diff options
20 files changed, 82 insertions, 53 deletions
diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index 46a8909..a56c327 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -236,11 +236,12 @@ Getting Started Start with the resulting files from Exercise 1. Complete ``TODO 7`` through ``TODO 13``. -First create a variable ``MY_MATH`` using the :command:`option` command +First create a variable ``USE_MYMATH`` using the :command:`option` command in the top-level ``CMakeLists.txt`` file. In that same file, use that option to determine whether to build and use the ``MathFunctions`` library. -Then, update ``tutorial.cxx`` and ``TutorialConfig.h.in`` to use ``MY_MATH``. +Then, update ``tutorial.cxx`` and ``TutorialConfig.h.in`` to use +``USE_MYMATH``. Build and Run ------------- @@ -314,9 +315,9 @@ Next, create an :command:`if` statement which checks the value of :command:`add_subdirectory` command from Exercise 1 with the additional :command:`list` commands. -When ``MY_MATH`` is ``ON``, the lists will be generated and will be added to -our project. When ``MY_MATH`` is ``OFF``, the lists stay empty. With this -strategy, we allow users to toggle ``MY_MATH`` to manipulate what library is +When ``USE_MYMATH`` is ``ON``, the lists will be generated and will be added to +our project. When ``USE_MYMATH`` is ``OFF``, the lists stay empty. With this +strategy, we allow users to toggle ``USE_MYMATH`` to manipulate what library is used in the build. The top-level CMakeLists.txt file will now look like the following: @@ -380,7 +381,7 @@ will cover the modern approach in the Step 3 of the tutorial. The corresponding changes to the source code are fairly straightforward. First, in ``tutorial.cxx``, we include the ``MathFunctions.h`` header if -``MY_MATH`` is defined. +``USE_MYMATH`` is defined. .. raw:: html diff --git a/Help/guide/tutorial/Step2/CMakeLists.txt b/Help/guide/tutorial/Step2/CMakeLists.txt index 2f7d56e..2b96128 100644 --- a/Help/guide/tutorial/Step2/CMakeLists.txt +++ b/Help/guide/tutorial/Step2/CMakeLists.txt @@ -7,7 +7,7 @@ project(Tutorial VERSION 1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# TODO 7: Create a variable MY_MATH using option and set default to ON +# TODO 7: Create a variable USE_MYMATH using option and set default to ON # configure a header file to pass some of the CMake settings # to the source code diff --git a/Help/guide/tutorial/Step2/TutorialConfig.h.in b/Help/guide/tutorial/Step2/TutorialConfig.h.in index adb4c55..6c09e1a 100644 --- a/Help/guide/tutorial/Step2/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step2/TutorialConfig.h.in @@ -2,4 +2,4 @@ #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ -// TODO 13: use cmakedefine to define MY_MATH +// TODO 13: use cmakedefine to define USE_MYMATH diff --git a/Help/guide/tutorial/Step2/tutorial.cxx b/Help/guide/tutorial/Step2/tutorial.cxx index f83aa7e..87f5e0f 100644 --- a/Help/guide/tutorial/Step2/tutorial.cxx +++ b/Help/guide/tutorial/Step2/tutorial.cxx @@ -5,7 +5,7 @@ #include "TutorialConfig.h" -// TODO 11: Only include MathFunctions if MY_MATH is defined +// TODO 11: Only include MathFunctions if USE_MYMATH is defined // TODO 5: Include MathFunctions.h @@ -22,7 +22,7 @@ int main(int argc, char* argv[]) // convert input to double const double inputValue = std::stod(argv[1]); - // TODO 12: Use mysqrt if MY_MATH is defined and sqrt otherwise + // TODO 12: Use mysqrt if USE_MYMATH is defined and sqrt otherwise // TODO 6: Replace sqrt with mysqrt diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 631bfd9..f06946b 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -173,8 +173,8 @@ int main(int argc, char const* const* argv) CommandArgument{ "--debug", CommandArgument::Values::Zero, debugLambda }, CommandArgument{ "--config", CommandArgument::Values::One, CommandArgument::setToValue(cpackConfigFile) }, - CommandArgument{ "--trace", CommandArgument::Values::One, traceLambda }, - CommandArgument{ "--trace-expand", CommandArgument::Values::One, + CommandArgument{ "--trace", CommandArgument::Values::Zero, traceLambda }, + CommandArgument{ "--trace-expand", CommandArgument::Values::Zero, traceExpandLambda }, CommandArgument{ "-C", CommandArgument::Values::One, CommandArgument::setToValue(cpackBuildConfig) }, diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c326ca6..077de42 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1030,19 +1030,6 @@ bool cmGlobalNinjaGenerator::OpenBuildFileStreams() return false; } - // New buffer size 8 MiB - constexpr auto buildFileStreamBufferSize = 8 * 1024 * 1024; - - // Ensure the buffer is allocated - if (!this->BuildFileStreamBuffer) { - this->BuildFileStreamBuffer = - cm::make_unique<char[]>(buildFileStreamBufferSize); - } - - // Enlarge the internal buffer of the `BuildFileStream` - this->BuildFileStream->rdbuf()->pubsetbuf(this->BuildFileStreamBuffer.get(), - buildFileStreamBufferSize); - // Write a comment about this file. *this->BuildFileStream << "# This file contains all the build statements describing the\n" diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index dc4f444..defa264 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -531,7 +531,6 @@ private: /// The file containing the build statement. (the relationship of the /// compilation DAG). std::unique_ptr<cmGeneratedFileStream> BuildFileStream; - std::unique_ptr<char[]> BuildFileStreamBuffer; /// The file containing the rule statements. (The action attached to each /// edge of the compilation DAG). std::unique_ptr<cmGeneratedFileStream> RulesFileStream; diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index 1a3e72e..8764f21 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -300,13 +300,32 @@ bool cmVSSetupAPIHelper::IsEWDKEnabled() return false; } +#if !defined(CMAKE_BOOTSTRAP) +namespace { +std::string FindVsWhereCommand() +{ + std::string vswhere; + static const char* programFiles[] = { "ProgramFiles(x86)", "ProgramFiles" }; + for (const char* pf : programFiles) { + if (cmSystemTools::GetEnv(pf, vswhere)) { + vswhere += "/Microsoft Visual Studio/Installer/vswhere.exe"; + if (cmSystemTools::FileExists(vswhere)) { + return vswhere; + } + } + } + vswhere = "vswhere.exe"; + return vswhere; +} +} +#endif + bool cmVSSetupAPIHelper::EnumerateVSInstancesWithVswhere( std::vector<VSInstanceInfo>& VSInstances) { #if !defined(CMAKE_BOOTSTRAP) // Construct vswhere command to get installed VS instances in JSON format - std::string vswhereExe = getenv("ProgramFiles(x86)") + - std::string(R"(\Microsoft Visual Studio\Installer\vswhere.exe)"); + std::string vswhereExe = FindVsWhereCommand(); std::vector<std::string> vswhereCmd = { vswhereExe, "-format", "json" }; // Execute vswhere command and capture JSON output diff --git a/Templates/MSBuild/FlagTables/v10_CSharp.json b/Templates/MSBuild/FlagTables/v10_CSharp.json index 5341841..526bcda 100644 --- a/Templates/MSBuild/FlagTables/v10_CSharp.json +++ b/Templates/MSBuild/FlagTables/v10_CSharp.json @@ -477,21 +477,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Templates/MSBuild/FlagTables/v11_CSharp.json b/Templates/MSBuild/FlagTables/v11_CSharp.json index 5341841..526bcda 100644 --- a/Templates/MSBuild/FlagTables/v11_CSharp.json +++ b/Templates/MSBuild/FlagTables/v11_CSharp.json @@ -477,21 +477,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Templates/MSBuild/FlagTables/v12_CSharp.json b/Templates/MSBuild/FlagTables/v12_CSharp.json index 5341841..526bcda 100644 --- a/Templates/MSBuild/FlagTables/v12_CSharp.json +++ b/Templates/MSBuild/FlagTables/v12_CSharp.json @@ -477,21 +477,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Templates/MSBuild/FlagTables/v140_CSharp.json b/Templates/MSBuild/FlagTables/v140_CSharp.json index 5341841..526bcda 100644 --- a/Templates/MSBuild/FlagTables/v140_CSharp.json +++ b/Templates/MSBuild/FlagTables/v140_CSharp.json @@ -477,21 +477,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Templates/MSBuild/FlagTables/v141_CSharp.json b/Templates/MSBuild/FlagTables/v141_CSharp.json index 5341841..526bcda 100644 --- a/Templates/MSBuild/FlagTables/v141_CSharp.json +++ b/Templates/MSBuild/FlagTables/v141_CSharp.json @@ -477,21 +477,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Templates/MSBuild/FlagTables/v142_CSharp.json b/Templates/MSBuild/FlagTables/v142_CSharp.json index 9ea8f4b..d57a97e 100644 --- a/Templates/MSBuild/FlagTables/v142_CSharp.json +++ b/Templates/MSBuild/FlagTables/v142_CSharp.json @@ -495,21 +495,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Templates/MSBuild/FlagTables/v143_CSharp.json b/Templates/MSBuild/FlagTables/v143_CSharp.json index 9ea8f4b..d57a97e 100644 --- a/Templates/MSBuild/FlagTables/v143_CSharp.json +++ b/Templates/MSBuild/FlagTables/v143_CSharp.json @@ -495,21 +495,21 @@ "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib", "comment": "", "value": "true", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib-", "comment": "", "value": "false", "flags": [] }, { - "name": "NoStandardLib", + "name": "NoStdLib", "switch": "nostdlib+", "comment": "", "value": "true", diff --git a/Tests/RunCMake/Ninja/Intl-build-check.cmake b/Tests/RunCMake/Ninja/Intl-build-check.cmake new file mode 100644 index 0000000..77f013c --- /dev/null +++ b/Tests/RunCMake/Ninja/Intl-build-check.cmake @@ -0,0 +1,5 @@ +include(${RunCMake_SOURCE_DIR}/Intl-common.cmake) +set(output "${RunCMake_TEST_BINARY_DIR}/${intl}-output.txt") +if(NOT EXISTS "${output}") + set(RunCMake_TEST_FAILED "Expected output does not exist:\n ${output}") +endif() diff --git a/Tests/RunCMake/Ninja/Intl-common.cmake b/Tests/RunCMake/Ninja/Intl-common.cmake new file mode 100644 index 0000000..7703976 --- /dev/null +++ b/Tests/RunCMake/Ninja/Intl-common.cmake @@ -0,0 +1 @@ +set(intl "intl-ë®") diff --git a/Tests/RunCMake/Ninja/Intl.cmake b/Tests/RunCMake/Ninja/Intl.cmake new file mode 100644 index 0000000..50e4ee4 --- /dev/null +++ b/Tests/RunCMake/Ninja/Intl.cmake @@ -0,0 +1,7 @@ +include(Intl-common.cmake) +set(input "${CMAKE_CURRENT_BINARY_DIR}/${intl}-input.txt") +set(output "${CMAKE_CURRENT_BINARY_DIR}/${intl}-output.txt") +file(WRITE "${input}" "${intl}\n") +add_custom_command(OUTPUT "${output}" + COMMAND ${CMAKE_COMMAND} -E copy "${input}" "${output}") +add_custom_target(drive ALL DEPENDS "${output}") diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 9f078e6..44a7ba1 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -33,6 +33,15 @@ function(run_NinjaToolMissing) endfunction() run_NinjaToolMissing() +function(run_Intl) + run_cmake(Intl) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Intl-build) + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(Intl-build ${CMAKE_COMMAND} --build .) +endfunction() +run_Intl() + function(run_NoWorkToDo) run_cmake(NoWorkToDo) set(RunCMake_TEST_NO_CLEAN 1) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index a3a3451..7245471 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -95,10 +95,11 @@ run_cmake(Inspect) include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") # FIXME: Support more compilers and default standard levels. -if (CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang)$" - AND DEFINED CMAKE_CXX_STANDARD_DEFAULT - AND DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT - ) +if (DEFINED CMAKE_CXX_STANDARD_DEFAULT AND + DEFINED CMAKE_CXX_EXTENSIONS_DEFAULT AND ( + (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 4.7) OR + (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + )) run_cmake(CMP0128-WARN) if(NOT CMAKE_CXX_STANDARD_DEFAULT EQUAL 11) run_cmake(CMP0128-NEW) |