summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-27 19:59:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-02-27 20:00:11 (GMT)
commit4aa2e7ace3fad65627824f72d3e491ba19fdb550 (patch)
treec902e370244623268880f55d0ad8a5f297766584
parent2a9cf889178dfc202ec84f1fece8a68594cc3566 (diff)
parent07223c5c27f60472db2125df647c7e1818aa01bc (diff)
downloadCMake-4aa2e7ace3fad65627824f72d3e491ba19fdb550.zip
CMake-4aa2e7ace3fad65627824f72d3e491ba19fdb550.tar.gz
CMake-4aa2e7ace3fad65627824f72d3e491ba19fdb550.tar.bz2
Merge topic 'tutorial-have-log-and-exp'
07223c5c27 Tutorial: Update Step 5 to work on Windows Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4375
-rw-r--r--Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt12
-rw-r--r--Help/guide/tutorial/index.rst2
-rw-r--r--Tests/CMakeLists.txt21
3 files changed, 27 insertions, 8 deletions
diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
index 4bf6024..f64c6ac 100644
--- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
@@ -8,10 +8,20 @@ target_include_directories(MathFunctions
# 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)
+if(NOT (HAVE_LOG AND HAVE_EXP))
+ unset(HAVE_LOG CACHE)
+ unset(HAVE_EXP CACHE)
+ set(CMAKE_REQUIRED_LIBRARIES "m")
+ check_symbol_exists(log "math.h" HAVE_LOG)
+ check_symbol_exists(exp "math.h" HAVE_EXP)
+ if(HAVE_LOG AND HAVE_EXP)
+ target_link_libraries(MathFunctions PRIVATE m)
+ endif()
+endif()
+# add compile definitions
if(HAVE_LOG AND HAVE_EXP)
target_compile_definitions(MathFunctions
PRIVATE "HAVE_LOG" "HAVE_EXP")
diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst
index a844cbf..4fbcd4c 100644
--- a/Help/guide/tutorial/index.rst
+++ b/Help/guide/tutorial/index.rst
@@ -386,7 +386,7 @@ these functions using the :module:`CheckSymbolExists` module in the top-level
.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
:language: cmake
:start-after: # does this system provide the log and exp functions?
- :end-before: if(HAVE_LOG AND HAVE_EXP)
+ :end-before: # add compile definitions
Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them
from ``mysqrt.cxx``:
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 33c7514..6f86a5f 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1605,7 +1605,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
DEPENDS ExternalProjectUpdateSetup )
# do each of the tutorial steps
- function(add_tutorial_test step_name use_mymath)
+ function(add_tutorial_test step_name use_mymath tutorial_arg pass_regex)
set(tutorial_test_name Tutorial${step_name})
set(tutorial_build_dir "${CMake_BINARY_DIR}/Tests/Tutorial/${step_name}")
if (use_mymath)
@@ -1623,19 +1623,28 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
${build_generator_args}
--build-project Tutorial
--build-options ${tutorial_build_options}
- --test-command Tutorial 25.0)
+ --test-command Tutorial ${tutorial_arg})
+ set_tests_properties(${tutorial_test_name} PROPERTIES
+ PASS_REGULAR_EXPRESSION ${pass_regex})
+
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/${tutorial_build_dir}_Build")
endfunction()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
foreach(STP RANGE 2 12)
- add_tutorial_test(Step${STP} TRUE)
+ if (STP EQUAL 6)
+ set(pass_regex ".*using log and exp")
+ else()
+ set(pass_regex "The square root of 25 is 5")
+ endif()
+ add_tutorial_test(Step${STP} TRUE 25 ${pass_regex})
endforeach()
- add_tutorial_test(Complete TRUE)
+ set(pass_regex "The square root of 25 is 5")
+ add_tutorial_test(Complete TRUE 25 ${pass_regex})
foreach(STP RANGE 3 12)
- add_tutorial_test(Step${STP} FALSE)
+ add_tutorial_test(Step${STP} FALSE 25 ${pass_regex})
endforeach()
- add_tutorial_test(Complete FALSE)
+ add_tutorial_test(Complete FALSE 25 ${pass_regex})
endif()
add_test(testing ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE}