diff --git a/CMake构建/v1/CMakeLists.txt b/CMake构建/v1/CMakeLists.txt new file mode 100644 index 0000000..1223d3d --- /dev/null +++ b/CMake构建/v1/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.2) +project(test) +add_executable(app add.cpp div.cpp mult.cpp main.cpp sub.cpp) \ No newline at end of file diff --git a/CMake构建/v1/add.cpp b/CMake构建/v1/add.cpp new file mode 100644 index 0000000..b414f7c --- /dev/null +++ b/CMake构建/v1/add.cpp @@ -0,0 +1,9 @@ +#include +#include "head.h" + +const char* libVersion = "Library Version 1.0"; + +int add(int a, int b) +{ + return a+b; +} \ No newline at end of file diff --git a/CMake构建/v1/div.cpp b/CMake构建/v1/div.cpp new file mode 100644 index 0000000..b1adf90 --- /dev/null +++ b/CMake构建/v1/div.cpp @@ -0,0 +1,7 @@ +#include +#include "head.h" + +double divide(int a, int b) +{ + return (double)a/b; +} \ No newline at end of file diff --git a/CMake构建/v1/head.h b/CMake构建/v1/head.h new file mode 100644 index 0000000..246461f --- /dev/null +++ b/CMake构建/v1/head.h @@ -0,0 +1,11 @@ +#ifndef _HEAD_H +#define _HEAD_H + +int add(int a, int b); + +int subtract(int a, int b); + +double divide(int a, int b); + +int multiply(int a, int b); +#endif \ No newline at end of file diff --git a/CMake构建/v1/main.cpp b/CMake构建/v1/main.cpp new file mode 100644 index 0000000..30862eb --- /dev/null +++ b/CMake构建/v1/main.cpp @@ -0,0 +1,14 @@ +#include +#include "head.h" + +int main() +{ + int a = 20; + int b = 12; + printf("a = %d, b = %d\n", a, b); + printf("a + b = %d\n", add(a, b)); + printf("a - b = %d\n", subtract(a, b)); + printf("a * b = %d\n", multiply(a, b)); + printf("a / b = %f\n", divide(a, b)); + return 0; +} \ No newline at end of file diff --git a/CMake构建/v1/mult.cpp b/CMake构建/v1/mult.cpp new file mode 100644 index 0000000..257e056 --- /dev/null +++ b/CMake构建/v1/mult.cpp @@ -0,0 +1,7 @@ +#include +#include "head.h" + +int multiply(int a, int b) +{ + return a*b; +} \ No newline at end of file diff --git a/CMake构建/v1/sub.cpp b/CMake构建/v1/sub.cpp new file mode 100644 index 0000000..3199359 --- /dev/null +++ b/CMake构建/v1/sub.cpp @@ -0,0 +1,7 @@ +#include +#include "head.h" + +int subtract(int a, int b) +{ + return a-b; +} \ No newline at end of file