diff options
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/tutorial.cxx | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/tutorial.cxx | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/TutorialConfig.h.in | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/tutorial.cxx | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/index.rst | 9 |
11 files changed, 22 insertions, 20 deletions
diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt index 3dbf28725b..dfa84c9413 100644 --- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt @@ -13,6 +13,8 @@ target_include_directories(MathFunctions 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) @@ -35,14 +37,12 @@ if(USE_MYMATH) ${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_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt index 483e20c406..a2df2a732b 100644 --- a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt @@ -13,6 +13,8 @@ target_include_directories(MathFunctions 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) @@ -34,6 +36,7 @@ if(USE_MYMATH) ${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} ) @@ -41,8 +44,6 @@ if(USE_MYMATH) target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() -target_compile_definitions(MathFunctions PRIVATE "$<$<BOOL:${USE_MYMATH}>:USE_MYMATH>") - # define the symbol stating we are using the declspec(dllexport) when # building on windows target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") diff --git a/Help/guide/tutorial/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx index ddc6364c05..f97805b1ce 100644 --- a/Help/guide/tutorial/MultiPackage/tutorial.cxx +++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx @@ -1,6 +1,5 @@ // A simple program that computes the square root of a number #include <iostream> -#include <sstream> #include <string> #include "MathFunctions.h" diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index 57555d3d1f..e0c06214cc 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -11,6 +11,8 @@ target_include_directories(MathFunctions 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) @@ -37,8 +39,6 @@ if(USE_MYMATH) POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) - target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt index df9f4dfcfb..e6cb8bacaf 100644 --- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt @@ -11,6 +11,8 @@ target_include_directories(MathFunctions 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) @@ -33,13 +35,12 @@ if(USE_MYMATH) ${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_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx index a3a2bdce00..a4f44d54fc 100644 --- a/Help/guide/tutorial/Step11/tutorial.cxx +++ b/Help/guide/tutorial/Step11/tutorial.cxx @@ -1,5 +1,4 @@ // A simple program that computes the square root of a number -#include <cmath> #include <iostream> #include <string> diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index f437053dae..d5f1cc8974 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -10,7 +10,8 @@ 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 the version number only +# 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 diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt index b40b464b7c..50f0701fe3 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt @@ -22,10 +22,6 @@ target_include_directories(MathFunctions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) -# use compile definitions to state if we have enabled USE_MYMATH -# and that anything that links to use will get this define -target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH") - # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step9/TutorialConfig.h.in b/Help/guide/tutorial/Step9/TutorialConfig.h.in index 8cd2fc9c63..e23f5213c7 100644 --- a/Help/guide/tutorial/Step9/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step9/TutorialConfig.h.in @@ -1,3 +1,4 @@ -// the configured version number +// 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 index 779fbcacaa..b3c6a4f43c 100644 --- a/Help/guide/tutorial/Step9/tutorial.cxx +++ b/Help/guide/tutorial/Step9/tutorial.cxx @@ -1,7 +1,6 @@ // A simple program that computes the square root of a number #include <cmath> #include <iostream> -#include <sstream> #include <string> #include "TutorialConfig.h" diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index f6fd580cb2..d858c25f97 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -645,7 +645,6 @@ The first step is to update the starting section of the top-level .. literalinclude:: Step10/CMakeLists.txt :language: cmake - :start-after: set(CMAKE_CXX_STANDARD 14) :end-before: # add the binary tree Now that we have made MathFunctions always be used, we will need to update @@ -658,7 +657,7 @@ The end result is that ``MathFunctions/CMakeLists.txt`` should look like: .. literalinclude:: Step10/MathFunctions/CMakeLists.txt :language: cmake - :lines: 1-40,46- + :lines: 1-36,42- Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and ``detail`` namespaces: @@ -671,6 +670,7 @@ 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: @@ -683,9 +683,14 @@ library that has position enabled 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) ====================================== |