diff options
Diffstat (limited to 'Help')
| -rw-r--r-- | Help/command/string.rst | 11 | ||||
| -rw-r--r-- | Help/guide/tutorial/Adding Support for a Testing Dashboard.rst | 95 | ||||
| -rw-r--r-- | Help/guide/tutorial/Adding System Introspection.rst | 153 | ||||
| -rw-r--r-- | Help/guide/tutorial/Adding a Library.rst | 13 | ||||
| -rw-r--r-- | Help/guide/tutorial/Installing and Testing.rst | 2 | ||||
| -rw-r--r-- | Help/guide/tutorial/Step2/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | Help/guide/tutorial/Step2/TutorialConfig.h.in | 2 | ||||
| -rw-r--r-- | Help/guide/tutorial/Step2/tutorial.cxx | 4 | ||||
| -rw-r--r-- | Help/guide/tutorial/Step6/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt | 20 | ||||
| -rw-r--r-- | Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx | 10 | ||||
| -rw-r--r-- | Help/manual/cmake.1.rst | 6 | ||||
| -rw-r--r-- | Help/prop_tgt/CONFIG_POSTFIX.rst | 10 | ||||
| -rw-r--r-- | Help/release/dev/timestamp-timezone.rst | 5 |
14 files changed, 263 insertions, 71 deletions
diff --git a/Help/command/string.rst b/Help/command/string.rst index 86cbd2e..217157c 100644 --- a/Help/command/string.rst +++ b/Help/command/string.rst @@ -522,6 +522,17 @@ specifiers: ``%Y`` The current year. +``%z`` + .. versionadded:: 3.26 + + The offset of the time zone from UTC, in hours and minutes, + with format ``+hhmm`` or ``-hhmm``. + +``%Z`` + .. versionadded:: 3.26 + + The time zone name. + Unknown format specifiers will be ignored and copied to the output as-is. diff --git a/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst b/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst index 45d5976..787e777 100644 --- a/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst +++ b/Help/guide/tutorial/Adding Support for a Testing Dashboard.rst @@ -4,33 +4,40 @@ Step 6: Adding Support for a Testing Dashboard Adding support for submitting our test results to a dashboard is simple. We already defined a number of tests for our project in :ref:`Testing Support <Tutorial Testing Support>`. Now we just have to run -those tests and submit them to a dashboard. To include support for dashboards -we include the :module:`CTest` module in our top-level ``CMakeLists.txt``. +those tests and submit them to CDash. -Replace: -.. literalinclude:: Step6/CMakeLists.txt - :caption: CMakeLists.txt - :name: CMakeLists.txt-enable_testing-remove - :language: cmake - :start-after: # enable testing - :end-before: # does the application run +Exercise 1 - Send Results to a Testing Dashboard +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -With: +Goal +---- -.. literalinclude:: Step7/CMakeLists.txt - :caption: CMakeLists.txt - :name: CMakeLists.txt-include-CTest - :language: cmake - :start-after: # enable testing - :end-before: # does the application run +Display our CTest results with CDash. + +Helpful Resources +----------------- + +* :manual:`ctest(1)` +* :command:`include` +* :module:`CTest` + +Files to Edit +------------- -The :module:`CTest` module will automatically call ``enable_testing()``, so we -can remove it from our CMake files. +* ``CMakeLists.txt`` + +Getting Started +--------------- + +For this exercise, complete ``TODO 1`` in the top-level ``CMakeLists.txt`` by +including the :module:`CTest` module. This will enable testing with CTest as +well as dashboard submissions to CDash, so we can safely remove the call to +:command:`enable_testing`. We will also need to acquire a ``CTestConfig.cmake`` file to be placed in the -top-level directory where we can specify information to CTest about the -project. It contains: +top-level directory. When run, the :manual:`ctest <ctest(1)>` executable will +read this file to gather information about the testing dashboard. It contains: * The project name @@ -41,9 +48,10 @@ project. It contains: * The URL of the CDash instance where the submission's generated documents will be sent -One has been provided for you in this directory. It would normally be -downloaded from the ``Settings`` page of the project on the CDash -instance that will host and display the test results. Once downloaded from +For this tutorial, a public dashboard server is used and its corresponding +``CTestConfig.cmake`` file is provided for you in this step's root directory. +In practice, this file would be downloaded from a project's ``Settings`` page +on the CDash instance intended to host the test results. Once downloaded from CDash, the file should not be modified locally. .. literalinclude:: Step7/CTestConfig.cmake @@ -51,11 +59,16 @@ CDash, the file should not be modified locally. :name: CTestConfig.cmake :language: cmake -The :manual:`ctest <ctest(1)>` executable will read in this file when it runs. -To create a simple dashboard you can run the :manual:`cmake <cmake(1)>` -executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project, -but do not build it yet. Instead, change directory to the binary tree, and then -run: + +Build and Run +------------- + +Note that as part of the CDash submission some information about your +development system (e.g. site name or full pathnames) may displayed publicly. + +To create a simple test dashboard, run the :manual:`cmake <cmake(1)>` +executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project +but do not build it yet. Instead, navigate to the build directory and run: .. code-block:: console @@ -70,6 +83,28 @@ type must be specified: Or, from an IDE, build the ``Experimental`` target. -The :manual:`ctest <ctest(1)>` executable will build and test the project and -submit the results to Kitware's public dashboard: +The :manual:`ctest <ctest(1)>` executable will build the project, run any +tests, and submit the results to Kitware's public dashboard: https://my.cdash.org/index.php?project=CMakeTutorial. + +Solution +-------- + +The only CMake code changed needed in this step was to enable dashboard +submissions to CDash by including the :module:`CTest` module in our top-level +``CMakeLists.txt``: + +.. raw:: html + + <details><summary>TODO 1: Click to show/hide answer</summary> + +.. literalinclude:: Step7/CMakeLists.txt + :caption: TODO 1: CMakeLists.txt + :name: CMakeLists.txt-include-CTest + :language: cmake + :start-after: # enable testing + :end-before: # does the application run + +.. raw:: html + + </details> diff --git a/Help/guide/tutorial/Adding System Introspection.rst b/Help/guide/tutorial/Adding System Introspection.rst index ba91df4..b69abd2 100644 --- a/Help/guide/tutorial/Adding System Introspection.rst +++ b/Help/guide/tutorial/Adding System Introspection.rst @@ -7,53 +7,156 @@ 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 :module:`CheckCXXSourceCompiles` module in +Exercise 1 - Assessing Dependency Availability +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Goal +---- + +Change implementation based on available system dependencies. + +Helpful Resources +----------------- + +* :module:`CheckCXXSourceCompiles` +* :command:`target_compile_definitions` + +Files to Edit +------------- + +* ``MathFunctions/CMakeLists.txt`` +* ``MathFunctions/mysqrt.cxx`` + +Getting Started +--------------- + +The starting source code is provided in the ``Step7`` directory. In this +exercise, complete ``TODO 1`` through ``TODO 5``. + +Start by editing ``MathFunctions/CMakeLists.txt``. Include the +:module:`CheckCXXSourceCompiles` module. Then, use +``check_cxx_source_compiles`` to determine whether ``log`` and ``exp`` are +available from ``cmath``. If they are available, use +:command:`target_compile_definitions` to specify ``HAVE_LOG`` and ``HAVE_EXP`` +as compile definitions. + +In the ``MathFunctions/mysqrt.cxx``, include ``cmath``. Then, if the system has +``log`` and ``exp``, use them to compute the square root. + +Build and Run +------------- + +Make a new directory called ``Step7_build``. Run the +:manual:`cmake <cmake(1)>` executable or the +:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it +with your chosen build tool and run the ``Tutorial`` executable. + +This can look like the following: + +.. code-block:: console + + mkdir Step7_build + cd Step7_build + cmake ../Step7 + cmake --build . + +Which function gives better results now, ``sqrt`` or ``mysqrt``? + +Solution +-------- + +In this exercise we will use functions from the +:module:`CheckCXXSourceCompiles` module so first we must include it in ``MathFunctions/CMakeLists.txt``. -Add the checks for ``log`` and ``exp`` to ``MathFunctions/CMakeLists.txt``, -after the call to :command:`target_include_directories`: +.. raw:: html + + <details><summary>TODO 1: Click to show/hide answer</summary> .. literalinclude:: Step8/MathFunctions/CMakeLists.txt - :caption: MathFunctions/CMakeLists.txt + :caption: TODO 1: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-include-check_cxx_source_compiles + :language: cmake + :start-after: # does this system provide the log and exp functions? + :end-before: check_cxx_source_compiles + +.. raw:: html + + </details> + +Then test for the availability of +``log`` and ``exp`` using ``check_cxx_compiles_source``. This function +lets us try compiling simple code with the required dependency prior to +the true source code compilation. The resulting variables ``HAVE_LOG`` +and ``HAVE_EXP`` represent whether those dependencies are available. + +.. raw:: html + + <details><summary>TODO 2: Click to show/hide answer</summary> + +.. literalinclude:: Step8/MathFunctions/CMakeLists.txt + :caption: TODO 2: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-check_cxx_source_compiles :language: cmake - :start-after: # to find MathFunctions.h, while we don't. + :start-after: include(CheckCXXSourceCompiles) :end-before: # add compile definitions -If available, use :command:`target_compile_definitions` to specify +.. raw:: html + + </details> + +Next, we need to pass these CMake variables to our source code. This way, +our source code can tell what resources are available. If both ``log`` and +``exp`` are available, use :command:`target_compile_definitions` to specify ``HAVE_LOG`` and ``HAVE_EXP`` as ``PRIVATE`` compile definitions. +.. raw:: html + + <details><summary>TODO 3: Click to show/hide answer</summary> + .. literalinclude:: Step8/MathFunctions/CMakeLists.txt - :caption: MathFunctions/CMakeLists.txt + :caption: TODO 3: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-target_compile_definitions :language: cmake :start-after: # add compile definitions :end-before: # install libs -If ``log`` and ``exp`` are available on the system, then we will use them to -compute the square root in the ``mysqrt`` function. Add the following code to -the ``mysqrt`` function in ``MathFunctions/mysqrt.cxx`` (don't forget the -``#endif`` before returning the result!): +.. raw:: html -.. literalinclude:: Step8/MathFunctions/mysqrt.cxx - :caption: MathFunctions/mysqrt.cxx - :name: MathFunctions/mysqrt.cxx-ifdef - :language: c++ - :start-after: // if we have both log and exp then use them - :end-before: // do ten iterations + </details> + +Since we may be using ``log`` and ``exp``, we need to modify +``mysqrt.cxx`` to include ``cmath``. + +.. raw:: html -We will also need to modify ``mysqrt.cxx`` to include ``cmath``. + <details><summary>TODO 4: Click to show/hide answer</summary> .. literalinclude:: Step8/MathFunctions/mysqrt.cxx - :caption: MathFunctions/mysqrt.cxx + :caption: TODO 4: MathFunctions/mysqrt.cxx :name: MathFunctions/mysqrt.cxx-include-cmath :language: c++ :end-before: #include <iostream> -Run the :manual:`cmake <cmake(1)>` executable or the -:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it -with your chosen build tool and run the Tutorial executable. +.. raw:: html -Which function gives better results now, ``sqrt`` or ``mysqrt``? + </details> + +If ``log`` and ``exp`` are available on the system, then use them to +compute the square root in the ``mysqrt`` function. The ``mysqrt`` function in +``MathFunctions/mysqrt.cxx`` will look as follows: + +.. raw:: html + + <details><summary>TODO 5: Click to show/hide answer</summary> + +.. literalinclude:: Step8/MathFunctions/mysqrt.cxx + :caption: TODO 5: MathFunctions/mysqrt.cxx + :name: MathFunctions/mysqrt.cxx-ifdef + :language: c++ + :start-after: // if we have both log and exp then use them + :end-before: // do ten iterations + +.. raw:: html + + </details> 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/Installing and Testing.rst b/Help/guide/tutorial/Installing and Testing.rst index fa13040..c020264 100644 --- a/Help/guide/tutorial/Installing and Testing.rst +++ b/Help/guide/tutorial/Installing and Testing.rst @@ -145,7 +145,7 @@ are similar. To the end of the top-level ``CMakeLists.txt`` we add: :name: TODO 3,4: CMakeLists.txt-install-TARGETS :language: cmake :start-after: # add the install targets - :end-before: # enable testing + :end-before: # TODO 1: Replace enable_testing() with include(CTest) .. 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/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index da9e852..c11e307 100644 --- a/Help/guide/tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -45,6 +45,7 @@ install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" DESTINATION include ) +# TODO 1: Replace enable_testing() with include(CTest) # enable testing enable_testing() diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt index b4724c4..e5bdc4d 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt @@ -9,6 +9,26 @@ target_include_directories(MathFunctions # link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) +# TODO 1: Include CheckCXXSourceCompiles + +# TODO 2: Use check_cxx_source_compiles with simple C++ code to verify +# availability of: +# * std::log +# * std::exp +# Store the results in HAVE_LOG and HAVE_EXP respectively. + +# Hint: Sample C++ code which uses log: +# #include <cmath> +# int main() { +# std::log(1.0); +# return 0; +# } + +# TODO 3: Conditionally on HAVE_LOG and HAVE_EXP, add private compile +# definitions "HAVE_LOG" and "HAVE_EXP" to the MathFunctions target. + +#Hint: Use target_compile_definitions() + # install libs set(installable_libs MathFunctions tutorial_compiler_flags) install(TARGETS ${installable_libs} DESTINATION lib) diff --git a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx index abe767d..3d2492a 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx @@ -1,5 +1,6 @@ #include <iostream> +// TODO 4: include cmath #include "MathFunctions.h" // a hack square root calculation using simple operations @@ -9,6 +10,14 @@ double mysqrt(double x) return 0; } + // TODO 5: If both HAVE_LOG and HAVE_EXP are defined, use the following: + //// double result = std::exp(std::log(x) * 0.5); + //// std::cout << "Computing sqrt of " << x << " to be " << result + //// << " using log and exp" << std::endl; + // else, use the existing logic. + + // Hint: Don't forget the #endif before returning the result! + double result = x; // do ten iterations @@ -20,5 +29,6 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } + return result; } diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 35bd05f..b31ad11 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -1286,6 +1286,12 @@ The options are: Lists the available workflow presets. The current working directory must contain CMake preset files. +.. option:: --fresh + + Perform a fresh configuration of the build tree. + This removes any existing ``CMakeCache.txt`` file and associated + ``CMakeFiles/`` directory, and recreates them from scratch. + View Help ========= diff --git a/Help/prop_tgt/CONFIG_POSTFIX.rst b/Help/prop_tgt/CONFIG_POSTFIX.rst index 5c2fbd7..69caa39 100644 --- a/Help/prop_tgt/CONFIG_POSTFIX.rst +++ b/Help/prop_tgt/CONFIG_POSTFIX.rst @@ -1,13 +1,13 @@ <CONFIG>_POSTFIX ---------------- -Postfix to append to the target file name for configuration <CONFIG>. +Postfix to append to the target file name for configuration ``<CONFIG>``. -When building with configuration <CONFIG> the value of this property +When building with configuration ``<CONFIG>`` the value of this property is appended to the target file name built on disk. For non-executable -targets, this property is initialized by the value of the variable -CMAKE_<CONFIG>_POSTFIX if it is set when a target is created. This -property is ignored on the Mac for Frameworks and App Bundles. +targets, this property is initialized by the value of the +:variable:`CMAKE_<CONFIG>_POSTFIX` variable if it is set when a target is +created. This property is ignored on macOS for Frameworks and App Bundles. For macOS see also the :prop_tgt:`FRAMEWORK_MULTI_CONFIG_POSTFIX_<CONFIG>` target property. diff --git a/Help/release/dev/timestamp-timezone.rst b/Help/release/dev/timestamp-timezone.rst new file mode 100644 index 0000000..178fa9a --- /dev/null +++ b/Help/release/dev/timestamp-timezone.rst @@ -0,0 +1,5 @@ +timestamp-timezone +------------------ + +* The :command:`string(TIMESTAMP)` and :command:`file(TIMESTAMP)` commands + now support the ``%z`` and ``%Z`` specifiers for the time zone. |
