diff options
Diffstat (limited to 'Help/guide/tutorial')
5 files changed, 31 insertions, 25 deletions
diff --git a/Help/guide/tutorial/A Basic Starting Point.rst b/Help/guide/tutorial/A Basic Starting Point.rst index 37b0668..2325e9e 100644 --- a/Help/guide/tutorial/A Basic Starting Point.rst +++ b/Help/guide/tutorial/A Basic Starting Point.rst @@ -102,7 +102,14 @@ Then call that build system to actually compile/link the project: cmake --build . -Finally, try to use the newly built ``Tutorial`` with these commands: +For multi-config generators (e.g. Visual Studio), first navigate to the +appropriate subdirectory, for example: + +.. code-block:: console + + cd Debug + +Finally, try to use the newly built ``Tutorial``: .. code-block:: console @@ -110,6 +117,11 @@ Finally, try to use the newly built ``Tutorial`` with these commands: Tutorial 10 Tutorial + +**Note:** Depending on the shell, the correct syntax may be ``Tutorial``, +``./Tutorial`` or ``.\Tutorial``. For simplicity, the exercises will use +``Tutorial`` throughout. + Solution -------- diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst index 3dab97f..910eacb 100644 --- a/Help/guide/tutorial/Adding Generator Expressions.rst +++ b/Help/guide/tutorial/Adding Generator Expressions.rst @@ -149,8 +149,8 @@ interface library. Lastly, we only want these warning flags to be used during builds. Consumers of our installed project should not inherit our warning flags. To specify -this, we wrap our flags in a generator expression using the ``BUILD_INTERFACE`` -condition. The resulting full code looks like the following: +this, we wrap our flags from TODO 3 in a generator expression using the +``BUILD_INTERFACE`` condition. The resulting full code looks like the following: .. raw:: html diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst index 2273063..5e803f5 100644 --- a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst +++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst @@ -127,7 +127,7 @@ Remove this line: </details> -And the lines: +And remove ``EXTRA_INCLUDES`` from ``target_include_directories``: .. raw:: html @@ -143,23 +143,6 @@ And the lines: </details> -The remaining code looks like: - -.. raw:: html - - <details><summary>Click to show/hide the resulting code</summary> - -.. literalinclude:: Step4/CMakeLists.txt - :caption: Remaining code after removing EXTRA_INCLUDES - :name: CMakeLists.txt-after-removing-EXTRA_INCLUDES - :language: cmake - :start-after: add_subdirectory(MathFunctions) - -.. raw:: html - - </details> - - Notice that with this technique, the only thing our executable target does to use our library is call :command:`target_link_libraries` with the name of the library target. In larger projects, the classic method of specifying @@ -309,8 +292,8 @@ and this: :caption: TODO 7: MathFunctions/CMakeLists.txt :name: MathFunctions-SqrtLibrary-target_link_libraries-step4 :language: cmake - :start-after: target_link_libraries(SqrtLibrary - :end-before: endif() + :start-after: # link our compiler flags interface library + :end-before: target_link_libraries(MathFunctions PUBLIC SqrtLibrary) .. raw:: html diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index 694dfaf..178334a 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -96,7 +96,7 @@ a library target called ``MathFunctions`` with :command:`add_library`. The source files for the library are passed as an argument to :command:`add_library`. This looks like the following line: -.. raw:: html/ +.. raw:: html <details><summary>TODO 1: Click to show/hide answer</summary> diff --git a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst index 504e42f..a2f5e2a 100644 --- a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst +++ b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst @@ -44,7 +44,18 @@ SqrtLibrary to be ``True`` when building shared libraries. :caption: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-POSITION_INDEPENDENT_CODE :language: cmake - :lines: 37-42 + :start-at: # state that SqrtLibrary need PIC when the default is shared libraries + :end-at: ) + +Define ``EXPORTING_MYMATH`` stating we are using ``declspec(dllexport)`` when +building on Windows. + +.. literalinclude:: Step11/MathFunctions/CMakeLists.txt + :caption: MathFunctions/CMakeLists.txt + :name: MathFunctions/CMakeLists.txt-dll-export + :language: cmake + :start-at: # define the symbol stating we are using the declspec(dllexport) when + :end-at: target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") **Exercise**: We modified ``MathFunctions.h`` to use dll export defines. Using CMake documentation can you find a helper module to simplify this? |