1,APP cmake
1.1 hello_app_01
文件:hello.cpp add_impl.cpp sub_impl.cpp CMakeLists.txt
hello.cpp
#include <iostream>
float add(float, float);
float sub(float, float);
int main()
{
float a, b;
a = 7.7f;
b = 2.333f;
std::cout<< "hello a + b =" << add(a, b) << std::endl;
std::cout<< "hello a - b =" << sub(a, b) << std::endl;
return 0;
}
add_impl.cpp
float add(float a, float b)
{
return a+b;
}
sub_impl.cpp
float sub(float a, float b)
{
return a - b;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(hello_01)
add_executable(hello_01 hello.cpp add_impl.cpp sub_impl.cpp)
编译:
cd hello_app_01/
mkdir build
cd build/
cmake ..
make
运行:
1.2 hello_app_02
文件:
编译:
运行:
1.3 hello_app_03
文件:
编译:
运行:
1.4 hello_app_04
文件:
编译:
运行:
1.5 hello_app_05
文件:
编译:
运行:
2,LIB cmake
2.1 hello_lib_01
文件:
编译:
运行:
2.2 hello_lib_02
文件:
编译:
运行:
2.3 hello_lib_03
文件:
编译:
运行:
2.4 hello_lib_04
文件:
编译:
运行:
2.5 hello_lib_05
文件:
编译:
运行:
2.6 hello_lib_06
文件:
编译:
运行: