mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 05:39:57 -05:00
Tutorial: Move step 8 to step 5. Shift steps 5-7 to 6-8.
This commit is contained in:
@@ -37,7 +37,7 @@ install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
|
||||
)
|
||||
|
||||
# enable testing
|
||||
enable_testing()
|
||||
include(CTest)
|
||||
|
||||
# does the application run
|
||||
add_test(NAME Runs COMMAND Tutorial 25)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
set(CTEST_PROJECT_NAME "CMakeTutorial")
|
||||
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
|
||||
|
||||
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)
|
||||
@@ -6,29 +6,6 @@ target_include_directories(MathFunctions
|
||||
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# does this system provide the log and exp functions?
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("
|
||||
#include <cmath>
|
||||
int main() {
|
||||
std::log(1.0);
|
||||
return 0;
|
||||
}
|
||||
" HAVE_LOG)
|
||||
check_cxx_source_compiles("
|
||||
#include <cmath>
|
||||
int main() {
|
||||
std::exp(1.0);
|
||||
return 0;
|
||||
}
|
||||
" HAVE_EXP)
|
||||
|
||||
# add compile definitions
|
||||
if(HAVE_LOG AND HAVE_EXP)
|
||||
target_compile_definitions(MathFunctions
|
||||
PRIVATE "HAVE_LOG" "HAVE_EXP")
|
||||
endif()
|
||||
|
||||
# install rules
|
||||
install(TARGETS MathFunctions DESTINATION lib)
|
||||
install(FILES MathFunctions.h DESTINATION include)
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// A simple program that builds a sqrt table
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
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
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#include "MathFunctions.h"
|
||||
@@ -10,12 +9,6 @@ double mysqrt(double x)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if we have both log and exp then use them
|
||||
#if defined(HAVE_LOG) && defined(HAVE_EXP)
|
||||
double result = std::exp(std::log(x) * 0.5);
|
||||
std::cout << "Computing sqrt of " << x << " to be " << result
|
||||
<< " using log and exp" << std::endl;
|
||||
#else
|
||||
double result = x;
|
||||
|
||||
// do ten iterations
|
||||
@@ -27,6 +20,5 @@ double mysqrt(double x)
|
||||
result = result + 0.5 * delta / result;
|
||||
std::cout << "Computing sqrt of " << x << " to be " << result << std::endl;
|
||||
}
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user