From 6909f769b157b3e9a334a29097facff662f26669 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Tue, 22 May 2012 14:49:17 +0400 Subject: [PATCH] CMake tutorial step1 added. --- c/cmake_tutorial/step1/CMakeLists.txt | 3 +++ c/cmake_tutorial/step1/tutorial.cxx | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 c/cmake_tutorial/step1/CMakeLists.txt create mode 100644 c/cmake_tutorial/step1/tutorial.cxx diff --git a/c/cmake_tutorial/step1/CMakeLists.txt b/c/cmake_tutorial/step1/CMakeLists.txt new file mode 100644 index 0000000..d676514 --- /dev/null +++ b/c/cmake_tutorial/step1/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required (VERSION 2.6) +project (Tutorial) +add_executable (Tutorial tutorial.cxx) diff --git a/c/cmake_tutorial/step1/tutorial.cxx b/c/cmake_tutorial/step1/tutorial.cxx new file mode 100644 index 0000000..3bcc4a4 --- /dev/null +++ b/c/cmake_tutorial/step1/tutorial.cxx @@ -0,0 +1,17 @@ +// A simple program that computes the square root of a number +#include +#include +#include +int main (int argc, char *argv[]) +{ + if (argc < 2) + { + fprintf(stdout,"Usage: %s number\n",argv[0]); + return 1; + } + double inputValue = atof(argv[1]); + double outputValue = sqrt(inputValue); + fprintf(stdout,"The square root of %g is %g\n", + inputValue, outputValue); + return 0; +}