diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/CMakeLists.txt (renamed from Tests/Tutorial/Complete/CMakeLists.txt) | 12 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/Config.cmake.in (renamed from Tests/Tutorial/MultiPackage/Config.cmake.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/License.txt (renamed from Tests/Tutorial/Step9/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Complete/MathFunctions/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step9/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx (renamed from Tests/Tutorial/Step9/MathFunctions/MathFunctions.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step11/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step11/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/MathFunctions/mysqrt.h (renamed from Tests/Tutorial/Step9/MathFunctions/mysqrt.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/TutorialConfig.h.in (renamed from Tests/Tutorial/Step9/TutorialConfig.h.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Complete/tutorial.cxx (renamed from Tests/Tutorial/Step10/tutorial.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Consumer/CMakeLists.txt (renamed from Tests/Tutorial/Consumer/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Consumer/Config.cmake.in (renamed from Tests/Tutorial/Consumer/Config.cmake.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Consumer/consumer.cxx (renamed from Tests/Tutorial/Consumer/consumer.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/CMakeLists.txt (renamed from Tests/Tutorial/MultiPackage/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/Config.cmake.in (renamed from Tests/Tutorial/Complete/Config.cmake.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/License.txt (renamed from Tests/Tutorial/Step8/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/MultiPackage/MathFunctions/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step8/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx (renamed from Tests/Tutorial/Step11/MathFunctions/MathFunctions.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step10/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step10/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h (renamed from Tests/Tutorial/Step11/MathFunctions/mysqrt.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake (renamed from Tests/Tutorial/MultiPackage/MultiCPackConfig.cmake) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/TutorialConfig.h.in (renamed from Tests/Tutorial/Step11/TutorialConfig.h.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/MultiPackage/tutorial.cxx (renamed from Tests/Tutorial/MultiPackage/tutorial.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step1/CMakeLists.txt (renamed from Tests/Tutorial/Step1/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step1/TutorialConfig.h.in (renamed from Tests/Tutorial/Step2/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step1/tutorial.cxx (renamed from Tests/Tutorial/Step1/tutorial.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/CMakeLists.txt (renamed from Tests/Tutorial/Step11/CMakeLists.txt) | 12 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/License.txt (renamed from Tests/Tutorial/Step7/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step10/MathFunctions/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx (renamed from Tests/Tutorial/Step10/MathFunctions/MathFunctions.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/MathFunctions/mysqrt.h (renamed from Tests/Tutorial/Step10/MathFunctions/mysqrt.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/TutorialConfig.h.in (renamed from Tests/Tutorial/Step10/TutorialConfig.h.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step10/tutorial.cxx (renamed from Tests/Tutorial/Complete/tutorial.cxx) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/CMakeLists.txt (renamed from Tests/Tutorial/Step10/CMakeLists.txt) | 12 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/License.txt (renamed from Tests/Tutorial/Step11/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step11/MathFunctions/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx (renamed from Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Complete/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Complete/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/MathFunctions/mysqrt.h (renamed from Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/TutorialConfig.h.in (renamed from Tests/Tutorial/MultiPackage/TutorialConfig.h.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step11/tutorial.cxx (renamed from Tests/Tutorial/Step11/tutorial.cxx) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step2/CMakeLists.txt (renamed from Tests/Tutorial/Step2/CMakeLists.txt) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step2/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step9/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step2/TutorialConfig.h.in (renamed from Tests/Tutorial/Step1/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step2/tutorial.cxx (renamed from Tests/Tutorial/Step2/tutorial.cxx) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step3/CMakeLists.txt (renamed from Tests/Tutorial/Step3/CMakeLists.txt) | 2 | ||||
-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/Step8/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step3/TutorialConfig.h.in (renamed from Tests/Tutorial/Step5/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step3/tutorial.cxx (renamed from Tests/Tutorial/Step5/tutorial.cxx) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step4/CMakeLists.txt (renamed from Tests/Tutorial/Step4/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step4/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step7/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step4/TutorialConfig.h.in (renamed from Tests/Tutorial/Step3/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step4/tutorial.cxx (renamed from Tests/Tutorial/Step6/tutorial.cxx) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/CMakeLists.txt (renamed from Tests/Tutorial/Step5/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step6/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/TutorialConfig.h.in (renamed from Tests/Tutorial/Step4/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step5/tutorial.cxx (renamed from Tests/Tutorial/Step3/tutorial.cxx) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/CMakeLists.txt (renamed from Tests/Tutorial/Step6/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step11/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step5/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/TutorialConfig.h.in (renamed from Tests/Tutorial/Step8/TutorialConfig.h.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step6/tutorial.cxx (renamed from Tests/Tutorial/Step4/tutorial.cxx) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/CMakeLists.txt (renamed from Tests/Tutorial/Step7/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/License.txt (renamed from Tests/Tutorial/Step10/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step8/MathFunctions/CMakeLists.txt) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Step10/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step4/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/TutorialConfig.h.in (renamed from Tests/Tutorial/Step7/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step7/tutorial.cxx | 35 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/CMakeLists.txt (renamed from Tests/Tutorial/Step8/CMakeLists.txt) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/License.txt (renamed from Tests/Tutorial/MultiPackage/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/MultiPackage/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step3/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step8/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/TutorialConfig.h.in (renamed from Tests/Tutorial/Step6/TutorialConfig.h.in) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step8/tutorial.cxx | 35 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/CMakeLists.txt (renamed from Tests/Tutorial/Step9/CMakeLists.txt) | 2 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/CTestConfig.cmake (renamed from Tests/Tutorial/Step9/CTestConfig.cmake) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/License.txt (renamed from Tests/Tutorial/Complete/License.txt) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt (renamed from Tests/Tutorial/Step9/MathFunctions/CMakeLists.txt) | 1 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx (renamed from Tests/Tutorial/Complete/MathFunctions/MakeTable.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx (renamed from Tests/Tutorial/Complete/MathFunctions/MathFunctions.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h (renamed from Tests/Tutorial/Step2/MathFunctions/MathFunctions.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx (renamed from Tests/Tutorial/Step9/MathFunctions/mysqrt.cxx) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/MathFunctions/mysqrt.h (renamed from Tests/Tutorial/Complete/MathFunctions/mysqrt.h) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/TutorialConfig.h.in (renamed from Tests/Tutorial/Complete/TutorialConfig.h.in) | 0 | ||||
-rw-r--r-- | Help/guide/tutorial/Step9/tutorial.cxx (renamed from Tests/Tutorial/Step9/tutorial.cxx) | 3 | ||||
-rw-r--r-- | Help/guide/tutorial/index.rst | 758 | ||||
-rw-r--r-- | Help/index.rst | 8 | ||||
-rw-r--r-- | Help/manual/cmake-policies.7.rst | 9 | ||||
-rw-r--r-- | Help/prop_tgt/FRAMEWORK.rst | 4 | ||||
-rw-r--r-- | Help/release/dev/FindPython-FIND_ABI.rst | 5 | ||||
-rw-r--r-- | Modules/FindMatlab.cmake | 80 | ||||
-rw-r--r-- | Modules/FindProtobuf.cmake | 5 | ||||
-rw-r--r-- | Modules/FindPython.cmake | 45 | ||||
-rw-r--r-- | Modules/FindPython/Support.cmake | 369 | ||||
-rw-r--r-- | Modules/FindPython3.cmake | 41 | ||||
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmComputeLinkDepends.cxx | 4 | ||||
-rw-r--r-- | Source/cmComputeLinkDepends.h | 2 | ||||
-rw-r--r-- | Source/cmExportCommand.cxx | 11 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmMachO.cxx | 14 | ||||
-rw-r--r-- | Source/cmMachO.h | 2 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmRuntimeDependencyArchive.cxx | 5 | ||||
-rw-r--r-- | Source/cmState.cxx | 6 | ||||
-rw-r--r-- | Source/cmState.h | 4 | ||||
-rw-r--r-- | Source/cmake.cxx | 25 | ||||
-rw-r--r-- | Source/cmake.h | 36 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 230 | ||||
-rw-r--r-- | Tests/FindIconv/Test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/FindPython/FindPythonScript.cmake | 10 | ||||
-rw-r--r-- | Tests/FindPython/Python2/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/FindPython/Python3/CMakeLists.txt | 53 | ||||
-rw-r--r-- | Tests/RunCMake/export/Empty.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/export/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/Tutorial/Consumer/directions.txt | 6 | ||||
-rw-r--r-- | Tests/Tutorial/MultiPackage/directions.txt | 34 | ||||
-rw-r--r-- | Tests/Tutorial/Readme.txt | 16 | ||||
-rw-r--r-- | Tests/Tutorial/Step1/directions.txt | 95 | ||||
-rw-r--r-- | Tests/Tutorial/Step10/directions.txt | 38 | ||||
-rw-r--r-- | Tests/Tutorial/Step11/directions.txt | 104 | ||||
-rw-r--r-- | Tests/Tutorial/Step2/directions.txt | 101 | ||||
-rw-r--r-- | Tests/Tutorial/Step3/directions.txt | 26 | ||||
-rw-r--r-- | Tests/Tutorial/Step4/directions.txt | 72 | ||||
-rw-r--r-- | Tests/Tutorial/Step5/directions.txt | 69 | ||||
-rw-r--r-- | Tests/Tutorial/Step6/directions.txt | 104 | ||||
-rw-r--r-- | Tests/Tutorial/Step7/build1.cmake | 5 | ||||
-rw-r--r-- | Tests/Tutorial/Step7/directions.txt | 40 | ||||
-rw-r--r-- | Tests/Tutorial/Step7/tutorial.cxx | 32 | ||||
-rw-r--r-- | Tests/Tutorial/Step8/directions.txt | 38 | ||||
-rw-r--r-- | Tests/Tutorial/Step8/tutorial.cxx | 32 | ||||
-rw-r--r-- | Tests/Tutorial/Step9/directions.txt | 166 |
157 files changed, 1493 insertions, 1406 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 51a1d8b..399e79c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -817,7 +817,7 @@ 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|index.rst)($|/)" EXCLUDE ) # Install auxiliary files integrating with other tools. diff --git a/Tests/Tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt index 1c97545..e84f932 100644 --- a/Tests/Tutorial/Complete/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.3) project(Tutorial) +set(CMAKE_CXX_STANDARD 14) + +# set the version number +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # 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}") -set(CMAKE_CXX_STANDARD 14) - option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -# the version number. -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - if(APPLE) set(CMAKE_INSTALL_RPATH "@executable_path/../lib") elseif(UNIX) diff --git a/Tests/Tutorial/MultiPackage/Config.cmake.in b/Help/guide/tutorial/Complete/Config.cmake.in index 17cbabd..17cbabd 100644 --- a/Tests/Tutorial/MultiPackage/Config.cmake.in +++ b/Help/guide/tutorial/Complete/Config.cmake.in diff --git a/Tests/Tutorial/Step9/License.txt b/Help/guide/tutorial/Complete/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/Step9/License.txt +++ b/Help/guide/tutorial/Complete/License.txt diff --git a/Tests/Tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt index 161ad64..63c0f5f 100644 --- a/Tests/Tutorial/Complete/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt @@ -1,4 +1,3 @@ - # add the library that runs add_library(MathFunctions MathFunctions.cxx) @@ -62,6 +61,7 @@ target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") 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) diff --git a/Tests/Tutorial/Step9/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step9/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Complete/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step9/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx index 5351184..5351184 100644 --- a/Tests/Tutorial/Step9/MathFunctions/MathFunctions.cxx +++ b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.cxx diff --git a/Tests/Tutorial/Step11/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h index 3fb547b..3fb547b 100644 --- a/Tests/Tutorial/Step11/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Complete/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step11/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx index 96d9421..96d9421 100644 --- a/Tests/Tutorial/Step11/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step9/MathFunctions/mysqrt.h b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.h index e1c42ef..e1c42ef 100644 --- a/Tests/Tutorial/Step9/MathFunctions/mysqrt.h +++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.h diff --git a/Tests/Tutorial/Step9/TutorialConfig.h.in b/Help/guide/tutorial/Complete/TutorialConfig.h.in index 8cd2fc9..8cd2fc9 100644 --- a/Tests/Tutorial/Step9/TutorialConfig.h.in +++ b/Help/guide/tutorial/Complete/TutorialConfig.h.in diff --git a/Tests/Tutorial/Step10/tutorial.cxx b/Help/guide/tutorial/Complete/tutorial.cxx index 4451cbd..4451cbd 100644 --- a/Tests/Tutorial/Step10/tutorial.cxx +++ b/Help/guide/tutorial/Complete/tutorial.cxx diff --git a/Tests/Tutorial/Consumer/CMakeLists.txt b/Help/guide/tutorial/Consumer/CMakeLists.txt index 5097917..5097917 100644 --- a/Tests/Tutorial/Consumer/CMakeLists.txt +++ b/Help/guide/tutorial/Consumer/CMakeLists.txt diff --git a/Tests/Tutorial/Consumer/Config.cmake.in b/Help/guide/tutorial/Consumer/Config.cmake.in index 0b3f1e4..0b3f1e4 100644 --- a/Tests/Tutorial/Consumer/Config.cmake.in +++ b/Help/guide/tutorial/Consumer/Config.cmake.in diff --git a/Tests/Tutorial/Consumer/consumer.cxx b/Help/guide/tutorial/Consumer/consumer.cxx index ae7877b..ae7877b 100644 --- a/Tests/Tutorial/Consumer/consumer.cxx +++ b/Help/guide/tutorial/Consumer/consumer.cxx diff --git a/Tests/Tutorial/MultiPackage/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/CMakeLists.txt index 067e807..067e807 100644 --- a/Tests/Tutorial/MultiPackage/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/CMakeLists.txt diff --git a/Tests/Tutorial/Complete/Config.cmake.in b/Help/guide/tutorial/MultiPackage/Config.cmake.in index 17cbabd..17cbabd 100644 --- a/Tests/Tutorial/Complete/Config.cmake.in +++ b/Help/guide/tutorial/MultiPackage/Config.cmake.in diff --git a/Tests/Tutorial/Step8/License.txt b/Help/guide/tutorial/MultiPackage/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/Step8/License.txt +++ b/Help/guide/tutorial/MultiPackage/License.txt diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt index 161ad64..161ad64 100644 --- a/Tests/Tutorial/MultiPackage/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt diff --git a/Tests/Tutorial/Step8/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step8/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step11/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx index 5351184..5351184 100644 --- a/Tests/Tutorial/Step11/MathFunctions/MathFunctions.cxx +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.cxx diff --git a/Tests/Tutorial/Step10/MathFunctions/MathFunctions.h b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h index 3fb547b..3fb547b 100644 --- a/Tests/Tutorial/Step10/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step10/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx index 96d9421..96d9421 100644 --- a/Tests/Tutorial/Step10/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step11/MathFunctions/mysqrt.h b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h index e1c42ef..e1c42ef 100644 --- a/Tests/Tutorial/Step11/MathFunctions/mysqrt.h +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.h diff --git a/Tests/Tutorial/MultiPackage/MultiCPackConfig.cmake b/Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake index 403b633..403b633 100644 --- a/Tests/Tutorial/MultiPackage/MultiCPackConfig.cmake +++ b/Help/guide/tutorial/MultiPackage/MultiCPackConfig.cmake diff --git a/Tests/Tutorial/Step11/TutorialConfig.h.in b/Help/guide/tutorial/MultiPackage/TutorialConfig.h.in index 8cd2fc9..8cd2fc9 100644 --- a/Tests/Tutorial/Step11/TutorialConfig.h.in +++ b/Help/guide/tutorial/MultiPackage/TutorialConfig.h.in diff --git a/Tests/Tutorial/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx index 4451cbd..4451cbd 100644 --- a/Tests/Tutorial/MultiPackage/tutorial.cxx +++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx diff --git a/Tests/Tutorial/Step1/CMakeLists.txt b/Help/guide/tutorial/Step1/CMakeLists.txt index 141f0c2..141f0c2 100644 --- a/Tests/Tutorial/Step1/CMakeLists.txt +++ b/Help/guide/tutorial/Step1/CMakeLists.txt diff --git a/Tests/Tutorial/Step2/TutorialConfig.h.in b/Help/guide/tutorial/Step1/TutorialConfig.h.in index 5395a06..7e4d7fa 100644 --- a/Tests/Tutorial/Step2/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step1/TutorialConfig.h.in @@ -1,4 +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/Tests/Tutorial/Step1/tutorial.cxx b/Help/guide/tutorial/Step1/tutorial.cxx index f8dd0c6..f8dd0c6 100644 --- a/Tests/Tutorial/Step1/tutorial.cxx +++ b/Help/guide/tutorial/Step1/tutorial.cxx diff --git a/Tests/Tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt index 79aadd5..5819272 100644 --- a/Tests/Tutorial/Step11/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.3) project(Tutorial) +set(CMAKE_CXX_STANDARD 14) + +# Set the version number +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # 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}") -set(CMAKE_CXX_STANDARD 14) - option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -# the version number. -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # configure a header file to pass the version number only configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" diff --git a/Tests/Tutorial/Step7/License.txt b/Help/guide/tutorial/Step10/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/Step7/License.txt +++ b/Help/guide/tutorial/Step10/License.txt diff --git a/Tests/Tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index 7a23505..aafd090 100644 --- a/Tests/Tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -1,4 +1,3 @@ - # add the library that runs add_library(MathFunctions MathFunctions.cxx) @@ -57,5 +56,6 @@ endif() # 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/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step7/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step10/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step10/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx index 5351184..5351184 100644 --- a/Tests/Tutorial/Step10/MathFunctions/MathFunctions.cxx +++ b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.cxx diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h index 3fb547b..3fb547b 100644 --- a/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step10/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx index 96d9421..96d9421 100644 --- a/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step10/MathFunctions/mysqrt.h b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.h index e1c42ef..e1c42ef 100644 --- a/Tests/Tutorial/Step10/MathFunctions/mysqrt.h +++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.h diff --git a/Tests/Tutorial/Step10/TutorialConfig.h.in b/Help/guide/tutorial/Step10/TutorialConfig.h.in index 8cd2fc9..8cd2fc9 100644 --- a/Tests/Tutorial/Step10/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step10/TutorialConfig.h.in diff --git a/Tests/Tutorial/Complete/tutorial.cxx b/Help/guide/tutorial/Step10/tutorial.cxx index 4451cbd..42eaab9 100644 --- a/Tests/Tutorial/Complete/tutorial.cxx +++ b/Help/guide/tutorial/Step10/tutorial.cxx @@ -9,6 +9,7 @@ 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; diff --git a/Tests/Tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt index 79aadd5..2e5cb15 100644 --- a/Tests/Tutorial/Step10/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.3) project(Tutorial) +set(CMAKE_CXX_STANDARD 14) + +# set the version number +set(Tutorial_VERSION_MAJOR 1) +set(Tutorial_VERSION_MINOR 0) + # 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}") -set(CMAKE_CXX_STANDARD 14) - option(BUILD_SHARED_LIBS "Build using shared libraries" ON) -# the version number. -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # configure a header file to pass the version number only configure_file( "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" diff --git a/Tests/Tutorial/Step11/License.txt b/Help/guide/tutorial/Step11/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/Step11/License.txt +++ b/Help/guide/tutorial/Step11/License.txt diff --git a/Tests/Tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt index 760d6a5..ea42770 100644 --- a/Tests/Tutorial/Step11/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt @@ -1,4 +1,3 @@ - # add the library that runs add_library(MathFunctions MathFunctions.cxx) @@ -56,5 +55,6 @@ target_compile_definitions(MathFunctions PRIVATE "$<$<BOOL:${USE_MYMATH}>:USE_MY #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/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step6/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step11/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx index 5351184..5351184 100644 --- a/Tests/Tutorial/MultiPackage/MathFunctions/MathFunctions.cxx +++ b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.cxx diff --git a/Tests/Tutorial/Complete/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h index 3fb547b..3fb547b 100644 --- a/Tests/Tutorial/Complete/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step11/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Complete/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx index 96d9421..96d9421 100644 --- a/Tests/Tutorial/Complete/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.h b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.h index e1c42ef..e1c42ef 100644 --- a/Tests/Tutorial/MultiPackage/MathFunctions/mysqrt.h +++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.h diff --git a/Tests/Tutorial/MultiPackage/TutorialConfig.h.in b/Help/guide/tutorial/Step11/TutorialConfig.h.in index 8cd2fc9..8cd2fc9 100644 --- a/Tests/Tutorial/MultiPackage/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step11/TutorialConfig.h.in diff --git a/Tests/Tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx index 38d4a79..6acafd2 100644 --- a/Tests/Tutorial/Step11/tutorial.cxx +++ b/Help/guide/tutorial/Step11/tutorial.cxx @@ -9,6 +9,7 @@ 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; diff --git a/Tests/Tutorial/Step2/CMakeLists.txt b/Help/guide/tutorial/Step2/CMakeLists.txt index 8e50e7c..1f43b2b 100644 --- a/Tests/Tutorial/Step2/CMakeLists.txt +++ b/Help/guide/tutorial/Step2/CMakeLists.txt @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.3) project(Tutorial) set(CMAKE_CXX_STANDARD 14) -# the version number. + +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt index 8b443a6..8b443a6 100644 --- a/Tests/Tutorial/Step3/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt diff --git a/Tests/Tutorial/Step9/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step2/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step9/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step2/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx index 7d9379e..7d9379e 100644 --- a/Tests/Tutorial/Step5/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step1/TutorialConfig.h.in b/Help/guide/tutorial/Step2/TutorialConfig.h.in index 5395a06..7e4d7fa 100644 --- a/Tests/Tutorial/Step1/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step2/TutorialConfig.h.in @@ -1,4 +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/Tests/Tutorial/Step2/tutorial.cxx b/Help/guide/tutorial/Step2/tutorial.cxx index 5ba34e8..f2ab446 100644 --- a/Tests/Tutorial/Step2/tutorial.cxx +++ b/Help/guide/tutorial/Step2/tutorial.cxx @@ -8,6 +8,7 @@ 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; diff --git a/Tests/Tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt index baa0a44..966c38a 100644 --- a/Tests/Tutorial/Step3/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 14) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt index 8b443a6..8b443a6 100644 --- a/Tests/Tutorial/Step2/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt diff --git a/Tests/Tutorial/Step8/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step3/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step8/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step3/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx index 7d9379e..7d9379e 100644 --- a/Tests/Tutorial/Step4/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step3/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step5/TutorialConfig.h.in b/Help/guide/tutorial/Step3/TutorialConfig.h.in index 25a0602..e23f521 100644 --- a/Tests/Tutorial/Step5/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step3/TutorialConfig.h.in @@ -2,4 +2,3 @@ #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH - diff --git a/Tests/Tutorial/Step5/tutorial.cxx b/Help/guide/tutorial/Step3/tutorial.cxx index c2b89df..8156a9c 100644 --- a/Tests/Tutorial/Step5/tutorial.cxx +++ b/Help/guide/tutorial/Step3/tutorial.cxx @@ -5,6 +5,7 @@ #include "TutorialConfig.h" +// should we include the MathFunctions header? #ifdef USE_MYMATH # include "MathFunctions.h" #endif @@ -12,6 +13,7 @@ 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; @@ -20,6 +22,7 @@ int main(int argc, char* argv[]) double inputValue = std::stod(argv[1]); + // which square root function should we use? #ifdef USE_MYMATH double outputValue = mysqrt(inputValue); #else diff --git a/Tests/Tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt index 9ce60b9..a157bda 100644 --- a/Tests/Tutorial/Step4/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 14) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt index 0515852..0515852 100644 --- a/Tests/Tutorial/Step4/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt diff --git a/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step4/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step7/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step4/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx index 7d9379e..7d9379e 100644 --- a/Tests/Tutorial/Step3/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step4/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step3/TutorialConfig.h.in b/Help/guide/tutorial/Step4/TutorialConfig.h.in index 25a0602..e23f521 100644 --- a/Tests/Tutorial/Step3/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step4/TutorialConfig.h.in @@ -2,4 +2,3 @@ #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH - diff --git a/Tests/Tutorial/Step6/tutorial.cxx b/Help/guide/tutorial/Step4/tutorial.cxx index c2b89df..8156a9c 100644 --- a/Tests/Tutorial/Step6/tutorial.cxx +++ b/Help/guide/tutorial/Step4/tutorial.cxx @@ -5,6 +5,7 @@ #include "TutorialConfig.h" +// should we include the MathFunctions header? #ifdef USE_MYMATH # include "MathFunctions.h" #endif @@ -12,6 +13,7 @@ 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; @@ -20,6 +22,7 @@ int main(int argc, char* argv[]) double inputValue = std::stod(argv[1]); + // which square root function should we use? #ifdef USE_MYMATH double outputValue = mysqrt(inputValue); #else diff --git a/Tests/Tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt index 828b9fc..76b9179 100644 --- a/Tests/Tutorial/Step5/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/CMakeLists.txt @@ -6,7 +6,7 @@ set(CMAKE_CXX_STANDARD 14) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt index 11cf412..b12f27d 100644 --- a/Tests/Tutorial/Step5/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt @@ -6,5 +6,6 @@ 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/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step5/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step5/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step5/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step6/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step5/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx index 7d9379e..7d9379e 100644 --- a/Tests/Tutorial/Step2/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step5/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step4/TutorialConfig.h.in b/Help/guide/tutorial/Step5/TutorialConfig.h.in index 25a0602..e23f521 100644 --- a/Tests/Tutorial/Step4/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step5/TutorialConfig.h.in @@ -2,4 +2,3 @@ #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/Help/guide/tutorial/Step5/tutorial.cxx index c2b89df..8156a9c 100644 --- a/Tests/Tutorial/Step3/tutorial.cxx +++ b/Help/guide/tutorial/Step5/tutorial.cxx @@ -5,6 +5,7 @@ #include "TutorialConfig.h" +// should we include the MathFunctions header? #ifdef USE_MYMATH # include "MathFunctions.h" #endif @@ -12,6 +13,7 @@ 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; @@ -20,6 +22,7 @@ int main(int argc, char* argv[]) double inputValue = std::stod(argv[1]); + // which square root function should we use? #ifdef USE_MYMATH double outputValue = mysqrt(inputValue); #else diff --git a/Tests/Tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index a78b0ff..5829891 100644 --- a/Tests/Tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -3,7 +3,7 @@ project(Tutorial) set(CMAKE_CXX_STANDARD 14) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt index 2946075..def1140 100644 --- a/Tests/Tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt @@ -4,11 +4,11 @@ add_library(MathFunctions mysqrt.cxx) # 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 - target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${Tutorial_BINARY_DIR} ) +# install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step11/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step11/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step6/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step6/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step5/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step6/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx index b9ad20a..b9ad20a 100644 --- a/Tests/Tutorial/Step6/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step8/TutorialConfig.h.in b/Help/guide/tutorial/Step6/TutorialConfig.h.in index e97ce24..e97ce24 100644 --- a/Tests/Tutorial/Step8/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step6/TutorialConfig.h.in diff --git a/Tests/Tutorial/Step4/tutorial.cxx b/Help/guide/tutorial/Step6/tutorial.cxx index c2b89df..8156a9c 100644 --- a/Tests/Tutorial/Step4/tutorial.cxx +++ b/Help/guide/tutorial/Step6/tutorial.cxx @@ -5,6 +5,7 @@ #include "TutorialConfig.h" +// should we include the MathFunctions header? #ifdef USE_MYMATH # include "MathFunctions.h" #endif @@ -12,6 +13,7 @@ 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; @@ -20,6 +22,7 @@ int main(int argc, char* argv[]) double inputValue = std::stod(argv[1]); + // which square root function should we use? #ifdef USE_MYMATH double outputValue = mysqrt(inputValue); #else diff --git a/Tests/Tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index 33aa039..17e6a60 100644 --- a/Tests/Tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -3,7 +3,7 @@ project(Tutorial) set(CMAKE_CXX_STANDARD 14) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step10/License.txt b/Help/guide/tutorial/Step7/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/Step10/License.txt +++ b/Help/guide/tutorial/Step7/License.txt diff --git a/Tests/Tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt index dc3eb98..3c3a816 100644 --- a/Tests/Tutorial/Step8/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt @@ -25,5 +25,6 @@ target_include_directories(MathFunctions ${CMAKE_CURRENT_BINARY_DIR} ) +# install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Step10/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Step10/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step7/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step7/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step4/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step7/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx index 5272f56..5272f56 100644 --- a/Tests/Tutorial/Step7/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step7/TutorialConfig.h.in b/Help/guide/tutorial/Step7/TutorialConfig.h.in index a091265..e97ce24 100644 --- a/Tests/Tutorial/Step7/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step7/TutorialConfig.h.in @@ -6,4 +6,3 @@ // does the platform provide exp and log functions? #cmakedefine HAVE_LOG #cmakedefine HAVE_EXP - diff --git a/Help/guide/tutorial/Step7/tutorial.cxx b/Help/guide/tutorial/Step7/tutorial.cxx new file mode 100644 index 0000000..8156a9c --- /dev/null +++ b/Help/guide/tutorial/Step7/tutorial.cxx @@ -0,0 +1,35 @@ +// 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; + } + + double inputValue = std::stod(argv[1]); + + // which square root function should we use? +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index 03dc7c0..86725e8 100644 --- a/Tests/Tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -3,7 +3,7 @@ project(Tutorial) set(CMAKE_CXX_STANDARD 14) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) @@ -74,6 +74,7 @@ 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}") diff --git a/Tests/Tutorial/MultiPackage/License.txt b/Help/guide/tutorial/Step8/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/MultiPackage/License.txt +++ b/Help/guide/tutorial/Step8/License.txt diff --git a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt index dc3eb98..3c3a816 100644 --- a/Tests/Tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt @@ -25,5 +25,6 @@ target_include_directories(MathFunctions ${CMAKE_CURRENT_BINARY_DIR} ) +# install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/MultiPackage/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/MultiPackage/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step8/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step3/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step8/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step8/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx index 5b862fb..5b862fb 100644 --- a/Tests/Tutorial/Step8/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Step6/TutorialConfig.h.in b/Help/guide/tutorial/Step8/TutorialConfig.h.in index a091265..e97ce24 100644 --- a/Tests/Tutorial/Step6/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step8/TutorialConfig.h.in @@ -6,4 +6,3 @@ // does the platform provide exp and log functions? #cmakedefine HAVE_LOG #cmakedefine HAVE_EXP - diff --git a/Help/guide/tutorial/Step8/tutorial.cxx b/Help/guide/tutorial/Step8/tutorial.cxx new file mode 100644 index 0000000..8156a9c --- /dev/null +++ b/Help/guide/tutorial/Step8/tutorial.cxx @@ -0,0 +1,35 @@ +// 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; + } + + double inputValue = std::stod(argv[1]); + + // which square root function should we use? +#ifdef USE_MYMATH + double outputValue = mysqrt(inputValue); +#else + double outputValue = sqrt(inputValue); +#endif + + std::cout << "The square root of " << inputValue << " is " << outputValue + << std::endl; + return 0; +} diff --git a/Tests/Tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index 4981fe2..07ab90a 100644 --- a/Tests/Tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -3,7 +3,7 @@ project(Tutorial) set(CMAKE_CXX_STANDARD 14) -# the version number. +# set the version number set(Tutorial_VERSION_MAJOR 1) set(Tutorial_VERSION_MINOR 0) diff --git a/Tests/Tutorial/Step9/CTestConfig.cmake b/Help/guide/tutorial/Step9/CTestConfig.cmake index 7a927ac..7a927ac 100644 --- a/Tests/Tutorial/Step9/CTestConfig.cmake +++ b/Help/guide/tutorial/Step9/CTestConfig.cmake diff --git a/Tests/Tutorial/Complete/License.txt b/Help/guide/tutorial/Step9/License.txt index c62d00b..c62d00b 100644 --- a/Tests/Tutorial/Complete/License.txt +++ b/Help/guide/tutorial/Step9/License.txt diff --git a/Tests/Tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt index e651a57..c8cd1dd 100644 --- a/Tests/Tutorial/Step9/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt @@ -31,5 +31,6 @@ if(HAVE_LOG AND HAVE_EXP) PRIVATE "HAVE_LOG" "HAVE_EXP") endif() +# install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Tests/Tutorial/Complete/MathFunctions/MakeTable.cxx b/Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx index ee58556..ee58556 100644 --- a/Tests/Tutorial/Complete/MathFunctions/MakeTable.cxx +++ b/Help/guide/tutorial/Step9/MathFunctions/MakeTable.cxx diff --git a/Tests/Tutorial/Complete/MathFunctions/MathFunctions.cxx b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx index 5351184..5351184 100644 --- a/Tests/Tutorial/Complete/MathFunctions/MathFunctions.cxx +++ b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.cxx diff --git a/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h index cd36bcc..cd36bcc 100644 --- a/Tests/Tutorial/Step2/MathFunctions/MathFunctions.h +++ b/Help/guide/tutorial/Step9/MathFunctions/MathFunctions.h diff --git a/Tests/Tutorial/Step9/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx index 8b82141..8b82141 100644 --- a/Tests/Tutorial/Step9/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx diff --git a/Tests/Tutorial/Complete/MathFunctions/mysqrt.h b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.h index e1c42ef..e1c42ef 100644 --- a/Tests/Tutorial/Complete/MathFunctions/mysqrt.h +++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.h diff --git a/Tests/Tutorial/Complete/TutorialConfig.h.in b/Help/guide/tutorial/Step9/TutorialConfig.h.in index 8cd2fc9..8cd2fc9 100644 --- a/Tests/Tutorial/Complete/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step9/TutorialConfig.h.in diff --git a/Tests/Tutorial/Step9/tutorial.cxx b/Help/guide/tutorial/Step9/tutorial.cxx index 6c41859..3286bc8 100644 --- a/Tests/Tutorial/Step9/tutorial.cxx +++ b/Help/guide/tutorial/Step9/tutorial.cxx @@ -6,6 +6,7 @@ #include "TutorialConfig.h" +// should we include the MathFunctions header? #ifdef USE_MYMATH # include "MathFunctions.h" #endif @@ -13,6 +14,7 @@ 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; @@ -21,6 +23,7 @@ int main(int argc, char* argv[]) double inputValue = std::stod(argv[1]); + // which square root function should we use? #ifdef USE_MYMATH double outputValue = mysqrt(inputValue); #else diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst new file mode 100644 index 0000000..db8e7a0 --- /dev/null +++ b/Help/guide/tutorial/index.rst @@ -0,0 +1,758 @@ +CMake Tutorial +************** + +.. only:: html + + .. contents:: + +This 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. This tutorial +can be found in the ``Help/guide/tutorial`` directory of the CMake +source code tree. Each topic has its own subdirectory containing code +that may be used as a starting point for that step. 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 two line CMakeLists file is all that is required. +This will be the starting point for our tutorial. The CMakeLists file +looks like: + +.. literalinclude:: Step1/CMakeLists.txt + :language: cmake + +Note that this example uses lower case commands in the CMakeLists file. +Upper, lower, and mixed case commands are supported by CMake. The source +code for ``tutorial.cxx`` will compute the square root of a number and +the first version of it is very simple, as follows: + +.. literalinclude:: Step1/tutorial.cxx + :language: c++ + +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 provides more flexibility. + +To add a version number we modify the CMakeLists file as follows: + +.. literalinclude:: Step2/CMakeLists.txt + :language: cmake + :start-after: # set the version number + :end-before: # configure a header file + +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. + +.. literalinclude:: Step2/CMakeLists.txt + :language: cmake + :start-after: # so that we will find TutorialConfig.h + +We then create a ``TutorialConfig.h.in`` file in the source tree with the +following contents: + +.. literalinclude:: Step1/TutorialConfig.h.in + :language: cmake + +When CMake configures this header file the values for +``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be +replaced by the values from the CMakeLists file. Next we modify +``tutorial.cxx`` to include the configured header file and to make use of the +version numbers. The updated source code is listed below. + +.. literalinclude:: Step2/tutorial.cxx + :language: c++ + :start-after: // report version + :end-before: return 1; + +The main changes are the inclusion of the ``TutorialConfig.h`` header +file and printing out a version number as part of the usage message. + +Specify the C++ Standard +------------------------- + +Next let's add some C++11 features to our project. We will need to explicitly +state in the CMake code that it should use the correct flags. The easiest way +to enable C++11 support for CMake is by using the ``CMAKE_CXX_STANDARD`` +variable. + +First, replace ``atof`` with ``std::stod`` in ``tutorial.cxx``. + +Then, set the ``CMAKE_CXX_STANDARD`` variable in the CMakeLists file. + +Which variable can we set in the CMakeLists file to treat the +``CMAKE_CXX_STANDARD`` value as a requirement? + +Build and Test +-------------- + +Run **cmake** or **cmake-gui** to configure the project and then build it +with your chosen build tool. + +cd 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. It will have the following one line CMakeLists file: + +.. literalinclude:: Step2/MathFunctions/CMakeLists.txt + :language: cmake + +The source file ``mysqrt.cxx`` has one function called ``mysqrt`` that +provides similar functionality to the compiler’s ``sqrt`` function. To make use +of the new library we add an ``add_subdirectory`` call in the top-level +CMakeLists 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 file 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 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 +file. + +.. literalinclude:: Step3/CMakeLists.txt + :language: cmake + :start-after: # should we use our own math functions + :end-before: # set the version number + +This will show up 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 this +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 file to +look like the following: + +.. literalinclude:: Step3/CMakeLists.txt + :language: cmake + :start-after: # add the MathFunctions library? + +Note the use of the variables ``EXTRA_LIBS`` and ``EXTRA_INCLUDES`` to collect +up any optional libraries to later be linked into the executable. 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, +include the MathFunctions header if we need it: + +.. literalinclude:: Step3/tutorial.cxx + :language: c++ + :start-after: // should we include the MathFunctions header + :end-before: int main + +Then make which square root function is used dependent on ``USE_MYMATH``: + +.. 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 + +Run **cmake** or **cmake-gui** to configure the project and then build it +with your chosen build tool. Then run the built Tutorial executable. + +Which function gives better results, Step1’s sqrt or Step2’s 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`` + +First up is MathFunctions. 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. Update ``MathFunctions/CMakeLists.txt`` with: + +.. 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. + +Once this is done, run **cmake** or **cmake-gui** to configure the project +and then build it with your chosen build tool. + +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 ``MathFunctions/CMakeLists.txt`` we add: + +.. literalinclude:: Step5/MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # install rules + +And the to 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. Build the ``install`` target by typing +``make install`` from the command line or build the ``INSTALL`` target from +an IDE. This will install the appropriate header files, libraries, and +executables. + +Verify that the installed Tutorial runs. Note: The CMake variable +``CMAKE_INSTALL_PREFIX`` is used to determine the root of where the files will +be installed. + +Testing Support +--------------- + +Next let's test our application. At the end of the top-level CMakeLists file we +can 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 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``. + +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.cmake`` macro in the top-level +CMakeLists file as follows: + +.. literalinclude:: Step6/CMakeLists.txt + :language: cmake + :start-after: # does this system provide the log and exp functions? + :end-before: # should we use our own math functions + +Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them +from ``mysqrt.cxx``: + +.. literalinclude:: Step6/TutorialConfig.h.in + :language: c + :start-after: // does the platform provide exp and log functions? + +Finally, 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: + +.. literalinclude:: Step6/MathFunctions/mysqrt.cxx + :language: c++ + :start-after: // if we have both log and exp then use them + :end-before: #else + +Run **cmake** or **cmake-gui** to configure the project and then build it +with your chosen build tool. + +You will notice that even though ``HAVE_LOG`` and ``HAVE_EXP`` are both +defined ``mysqrt`` isn't using them. We should realize quickly that we have +forgotten to include ``TutorialConfig.h`` in ``mysqrt.cxx``. + +After making this update, go ahead and build the project again. + +Run the built Tutorial executable. Which function gives better results now, +Step1’s sqrt or Step5’s mysqrt? + +**Exercise**: Why is it important that we configure ``TutorialConfig.h.in`` +after the checks for ``HAVE_LOG`` and ``HAVE_EXP``? What would happen if we +inverted the two? + +**Exercise**: Is there a better place for us to save the ``HAVE_LOG`` and +``HAVE_EXP`` values other than in ``TutorialConfig.h``? + +Adding a Custom Command and Generated File (Step 6) +=================================================== + +In this section, we will add a generated source file into the build process +of an application. For this example, we will create a table of precomputed +square roots as part of the build process, and then compile that +table into our application. + +To accomplish this, we first need a program that will generate the table. In +the MathFunctions subdirectory a new source file named ``MakeTable.cxx`` will +do just that. + +.. literalinclude:: Step7/MathFunctions/MakeTable.cxx + :language: c++ + +Note 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 MathFunctions' CMakeLists +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, 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. + +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 makes use of the +variables we set earlier in this tutorial. Finally we include the CPack +module which will use these variables and some other properties of the system +you are on 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 you would run: + +.. code-block:: console + + cpack + +To create a source distribution you would type: + +.. code-block:: console + + cpack -C CPackSourceConfig.cmake + +Alternatively, run ``make package`` or right click the ``Package`` target and +``Build Project`` from an IDE. + +Run the installer executable 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 the earlier steps of this +tutorial. 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 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: + +.. code-block:: console + + 'ctest [-VV] –D Experimental' + +On Windows, 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/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 + :start-after: set(Tutorial_VERSION_MINOR + :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-40,46- + +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`` + +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 enabled code with a +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. + +**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. + +For example: + +.. code-block:: cmake + + if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(SqrtLibrary + PRIVATE "HAVE_LOG" "HAVE_EXP") + endif() + +Can be rewritten with generator expressions: + +.. code-block:: cmake + + target_compile_definitions(SqrtLibrary PRIVATE + "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" + "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>" + ) + +Note that ``${HAVE_LOG}`` is evaluated at CMake configure time while +``$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>`` is evaluated at build system generation +time. + +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 see 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: + +.. 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: + +.. 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 examples 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 is 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 ahead and construct a directory called ``multi_config`` this +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: + +─ 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 now use +the custom MultiCPackConfig 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 a948939..cf1d2f1 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -44,6 +44,14 @@ Reference Manuals /manual/cmake-variables.7 /manual/cpack-generators.7 +Guides +###### + +.. toctree:: + :maxdepth: 1 + + /guide/tutorial/index + .. only:: html or text Release Notes diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index bac1c6c..d7207e1 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -51,13 +51,20 @@ 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.15 +Policies Introduced by CMake 3.16 ================================= .. toctree:: :maxdepth: 1 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> diff --git a/Help/prop_tgt/FRAMEWORK.rst b/Help/prop_tgt/FRAMEWORK.rst index 9dad060..3dff1be 100644 --- a/Help/prop_tgt/FRAMEWORK.rst +++ b/Help/prop_tgt/FRAMEWORK.rst @@ -6,7 +6,9 @@ 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 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. diff --git a/Help/release/dev/FindPython-FIND_ABI.rst b/Help/release/dev/FindPython-FIND_ABI.rst new file mode 100644 index 0000000..19e3f71 --- /dev/null +++ b/Help/release/dev/FindPython-FIND_ABI.rst @@ -0,0 +1,5 @@ +FindPython-FIND_ABI +------------------- + +* Modules :module:`FindPython3` and :module:`FindPython` gain the capability + to control which ``ABIs`` will be searched. diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index bcc7f67..5138f2a 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -224,6 +224,9 @@ Reference this list. #]=======================================================================] +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + set(_FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}") include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) @@ -395,7 +398,7 @@ function(matlab_extract_all_installed_versions_from_registry win64 matlab_versio ) - if(${resultMatlab} EQUAL 0) + if(resultMatlab EQUAL 0) string( REGEX MATCHALL "MATLAB\\\\([0-9]+(\\.[0-9]+)?)" @@ -612,9 +615,10 @@ function(matlab_get_mex_suffix matlab_root mex_suffix) OUTPUT_VARIABLE _matlab_mex_extension #RESULT_VARIABLE _matlab_mex_extension_call ERROR_VARIABLE _matlab_mex_extension_error + OUTPUT_STRIP_TRAILING_WHITESPACE ${devnull}) - if(NOT "${_matlab_mex_extension_error}" STREQUAL "") + if(_matlab_mex_extension_error) if(WIN32) # this is only for intel architecture if(CMAKE_SIZEOF_VOID_P EQUAL 8) @@ -700,7 +704,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.") @@ -955,14 +959,14 @@ 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 + if(NOT Matlab_VERSION_STRING VERSION_LESS "9.1") # For 9.1 (R2016b) and newer, add version source file # TODO: check the file extensions in ${${prefix}_SRC} to see if they're C or C++ files # Currently, the C and C++ versions of the version files are identical, so this doesn't matter. set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/c_mexapi_version.c") #set(MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/cpp_mexapi_version.cpp") endif() - if(NOT ${Matlab_VERSION_STRING} VERSION_LESS "9.4") # For 9.4 (R2018a) and newer, add API macro + 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() @@ -1023,7 +1027,7 @@ function(matlab_add_mex) 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 + 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() @@ -1042,13 +1046,13 @@ function(matlab_add_mex) else() - if(${Matlab_VERSION_STRING} VERSION_LESS "9.1") # For versions prior to 9.1 (R2016b) + 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?) + 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 @@ -1114,14 +1118,14 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve # 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() - if("${matlab_or_mcr}" STREQUAL "UNKNOWN") + if(matlab_or_mcr STREQUAL "UNKNOWN") if(MATLAB_FIND_DEBUG) message(WARNING "[MATLAB] Determining Matlab or MCR") endif() @@ -1136,10 +1140,10 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve # default fallback to Matlab set(matlab_or_mcr "MATLAB") - if(NOT "${CMAKE_MATCH_1}" STREQUAL "") + if(NOT CMAKE_MATCH_1 STREQUAL "") string(TOLOWER "${CMAKE_MATCH_1}" product_reg_match) - if("${product_reg_match}" STREQUAL "matlab runtime") + if(product_reg_match STREQUAL "matlab runtime") set(matlab_or_mcr "MCR") endif() endif() @@ -1153,7 +1157,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve # 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") + if(matlab_or_mcr STREQUAL "MATLAB" OR matlab_or_mcr STREQUAL "UNKNOWN") # MATLAB versions set(_matlab_current_program ${Matlab_MAIN_PROGRAM}) @@ -1205,7 +1209,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve 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) + 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") @@ -1215,7 +1219,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve 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) + 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() @@ -1235,10 +1239,8 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve ${versioninfo_string} ) - if(NOT "${version_reg_match}" STREQUAL "") - if("${CMAKE_MATCH_1}" MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*") - set(_matlab_version_tmp "${CMAKE_MATCH_1}") - endif() + 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) @@ -1444,14 +1446,28 @@ 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_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, provide the -DMatlab_ROOT_DIR=... on the command line") + 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") + + 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() @@ -1617,8 +1633,7 @@ list(APPEND _matlab_required_variables Matlab_MEX_EXTENSION) 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) +if("MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS) find_program( Matlab_MEX_COMPILER "mex" @@ -1630,11 +1645,9 @@ if(_matlab_find_mex_compiler GREATER -1) set(Matlab_MEX_COMPILER_FOUND TRUE) endif() 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) +if("MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS) find_program( Matlab_MAIN_PROGRAM matlab @@ -1646,7 +1659,6 @@ if(_matlab_find_matlab_program GREATER -1) set(Matlab_MAIN_PROGRAM_FOUND TRUE) endif() endif() -unset(_matlab_find_matlab_program) # The MX library is required _Matlab_find_library( @@ -1794,3 +1806,5 @@ if(Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES) Matlab_MEX_EXTENSION ) endif() + +cmake_policy(POP) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 76bc873..085e96c 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -521,6 +521,11 @@ 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(UNIX AND TARGET Threads::Threads) set_property(TARGET protobuf::libprotobuf APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads) diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index e2f3bf3..6a9decb 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -137,6 +137,51 @@ Hints * 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 diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 49d8e26..c0e843a 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -96,51 +96,149 @@ function (_PYTHON_GET_REGISTRIES _PYTHON_PGR_REGISTRY_PATHS _PYTHON_VERSION) PARENT_SCOPE) endfunction() -function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES _PYTHON_VERSION _PYTHON_TYPE) - set (path_suffixes) - if (_PYTHON_TYPE STREQUAL "LIBRARY") +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) - list (APPEND path_suffixes lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}mu-${CMAKE_LIBRARY_ARCHITECTURE} - lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}m-${CMAKE_LIBRARY_ARCHITECTURE} - lib/python${_PYTHON_VERSION}/config-${CMAKE_MATCH_1}u-${CMAKE_LIBRARY_ARCHITECTURE} - lib/python${_PYTHON_VERSION}/config-${CMAKE_MATCH_1}-${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 lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}mu - lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}m - lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION}u - lib/python${_PYTHON_VERSION}/config-${_PYTHON_VERSION} - lib/python${_PYTHON_VERSION}/config) - - elseif (_PYTHON_TYPE STREQUAL "INCLUDE") - list (APPEND path_suffixes include/python${_PYTHON_VERSION}mu - include/python${_PYTHON_VERSION}m - include/python${_PYTHON_VERSION}u - include/python${_PYTHON_VERSION} - include) + list (APPEND path_suffixes ${suffixes} include) endif() set (${_PYTHON_PGPS_PATH_SUFFIXES} ${path_suffixes} PARENT_SCOPE) endfunction() -function (_PYTHON_GET_LIB_NAMES _PYTHON_PGLN_NAMES _PYTHON_VERSION) - string (REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${_PYTHON_VERSION}) +function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) + cmake_parse_arguments (PARSE_ARGV 1 _PGN "POSIX;EXECUTABLE;CONFIG;LIBRARY;WIN32;DEBUG" "VERSION" "") - if (ARGC EQUAL 3 AND ARGV2 STREQUAL "DEBUG") - set (${_PYTHON_PGLN_NAMES} python${_PYTHON_VERSION_NO_DOTS}_d PARENT_SCOPE) - else() - set (${_PYTHON_PGLN_NAMES} python${_PYTHON_VERSION_NO_DOTS} - python${_PYTHON_VERSION}mu - python${_PYTHON_VERSION}m - python${_PYTHON_VERSION}u - python${_PYTHON_VERSION} - PARENT_SCOPE) + 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() @@ -149,16 +247,35 @@ function (_PYTHON_VALIDATE_INTERPRETER) return() endif() - cmake_parse_arguments (_PVI "EXACT" "" "" ${ARGN}) + cmake_parse_arguments (PARSE_ARGV 0 _PVI "EXACT" "" "") if (_PVI_UNPARSED_ARGUMENTS) set (expected_version ${_PVI_UNPARSED_ARGUMENTS}) else() unset (expected_version) 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}${CMAKE_EXECUTABLE_SUFFIX}") + 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]]))" @@ -168,7 +285,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) 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 (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE) + set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() else() @@ -183,7 +300,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result OR NOT version EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) # interpreter not usable or has wrong major version - set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE) + set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() endif() @@ -200,7 +317,7 @@ function (_PYTHON_VALIDATE_INTERPRETER) OUTPUT_STRIP_TRAILING_WHITESPACE) if (result OR NOT size EQUAL CMAKE_SIZEOF_VOID_P) # interpreter not usable or has wrong architecture - set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE) + set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") return() endif() endif() @@ -244,7 +361,7 @@ function (_PYTHON_VALIDATE_COMPILER expected_version) 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 (${_PYTHON_PREFIX}_COMPILER ${_PYTHON_PREFIX}_COMPILER-NOTFOUND CACHE INTERNAL "" FORCE) + set_property (CACHE ${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") endif() endfunction() @@ -321,6 +438,28 @@ if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER 1) 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") @@ -446,7 +585,8 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) # build all executable names - list (APPEND _${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_VERSION}) + _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}) @@ -516,12 +656,24 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() endif() - # try using HINTS and standard paths + # 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) @@ -561,9 +713,9 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) else() # look-up for various versions and locations foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - set (_${_PYTHON_PREFIX}_NAMES python${_${_PYTHON_PREFIX}_VERSION} - python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} - python) + _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}) @@ -643,12 +795,12 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) # systematically 'python' (i.e. version 2) even if version 3 is searched. if (WIN32) find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${_${_PYTHON_PREFIX}_VERSION} + NAMES ${_${_PYTHON_PREFIX}_NAMES} python ${_${_PYTHON_PREFIX}_IRON_PYTHON_NAMES}) else() find_program (${_PYTHON_PREFIX}_EXECUTABLE - NAMES python${_${_PYTHON_PREFIX}_VERSION}) + NAMES ${_${_PYTHON_PREFIX}_NAMES}) endif() _python_validate_interpreter (${_${_PYTHON_PREFIX}_VERSION} EXACT) if (${_PYTHON_PREFIX}_EXECUTABLE) @@ -715,7 +867,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) list (GET _${_PYTHON_PREFIX}_VERSIONS 2 ${_PYTHON_PREFIX}_VERSION_PATCH) else() # Interpreter is not usable - set (${_PYTHON_PREFIX}_EXECUTABLE ${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND CACHE INTERNAL "" FORCE) + set_property (CACHE ${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND") unset (${_PYTHON_PREFIX}_VERSION) endif() endif() @@ -723,8 +875,17 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) if (${_PYTHON_PREFIX}_EXECUTABLE AND ${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR) set (${_PYTHON_PREFIX}_Interpreter_FOUND TRUE) - # Use interpreter version for future searches to ensure consistency + # 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) @@ -932,7 +1093,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS) endif() else() # compiler not usable - set (${_PYTHON_PREFIX}_COMPILER ${_PYTHON_PREFIX}_COMPILER-NOTFOUND CACHE INTERNAL "" FORCE) + set_property (CACHE ${_PYTHON_PREFIX}_COMPILER PROPERTY VALUE "${_PYTHON_PREFIX}_COMPILER-NOTFOUND") endif() file (REMOVE_RECURSE "${_${_PYTHON_PREFIX}_VERSION_DIR}") endif() @@ -1015,16 +1176,15 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() endif() - set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_EXEC_PREFIX}" "${_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX}" "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + set (_${_PYTHON_PREFIX}_BASE_HINTS "${_${_PYTHON_PREFIX}_EXEC_PREFIX}" "${_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX}" "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + set (_${_PYTHON_PREFIX}_HINTS ${_${_PYTHON_PREFIX}_BASE_HINTS}) if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") set (_${_PYTHON_PREFIX}_CONFIG_NAMES) foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - if (DEFINED CMAKE_LIBRARY_ARCHITECTURE) - list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "${CMAKE_LIBRARY_ARCHITECTURE}-python${_${_PYTHON_PREFIX}_VERSION}-config") - endif() - list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "python${_${_PYTHON_PREFIX}_VERSION}-config") + _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) + list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) endforeach() find_program (_${_PYTHON_PREFIX}_CONFIG @@ -1033,6 +1193,22 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS HINTS ${_${_PYTHON_PREFIX}_HINTS} PATH_SUFFIXES bin) + 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 @@ -1052,11 +1228,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS else() foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) # try to use pythonX.Y-config tool - set (_${_PYTHON_PREFIX}_CONFIG_NAMES) - if (DEFINED CMAKE_LIBRARY_ARCHITECTURE) - set (_${_PYTHON_PREFIX}_CONFIG_NAMES "${CMAKE_LIBRARY_ARCHITECTURE}-python${_${_PYTHON_PREFIX}_VERSION}-config") - endif() - list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES "python${_${_PYTHON_PREFIX}_VERSION}-config") + _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) find_program (_${_PYTHON_PREFIX}_CONFIG NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} NAMES_PER_DIR @@ -1067,6 +1239,22 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS 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 (DEFINED CMAKE_LIBRARY_ARCHITECTURE) # check that config tool match library architecture execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir @@ -1105,49 +1293,32 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() if (_${_PYTHON_PREFIX}_CONFIG) - set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") - - unset (_${_PYTHON_PREFIX}_LIB_DIRS) - unset (_${_PYTHON_PREFIX}_PATH_SUFFIXES) - unset (_${_PYTHON_PREFIX}_LIB_NAMES) - - # retrieve library - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags + # enforce current ABI + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_ABIFLAGS ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - # retrieve library directory - string (REGEX MATCHALL "-L[^ ]+" _${_PYTHON_PREFIX}_LIB_DIRS "${_${_PYTHON_PREFIX}_FLAGS}") - string (REPLACE "-L" "" _${_PYTHON_PREFIX}_LIB_DIRS "${_${_PYTHON_PREFIX}_LIB_DIRS}") - if (_${_PYTHON_PREFIX}_CONFIG MATCHES "python([0-9.]+)-config") - _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES ${CMAKE_MATCH_1} LIBRARY) - endif() - - # retrieve library name - string (REGEX MATCHALL "-lpython[^ ]+" _${_PYTHON_PREFIX}_LIB_NAMES "${_${_PYTHON_PREFIX}_FLAGS}") - string (REPLACE "-l" "" _${_PYTHON_PREFIX}_LIB_NAMES "${_${_PYTHON_PREFIX}_LIB_NAMES}") - list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_LIB_NAMES) + if (_${_PYTHON_PREFIX}_RESULT) + # assume ABI is not supported + set (_${_PYTHON_PREFIX}_ABIFLAGS "") endif() + set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") + + # retrieve library + ## compute some paths and artifact names + string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_CONFIG_VERSION "${_${_PYTHON_PREFIX}_CONFIG}") + _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_CONFIG_VERSION} LIBRARY) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_CONFIG_VERSION} POSIX LIBRARY) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) if (NOT _${_PYTHON_PREFIX}_RESULT) - list (APPEND _${_PYTHON_PREFIX}_LIB_DIRS "${_${_PYTHON_PREFIX}_CONFIGDIR}") - endif() - list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_LIB_DIRS) - list (APPEND _${_PYTHON_PREFIX}_HINTS ${_${_PYTHON_PREFIX}_LIB_DIRS}) - - if (NOT _${_PYTHON_PREFIX}_LIB_NAMES) - # config tool do not specify "-l" option (it is the case starting with 3.8) - # extract version from the config tool name and list all possible lib names - if (_${_PYTHON_PREFIX}_CONFIG MATCHES "python([0-9.]+)-config") - _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES ${CMAKE_MATCH_1}) - endif() + list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}") endif() list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) @@ -1195,7 +1366,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # Rely on HINTS and standard paths if config tool failed to locate artifacts if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) - set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + set (_${_PYTHON_PREFIX}_HINTS ${_${_PYTHON_PREFIX}_BASE_HINTS}) if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") unset (_${_PYTHON_PREFIX}_LIB_NAMES) @@ -1206,9 +1377,9 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) # library names - _python_get_lib_names (_${_PYTHON_PREFIX}_VERSION_NAMES ${_${_PYTHON_PREFIX}_LIB_VERSION}) + _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_lib_names (_${_PYTHON_PREFIX}_VERSION_NAMES ${_${_PYTHON_PREFIX}_LIB_VERSION} DEBUG) + _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 @@ -1220,7 +1391,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS list (APPEND _${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) # Paths suffixes - _python_get_path_suffixes (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) + _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() @@ -1290,7 +1461,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # search for debug library if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) # use library location as a hint - _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION} DEBUG) + _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} @@ -1327,13 +1498,13 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() else() foreach (_${_PYTHON_PREFIX}_LIB_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_LIB_VERSION}) - _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_LIB_VERSION} DEBUG) + _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 ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) + _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 @@ -1429,7 +1600,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # retrieve runtime libraries if (${_PYTHON_PREFIX}_LIBRARY_RELEASE) - _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES ${_${_PYTHON_PREFIX}_VERSION}) + _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 @@ -1439,7 +1610,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS PATH_SUFFIXES bin) endif() if (${_PYTHON_PREFIX}_LIBRARY_DEBUG) - _python_get_lib_names (_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG ${_${_PYTHON_PREFIX}_VERSION} 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 @@ -1488,7 +1659,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS _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 ${_${_PYTHON_PREFIX}_VERSION} INCLUDE) + _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 diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 2ead5b6..c8d9f24 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -138,6 +138,47 @@ Hints * 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 diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 78f236f..a054b11 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 15) -set(CMake_VERSION_PATCH 20190624) +set(CMake_VERSION_PATCH 20190626) #set(CMake_VERSION_RC 1) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 186deb6..a7618c7 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -202,7 +202,6 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target, cmComputeLinkDepends::~cmComputeLinkDepends() { cmDeleteAll(this->InferredDependSets); - delete this->CCG; } void cmComputeLinkDepends::SetOldLinkDirMode(bool b) @@ -632,7 +631,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 diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index dfaaf8b..0b1f00c 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -137,7 +137,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/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 5b611c0..a849aa2 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -4,6 +4,8 @@ #include "cm_static_string_view.hxx" #include "cmsys/RegularExpression.hxx" + +#include <algorithm> #include <map> #include <sstream> #include <utility> @@ -66,7 +68,9 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args, } std::vector<std::string> unknownArgs; - Arguments const arguments = parser.Parse(args, &unknownArgs); + std::vector<std::string> keywordsMissingValue; + Arguments const arguments = + parser.Parse(args, &unknownArgs, &keywordsMissingValue); if (!unknownArgs.empty()) { this->SetError("Unknown argument: \"" + unknownArgs.front() + "\"."); @@ -128,7 +132,10 @@ bool cmExportCommand::InitialPass(std::vector<std::string> const& args, return false; } ExportSet = it->second; - } else if (!arguments.Targets.empty()) { + } else if (!arguments.Targets.empty() || + std::find(keywordsMissingValue.begin(), + keywordsMissingValue.end(), + "TARGETS") != keywordsMissingValue.end()) { for (std::string const& currentTarget : arguments.Targets) { if (this->Makefile->IsAlias(currentTarget)) { std::ostringstream e; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index df0f33f..b250dd7 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -92,7 +92,6 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) // how long to let try compiles run this->TryCompileTimeout = cmDuration::zero(); - this->ExtraGenerator = nullptr; this->CurrentConfigureMakefile = nullptr; this->TryCompileOuterMakefile = nullptr; @@ -113,7 +112,6 @@ cmGlobalGenerator::cmGlobalGenerator(cmake* cm) cmGlobalGenerator::~cmGlobalGenerator() { this->ClearGeneratorMembers(); - delete this->ExtraGenerator; } #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -1499,7 +1497,7 @@ void cmGlobalGenerator::Generate() this->WriteSummary(); - if (this->ExtraGenerator != nullptr) { + if (this->ExtraGenerator) { this->ExtraGenerator->Generate(); } @@ -2720,8 +2718,8 @@ bool cmGlobalGenerator::IsReservedTarget(std::string const& name) void cmGlobalGenerator::SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator* extraGenerator) { - this->ExtraGenerator = extraGenerator; - if (this->ExtraGenerator != nullptr) { + this->ExtraGenerator.reset(extraGenerator); + if (this->ExtraGenerator) { this->ExtraGenerator->SetGlobalGenerator(this); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index db96489..7fd5433 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -618,7 +618,7 @@ private: void ComputeBuildFileGenerators(); - cmExternalMakefileProjectGenerator* ExtraGenerator; + std::unique_ptr<cmExternalMakefileProjectGenerator> ExtraGenerator; // track files replaced during a Generate std::vector<std::string> FilesReplacedDuringGenerate; diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx index d4af1e0..ac6dce9 100644 --- a/Source/cmMachO.cxx +++ b/Source/cmMachO.cxx @@ -2,9 +2,9 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmMachO.h" +#include "cmAlgorithms.h" #include "cmsys/FStream.hxx" -#include <algorithm> -#include <stddef.h> +#include <cstddef> #include <string> #include <vector> @@ -120,7 +120,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: @@ -306,15 +306,11 @@ bool cmMachOInternal::read_mach_o(uint32_t file_offset) // External class implementation. cmMachO::cmMachO(const char* fname) - : Internal(nullptr) + : 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 5482465..0c44b55 100644 --- a/Source/cmMachO.h +++ b/Source/cmMachO.h @@ -41,7 +41,7 @@ public: private: friend class cmMachOInternal; bool Valid() const; - cmMachOInternal* Internal; + std::unique_ptr<cmMachOInternal> Internal; }; #endif diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 7ad8ab3..f65abc8 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -171,20 +171,9 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile) vars.Language = "CUDA"; - std::string responseFlag; - - 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 if (this->TargetLinkLanguage != "CUDA") { - responseFlag = "@"; - } + std::string responseFlag = this->GetMakefile()->GetSafeDefinition( + "CMAKE_CUDA_RESPONSE_FILE_LINK_FLAG"); if (!useResponseFile || responseFlag.empty()) { vars.Objects = "$in"; diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index b4c6c32..a1d1f95 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -342,10 +342,7 @@ void cmRuntimeDependencyArchive::AddResolvedPath(const std::string& name, const std::string& path, bool& unique) { - auto it = - this->ResolvedPaths - .insert(std::pair<std::string, std::set<std::string>>{ name, {} }) - .first; + auto it = this->ResolvedPaths.emplace(name, std::set<std::string>{}).first; unique = true; for (auto const& other : it->second) { if (cmSystemTools::SameFile(path, other)) { diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 091c2e0..587cda5 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -23,14 +23,12 @@ cmState::cmState() { - this->CacheManager = new cmCacheManager; - this->GlobVerificationManager = new cmGlobVerificationManager; + this->CacheManager = cm::make_unique<cmCacheManager>(); + this->GlobVerificationManager = cm::make_unique<cmGlobVerificationManager>(); } cmState::~cmState() { - delete this->CacheManager; - delete this->GlobVerificationManager; cmDeleteAll(this->BuiltinCommands); cmDeleteAll(this->ScriptedCommands); } diff --git a/Source/cmState.h b/Source/cmState.h index 6abe71c..accd838 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -211,8 +211,8 @@ private: std::map<std::string, cmCommand*> BuiltinCommands; std::map<std::string, cmCommand*> ScriptedCommands; cmPropertyMap GlobalProperties; - cmCacheManager* CacheManager; - cmGlobVerificationManager* GlobVerificationManager; + std::unique_ptr<cmCacheManager> CacheManager; + std::unique_ptr<cmGlobVerificationManager> GlobVerificationManager; cmLinkedTree<cmStateDetail::BuildsystemDirectoryStateType> BuildsystemDirectory; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 3772f09..8f2f86d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -141,12 +141,12 @@ cmake::cmake(Role role, cmState::Mode mode) this->DebugOutput = false; this->DebugTryCompile = false; this->ClearBuildSystem = false; - this->FileTimeCache = new cmFileTimeCache; + this->FileTimeCache = cm::make_unique<cmFileTimeCache>(); - this->State = new cmState; + this->State = cm::make_unique<cmState>(); this->State->SetMode(mode); this->CurrentSnapshot = this->State->CreateBaseSnapshot(); - this->Messenger = new cmMessenger; + this->Messenger = cm::make_unique<cmMessenger>(); #ifdef __APPLE__ struct rlimit rlp; @@ -165,7 +165,7 @@ cmake::cmake(Role role, cmState::Mode mode) this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE - this->VariableWatch = new cmVariableWatch; + this->VariableWatch = cm::make_unique<cmVariableWatch>(); #endif this->AddDefaultGenerators(); @@ -222,17 +222,11 @@ cmake::cmake(Role role, cmState::Mode mode) cmake::~cmake() { - delete this->State; - delete this->Messenger; if (this->GlobalGenerator) { delete this->GlobalGenerator; this->GlobalGenerator = nullptr; } cmDeleteAll(this->Generators); -#ifdef CMAKE_BUILD_WITH_CMAKE - delete this->VariableWatch; -#endif - delete this->FileTimeCache; } #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -460,7 +454,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) return false; } // Register fake project commands that hint misuse in script mode. - GetProjectCommandsInScriptMode(this->State); + GetProjectCommandsInScriptMode(this->GetState()); this->ReadListFile(args, path); } else if (arg.find("--find-package", 0) == 0) { findPackageMode = true; @@ -1898,12 +1892,12 @@ const char* cmake::GetCacheDefinition(const std::string& name) const void cmake::AddScriptingCommands() { - GetScriptingCommands(this->State); + GetScriptingCommands(this->GetState()); } void cmake::AddProjectCommands() { - GetProjectCommands(this->State); + GetProjectCommands(this->GetState()); } void cmake::AddDefaultGenerators() @@ -2607,11 +2601,6 @@ std::vector<std::string> cmake::GetDebugConfigs() return configs; } -cmMessenger* cmake::GetMessenger() const -{ - return this->Messenger; -} - int cmake::Build(int jobs, const std::string& dir, const std::vector<std::string>& targets, const std::string& config, diff --git a/Source/cmake.h b/Source/cmake.h index fa4409a..e14a081 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -307,7 +307,7 @@ public: #if defined(CMAKE_BUILD_WITH_CMAKE) //! Get the variable watch object - cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } + cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); } #endif std::vector<cmDocumentationEntry> GetGeneratorsDocumentation(); @@ -348,18 +348,18 @@ public: /** * Get the file comparison class */ - cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache; } + cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache.get(); } - // Get the selected log level for `message()` commands during the cmake run. + //! 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; } @@ -396,31 +396,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. @@ -431,7 +431,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. @@ -459,7 +459,7 @@ public: 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; @@ -537,18 +537,18 @@ private: std::unordered_set<std::string> HeaderFileExtensionsSet; bool ClearBuildSystem; bool DebugTryCompile; - cmFileTimeCache* FileTimeCache; + std::unique_ptr<cmFileTimeCache> FileTimeCache; std::string GraphVizFile; InstalledFilesMap InstalledFiles; #if defined(CMAKE_BUILD_WITH_CMAKE) - cmVariableWatch* VariableWatch; + std::unique_ptr<cmVariableWatch> VariableWatch; std::unique_ptr<cmFileAPI> FileAPI; #endif - cmState* State; + std::unique_ptr<cmState> State; cmStateSnapshot CurrentSnapshot; - cmMessenger* Messenger; + std::unique_ptr<cmMessenger> Messenger; std::vector<std::string> TraceOnlyThisSources; @@ -556,7 +556,7 @@ private: 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(); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 920af04..a81ea5b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1398,184 +1398,66 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH endif() endif() - if(CMake_TEST_FindALSA) - add_subdirectory(FindALSA) - 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 + GSL + GTK2 + Iconv + ICU + JPEG + JsonCpp + LibLZMA + LibRHash + Libinput + LibUV + LibXml2 + LTTngUST + ODBC + 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_FindCURL) - add_subdirectory(FindCURL) - endif() - - if(CMake_TEST_FindCups) - add_subdirectory(FindCups) - endif() - - if(CMake_TEST_FindDoxygen) - add_subdirectory(FindDoxygen) - endif() - - if(CMake_TEST_FindEnvModules) - add_subdirectory(FindEnvModules) - endif() - - if(CMake_TEST_FindEXPAT) - add_subdirectory(FindEXPAT) - endif() - - if(CMake_TEST_FindFontconfig) - add_subdirectory(FindFontconfig) - endif() - - if(CMake_TEST_FindFreetype) - add_subdirectory(FindFreetype) - endif() - - if(CMake_TEST_FindGDAL) - add_subdirectory(FindGDAL) - endif() - - if(CMake_TEST_FindGIF) - add_subdirectory(FindGIF) - endif() - - if(CMake_TEST_FindGit) - add_subdirectory(FindGit) - endif() - - if(CMake_TEST_FindGLEW) - add_subdirectory(FindGLEW) - endif() - - if(CMake_TEST_FindGSL) - add_subdirectory(FindGSL) - endif() - if(CMake_TEST_FindGTest) add_subdirectory(FindGTest) add_subdirectory(GoogleTest) endif() - if(CMake_TEST_FindGTK2) - add_subdirectory(FindGTK2) - endif() - - if(CMake_TEST_FindIconv) - add_subdirectory(FindIconv) - endif() - - if(CMake_TEST_FindICU) - add_subdirectory(FindICU) - endif() - - if(CMake_TEST_FindJPEG) - add_subdirectory(FindJPEG) - endif() - - if(CMake_TEST_FindJsonCpp) - add_subdirectory(FindJsonCpp) - endif() - - if(CMake_TEST_FindLibLZMA) - add_subdirectory(FindLibLZMA) - endif() - - if(CMake_TEST_FindLibRHash) - add_subdirectory(FindLibRHash) - endif() - - if(CMake_TEST_FindLibinput) - add_subdirectory(FindLibinput) - endif() - - if(CMake_TEST_FindLibUV) - add_subdirectory(FindLibUV) - endif() - - if(CMake_TEST_FindLibXml2) - add_subdirectory(FindLibXml2) - endif() - - if(CMake_TEST_FindLTTngUST) - add_subdirectory(FindLTTngUST) - endif() - - if(CMake_TEST_FindODBC) - add_subdirectory(FindODBC) - 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) - endif() - - if(CMake_TEST_FindPNG) - add_subdirectory(FindPNG) - endif() - - if(CMake_TEST_FindPatch) - add_subdirectory(FindPatch) - endif() - - if(CMake_TEST_FindPostgreSQL) - add_subdirectory(FindPostgreSQL) - endif() - - if(CMake_TEST_FindProtobuf) - add_subdirectory(FindProtobuf) - endif() - - if(CMake_TEST_FindSQLite3) - add_subdirectory(FindSQLite3) - endif() - - if(CMake_TEST_FindTIFF) - add_subdirectory(FindTIFF) - endif() - - if(CMake_TEST_FindVulkan) - add_subdirectory(FindVulkan) - endif() - - if(CMake_TEST_FindX11) - add_subdirectory(FindX11) - endif() - - if(CMake_TEST_FindXalanC) - add_subdirectory(FindXalanC) - endif() - - if(CMake_TEST_FindXercesC) - add_subdirectory(FindXercesC) - endif() - if(CMake_TEST_FindPython OR CMake_TEST_FindPython_NumPy) add_subdirectory(FindPython) endif() @@ -1591,16 +1473,16 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH # 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 (NOT "${CMake_TEST_FindMatlab_ROOT_DIR}" STREQUAL "") OR - CMake_TEST_FindMatlab_MCR OR (NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "")) + 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 NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "") + if(CMake_TEST_FindMatlab_MCR OR CMake_TEST_FindMatlab_MCR_ROOT_DIR) set(FindMatlab_additional_test_options -DIS_MCR=TRUE) endif() - if(NOT "${CMake_TEST_FindMatlab_ROOT_DIR}" STREQUAL "") + 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(NOT "${CMake_TEST_FindMatlab_MCR_ROOT_DIR}" STREQUAL "") + 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}) @@ -1729,7 +1611,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH endif() add_test(${tutorial_test_name} ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/Tutorial/${step_name}" + "${CMake_SOURCE_DIR}/Help/guide/tutorial/${step_name}" ${tutorial_build_dir}_Build ${build_generator_args} --build-project Tutorial @@ -2290,7 +2172,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH foreach(STP RANGE 1 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 diff --git a/Tests/FindIconv/Test/CMakeLists.txt b/Tests/FindIconv/Test/CMakeLists.txt index c59adb3..a6243f5 100644 --- a/Tests/FindIconv/Test/CMakeLists.txt +++ b/Tests/FindIconv/Test/CMakeLists.txt @@ -6,9 +6,11 @@ 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/FindPython/FindPythonScript.cmake b/Tests/FindPython/FindPythonScript.cmake index 9450092..bc7e0d1 100644 --- a/Tests/FindPython/FindPythonScript.cmake +++ b/Tests/FindPython/FindPythonScript.cmake @@ -1 +1,9 @@ -find_package(${PYTHON_PACKAGE_NAME} REQUIRED QUIET) + +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/Python2/CMakeLists.txt b/Tests/FindPython/Python2/CMakeLists.txt index 274745a..cf77ca2 100644 --- a/Tests/FindPython/Python2/CMakeLists.txt +++ b/Tests/FindPython/Python2/CMakeLists.txt @@ -34,4 +34,5 @@ add_test (NAME python2_spam2 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/Python3/CMakeLists.txt b/Tests/FindPython/Python3/CMakeLists.txt index b21a15b..6691a48 100644 --- a/Tests/FindPython/Python3/CMakeLists.txt +++ b/Tests/FindPython/Python3/CMakeLists.txt @@ -34,4 +34,57 @@ add_test (NAME python3_spam3 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/RunCMake/export/Empty.cmake b/Tests/RunCMake/export/Empty.cmake new file mode 100644 index 0000000..2198ddf --- /dev/null +++ b/Tests/RunCMake/export/Empty.cmake @@ -0,0 +1 @@ +export(TARGETS FILE targets.cmake) diff --git a/Tests/RunCMake/export/RunCMakeTest.cmake b/Tests/RunCMake/export/RunCMakeTest.cmake index 46bb1fc..97a0ca6 100644 --- a/Tests/RunCMake/export/RunCMakeTest.cmake +++ b/Tests/RunCMake/export/RunCMakeTest.cmake @@ -1,6 +1,7 @@ include(RunCMake) run_cmake(CustomTarget) +run_cmake(Empty) run_cmake(TargetNotFound) run_cmake(AppendExport) run_cmake(OldIface) diff --git a/Tests/Tutorial/Consumer/directions.txt b/Tests/Tutorial/Consumer/directions.txt deleted file mode 100644 index 6a70aab..0000000 --- a/Tests/Tutorial/Consumer/directions.txt +++ /dev/null @@ -1,6 +0,0 @@ -# Import a CMake Project# - -This examples shows how a project can find other CMake packages that -generated Config.cmake files. - -It also shows how to state a projects external dependencies when generating a Config.cmake. diff --git a/Tests/Tutorial/MultiPackage/directions.txt b/Tests/Tutorial/MultiPackage/directions.txt deleted file mode 100644 index c3102bb..0000000 --- a/Tests/Tutorial/MultiPackage/directions.txt +++ /dev/null @@ -1,34 +0,0 @@ -# Packaging Debug and Release # - -By default CMake is 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 ahead and construct a directory called 'multi_config' this -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: - -─ multi_config - ├── debug - └── release - -Now we need to setup debug and release builds, which would roughly entail -the following: - - 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 now use -the custom MultiCPackConfig to package both builds into a single release. - - cpack --config ../../MultiPackage/MultiCPackConfig.cmake diff --git a/Tests/Tutorial/Readme.txt b/Tests/Tutorial/Readme.txt deleted file mode 100644 index 74eb01a..0000000 --- a/Tests/Tutorial/Readme.txt +++ /dev/null @@ -1,16 +0,0 @@ - -Step 0: A Starting Point -Step 1: Configure a File and C++11 Controls -Step 2: Adding a Library -Step 3: Usage Requirements for Library -Step 4: Installing and Testing -Step 5: System Introspection -Step 6: Custom Command and Generated File -Step 7: Building an Installer -Step 8: CDash submission -Step 9: Mixing Static and Shared -Step 10: Generator Expressions -Step 11: Adding Export Configuration -Complete: End result of Step 11 -Consumer: Example of Import Packages -MultiPackage: How to package Debug and Release versions diff --git a/Tests/Tutorial/Step1/directions.txt b/Tests/Tutorial/Step1/directions.txt deleted file mode 100644 index 827d775..0000000 --- a/Tests/Tutorial/Step1/directions.txt +++ /dev/null @@ -1,95 +0,0 @@ -# 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 provides more flexibility. - -To add a version number we modify the CMakeLists file as follows: - - cmake_minimum_required(VERSION 3.3) - 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 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}" - ) - - -We then create a TutorialConfig.h.in file in the source tree with the -following contents: - - // the configured options and settings for Tutorial - #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ - #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ - -When CMake configures this header file the values for @Tutorial_VERSION_MAJOR@ -and @Tutorial_VERSION_MINOR@ will be replaced by the values from the CMakeLists -file. Next we modify tutorial.cxx to include the configured header file and to -make use of the version numbers. The resulting source code is listed below. - - // A simple program that computes the square root of a number - #include <cmath> - #include <iostream> - #include <string> - #include <sstream> - - #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; - } - - double inputValue = atof(argv[1]); - - double outputValue = sqrt(inputValue); - std::cout << "The square root of " - << inputValue << " is " << outputValue << std::endl; - return 0; - } - -# Adding C++11 support # - -Let's add some C++11 features to our project. We will need to explicitly state -in the CMake code that it should use the correct flags. The easiest way to -enable C++11 support for CMake is by using the CMAKE_CXX_STANDARD -and CMAKE_CXX_STANDARD_REQUIRED variables. - -First, replace `atof` with `std::stod` in tutorial.cxx. - -Then, add the CMAKE_CXX_STANDARD and CMAKE_CXX_STANDARD_REQUIRED variables to -the CMakeLists file. The STANADARD value should be set to 11, and REQUIRED -should be set to True. - - -# Build and Test # - -Run cmake or cmake-gui to configure the project and then build it with your -chosen build tool - -cd to the directory where Tutorial was built (likely the make directory or -a Debug or Release build configuration subdirectory) and run these commands: - - Tutorial 4294967296 - Tutorial 10 - Tutorial diff --git a/Tests/Tutorial/Step10/directions.txt b/Tests/Tutorial/Step10/directions.txt deleted file mode 100644 index 5317b54..0000000 --- a/Tests/Tutorial/Step10/directions.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Adding Generator Expressions # - -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 to used to 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. - -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. -For example: - - if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(SqrtLibrary - PRIVATE "HAVE_LOG" "HAVE_EXP") - endif() - -Can be rewritten with generator expressions: - - target_compile_definitions(SqrtLibrary PRIVATE - "$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" - "$<$<BOOL:${HAVE_EXP}>:HAVE_EXP>" - ) - -Note that "${HAVE_LOG}" is evaluated at CMake configure time while -"$<$<BOOL:${HAVE_LOG}>:HAVE_LOG>" is evaluated at build system generation time. diff --git a/Tests/Tutorial/Step11/directions.txt b/Tests/Tutorial/Step11/directions.txt deleted file mode 100644 index ebb5def..0000000 --- a/Tests/Tutorial/Step11/directions.txt +++ /dev/null @@ -1,104 +0,0 @@ -# Adding Export Configuration # - -During Step 4 of the tutorial we added the ability for CMake to install the -library and headers of the project. During 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: - - install(TARGETS MathFunctions DESTINATION lib EXPORT MathFunctionsTargets) - -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: - - # install the configuration targets - install(EXPORT MathFunctionsTargets - FILE MathFunctionsTargets.cmake - DESTINATION lib/cmake/MathFunctions - ) - -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: - - 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: - - target_include_directories(MathFunctions - INTERFACE - $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> - $<INSTALL_INTERFACE:include> - ) - -Once this has been updated, we can re-run CMake and see 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: - - @PACKAGE_INIT@ - - include ( "${CMAKE_CURRENT_LIST_DIR}/MathFunctionsTargets.cmake" ) - -Then, to properly configure and install that file, add the following to the -bottom of the top-level CMakeLists: - - 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 - ) - -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: - - # 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" - ) - -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. diff --git a/Tests/Tutorial/Step2/directions.txt b/Tests/Tutorial/Step2/directions.txt deleted file mode 100644 index 48de7a2..0000000 --- a/Tests/Tutorial/Step2/directions.txt +++ /dev/null @@ -1,101 +0,0 @@ -# Adding a Library # - -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. It will have the following one line CMakeLists file: - - add_library(MathFunctions mysqrt.cxx) - -The source file mysqrt.cxx has one function called mysqrt that provides similar -functionality to the compiler’s sqrt function. To make use of the new library -we add an add_subdirectory call in the top-level CMakeLists file so that the -library will get built. We add the new library to the executable, and add the -MathFunctions as an include directory so that mqsqrt.h header file can be -found. The last few lines of the top-level CMakeLists file now look like: - - - add_subdirectory(MathFunctions) - - #add the executable - add_executable(Tutorial tutorial.cxx) - - target_link_libraries(Tutorial ${EXTRA_LIBS}) - - -Now let us make the MathFunctions library optional. While for the tutorial -there really isn’t any need to do so, but with larger projects this is a common -occurrence. The first step is to add an option to the top-level CMakeLists file. - - option (USE_MYMATH - "Use tutorial provided math implementation" ON) - -This will show up in CMake GUI and ccmake with a default value of ON that can -be changed by the user. This setting will be stored so that the user does not -need to set the value each time they run CMake on this build directory. - -The next change is to make building and linking the MathFunctions library -conditional. To do this we change the top-level CMakeLists file to look like -the following: - - cmake_minimum_required(VERSION 3.3) - project(Tutorial) - - set(CMAKE_CXX_STANDARD 14) - - # 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" - ) - - # should we use our own math functions - option(USE_MYMATH "Use tutorial provided math implementation" ON) - - # add the MathFunctions library? - if(USE_MYMATH) - add_subdirectory(MathFunctions) - list(APPEND EXTRA_LIBS MathFunctions) - list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions") - endif(USE_MYMATH) - - # add the executable - add_executable(Tutorial tutorial.cxx) - - target_link_libraries(Tutorial ${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} - ) - -Note the use of the variables EXTRA_LIBS, and EXTRA_INCLUDES to collect -up any optional libraries to later be linked into the executable. This is a -classic approach when dealing with many optional components, we will cover the -modern approach in the next step. For now the corresponding changes to the -source code are fairly straightforward and leave us with: - - #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); - #else - double outputValue = sqrt(inputValue); - #endif - -Since the source code now requires USE_MYMATH we can add it to the -TutorialConfig.h.in. Simply add the following line: - #cmakedefine USE_MYMATH - -Run cmake or cmake-gui to configure the project and then build it with your -chosen build tool and then run the built Tutorial executable. - -Which function gives better results, Step1’s sqrt or Step2’s mysqrt? diff --git a/Tests/Tutorial/Step3/directions.txt b/Tests/Tutorial/Step3/directions.txt deleted file mode 100644 index 54d0318..0000000 --- a/Tests/Tutorial/Step3/directions.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Adding Usage Requirements for Library # - -Usage requirements allow for far better control over a library / 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 - -First up is MathFunctions. 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. - - target_include_directories(MathFunctions - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) - -Now that we've specified usage requirements for MathFunctions we can safely remove -our uses of the EXTRA_INCLUDES variable. - -Run cmake or cmake-gui to configure the project and then build it with your -chosen build tool. diff --git a/Tests/Tutorial/Step4/directions.txt b/Tests/Tutorial/Step4/directions.txt deleted file mode 100644 index 91e4043..0000000 --- a/Tests/Tutorial/Step4/directions.txt +++ /dev/null @@ -1,72 +0,0 @@ -# Installing and Testing # - -Now we can start adding testing support and install rules to our project. - -The install rules are fairly simple; for MathFunctions we install the library -and header file, for the application we install the executable and configured -header. - -So to MathFunctions/CMakeLists.txt we add: - - install (TARGETS MathFunctions DESTINATION bin) - install (FILES MathFunctions.h DESTINATION include) - -And the to top-level CMakeLists.txt we add: - - install(TARGETS Tutorial DESTINATION bin) - install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" - DESTINATION include - ) - -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. Then build the “install” target by typing 'make install' -from the command line or build the INSTALL target from an IDE. This will -install the appropriate header files, libraries, and executables. - -Verify that the installed Tutorial runs. Note: The CMake variable -CMAKE_INSTALL_PREFIX is used to determine the root of where the files will -be installed. - -Next let's test our application. Adding testing is an easy process. At the -end of the top-level CMakeLists file we can add a number of basic tests to -verify that the application is working correctly. - - # 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 25 "25 is 5") - do_test(Tutorial -25 "-25 is [-nan|nan|0]") - do_test(Tutorial 0.0001 "0.0001 is 0.01") - -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 Usage test uses a regular expression to verify that the usage message -is printed when an incorrect number of arguments are provided. - -Lastly, we have a function called do_test that simplifies running the -application and verifying that the computed square root is correct for given -input. - -To run tests, cd to the binary directory and run “ctest -N” and “ctest -VV”. diff --git a/Tests/Tutorial/Step5/directions.txt b/Tests/Tutorial/Step5/directions.txt deleted file mode 100644 index e6f5197..0000000 --- a/Tests/Tutorial/Step5/directions.txt +++ /dev/null @@ -1,69 +0,0 @@ -# Adding System Introspection # - -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.cmake macro in the top-level CMakeLists -file as follows: - - # 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) - -Now let's add these defines to TutorialConfig.h.in so that we can use them -from mysqrt.cxx: - - // does the platform provide exp and log functions? - #cmakedefine HAVE_LOG - #cmakedefine HAVE_EXP - -Modify mysqrt.cxx to include math.h. Next, 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: - - // 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" << std::endl; - #else - ... - -Run cmake or cmake-gui to configure the project and then build it with your -chosen build tool. - -You will notice that even though HAVE_LOG and HAVE_EXP are both defined mysqrt -isn't using them. We should realize quickly that we have forgotten to include -TutorialConfig.h in mysqrt.cxx. We will also need to update -MathFunctions/CMakeLists.txt with where it is located. - -So let's go ahead and update MathFunctions/CMakeLists.txt to look like: - - add_library(MathFunctions mysqrt.cxx) - - target_include_directories(MathFunctions - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${Tutorial_BINARY_DIR} - ) - - install(TARGETS MathFunctions DESTINATION lib) - install(FILES MathFunctions.h DESTINATION include) - -Now all we need to do is include TutorialConfig.h in mysqrt.cxx - -At this point you should go ahead and build the project again. - -Run the built Tutorial executable. Which function gives better results now, -Step1’s sqrt or Step5’s mysqrt? - -Exercise: Why is it important that we configure TutorialConfig.h.in after the -checks for HAVE_LOG and HAVE_EXP? What would happen if we inverted the two? - -Exercise: Is there a better place for us to save the HAVE_LOG and HAVE_EXP -values other than in TutorialConfig.h? diff --git a/Tests/Tutorial/Step6/directions.txt b/Tests/Tutorial/Step6/directions.txt deleted file mode 100644 index 42b9f06..0000000 --- a/Tests/Tutorial/Step6/directions.txt +++ /dev/null @@ -1,104 +0,0 @@ -# Adding a Custom Command and Generated File # - -In this section we will show how you can add a generated source file into the -build process of an application. For this example, we will create a table of -precomputed square roots as part of the build process, and then compile that -table into our application. - -To accomplish this, we first need a program that will generate the table. In the -MathFunctions subdirectory a new source file named MakeTable.cxx will do just that. - - // A simple program that builds a sqrt table - #include <iostream> - #include <fstream> - #include <cmath> - - 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 - } - -Note 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 MathFunctions’ CMakeLists -file to build the MakeTable executable and then run it as part of the build -process. A few commands are needed to accomplish this, as shown below: - - # 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 - ) - - target_include_directories(MathFunctions - INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC ${Tutorial_BINARY_DIR} - # add the binary tree directory to the search path for include files - ${CMAKE_CURRENT_BINARY_DIR} - ) - - install(TARGETS MathFunctions DESTINATION lib) - install(FILES MathFunctions.h DESTINATION include) - -First, the executable for MakeTable is added as any other executable would be -added. Then we add a custom command that specifies how to produce Table.h by -running MakeTable. 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. 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. - -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: - - 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)]; - } - - // 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; - } - -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. diff --git a/Tests/Tutorial/Step7/build1.cmake b/Tests/Tutorial/Step7/build1.cmake deleted file mode 100644 index baa475f..0000000 --- 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/directions.txt b/Tests/Tutorial/Step7/directions.txt deleted file mode 100644 index 7d7c2ea..0000000 --- a/Tests/Tutorial/Step7/directions.txt +++ /dev/null @@ -1,40 +0,0 @@ -# Building an Installer # - -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 -the Installing and Testing section (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. - - 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) - -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 makes use of the variables we set earlier in this tutorial. Finally -we include the CPack module which will use these variables and some other -properties of the system you are on 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 you would run: - - cpack - -To create a source distribution you would type: - - cpack -C CPackSourceConfig.cmake - -Alternatively, run “make package” or right click the Package target and -“Build Project” from an IDE. - -Run the installer executable found in the binary directory. Then run the -installed executable and verify that it works. diff --git a/Tests/Tutorial/Step7/tutorial.cxx b/Tests/Tutorial/Step7/tutorial.cxx deleted file mode 100644 index c2b89df..0000000 --- a/Tests/Tutorial/Step7/tutorial.cxx +++ /dev/null @@ -1,32 +0,0 @@ -// A simple program that computes the square root of a number -#include <cmath> -#include <iostream> -#include <string> - -#include "TutorialConfig.h" - -#ifdef USE_MYMATH -# include "MathFunctions.h" -#endif - -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; - } - - double inputValue = std::stod(argv[1]); - -#ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); -#else - double outputValue = sqrt(inputValue); -#endif - - std::cout << "The square root of " << inputValue << " is " << outputValue - << std::endl; - return 0; -} diff --git a/Tests/Tutorial/Step8/directions.txt b/Tests/Tutorial/Step8/directions.txt deleted file mode 100644 index 588d9c6..0000000 --- a/Tests/Tutorial/Step8/directions.txt +++ /dev/null @@ -1,38 +0,0 @@ -# Adding Support for a Dashboard # - -Adding support for submitting our test results to a dashboard is very easy. We -already defined a number of tests for our project in the earlier steps of this -tutorial. 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: - # enable testing - enable_testing() - -With: - # 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 where we can specify the -name of the project and where to submit the dashboard. - - set(CTEST_PROJECT_NAME "CMakeTutorial") - 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=CMakeTutorial") - set(CTEST_DROP_SITE_CDASH TRUE) - -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'. On Windows, build the EXPERIMENTAL target. - -Ctest will build and test the project and submit 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. diff --git a/Tests/Tutorial/Step8/tutorial.cxx b/Tests/Tutorial/Step8/tutorial.cxx deleted file mode 100644 index c2b89df..0000000 --- a/Tests/Tutorial/Step8/tutorial.cxx +++ /dev/null @@ -1,32 +0,0 @@ -// A simple program that computes the square root of a number -#include <cmath> -#include <iostream> -#include <string> - -#include "TutorialConfig.h" - -#ifdef USE_MYMATH -# include "MathFunctions.h" -#endif - -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; - } - - double inputValue = std::stod(argv[1]); - -#ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); -#else - double outputValue = sqrt(inputValue); -#endif - - std::cout << "The square root of " << inputValue << " is " << outputValue - << std::endl; - return 0; -} diff --git a/Tests/Tutorial/Step9/directions.txt b/Tests/Tutorial/Step9/directions.txt deleted file mode 100644 index 8771637..0000000 --- a/Tests/Tutorial/Step9/directions.txt +++ /dev/null @@ -1,166 +0,0 @@ -# Mixing Static and Shared # - -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/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: - - cmake_minimum_required(VERSION 3.3) - project(Tutorial) - - # 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_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED True) - - option(BUILD_SHARED_LIBS "Build using shared libraries" ON) - - # the version number. - set(Tutorial_VERSION_MAJOR 1) - set(Tutorial_VERSION_MINOR 0) - - # configure a header file to pass the version number only - configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) - - # add the MathFunctions library - add_subdirectory(MathFunctions) - - # add the executable - add_executable(Tutorial tutorial.cxx) - target_link_libraries(Tutorial PUBLIC MathFunctions) - -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: - - # 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) - - # 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) - - # 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} - ) - - target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(SqrtLibrary - PRIVATE "HAVE_LOG" "HAVE_EXP") - endif() - - 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(TARGETS MathFunctions DESTINATION lib) - install(FILES MathFunctions.h DESTINATION include) - -Next, update MathFunctions/mysqrt.cxx to use the mathfunctions and detail namespaces: - - #include <iostream> - #include "MathFunctions.h" - - // include the generated table - #include "Table.h" - - #include <cmath> - - namespace mathfunctions { - namespace detail { - // a hack square root calculation using simple operations - double mysqrt(double x) - { - ... - - return result; - } - } - } - -We also need to make some changes in tutorial.cxx, so that it no longer uses USE_MYMATH: -1. Always include MathFunctions.h -2. Always use mathfunctions::sqrt - -Finally, update MathFunctions/MathFunctions.h to use dll export defines: - - #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); - } - -At this point, if you build everything, you will notice that linking fails -as we are combining a static library without position enabled code with a -library that has position enabled code. This solution to this is to explicitly -set the POSITION_INDEPENDENT_CODE target property of SqrtLibrary to be True no -matter the build type. - -Exercise: We modified MathFunctions.h to use dll export defines. Using CMake -documentation can you find a helper module to simplify this? - -Exercise: Determine what command is enabling PIC for SqrtLibrary. -What happens if we remove said command? |