CMake the easiest project

Written in C ++ files

#include <iostream>
class CopyObj
{
public:
        CopyObj()
        {
                std::cout << "CopyObj "<<std::endl;
        }
        ~CopyObj()
        {}
};
class CopyTest
{
public:`在这里插入代码片`
        CopyTest(){}
        ~CopyTest(){}
        CopyObj copyExecute()
        {
                return obj;
        }
private:
        CopyObj obj;
};
int main()
{
        CopyTest cop;
        std::cout<<"Hello World! "<<std::endl;
        auto obj1 = cop.copyExecute();
        return 0;
}

编写CMakeLists.txt

cmake_minimum_required(VERSION 2.8.0)
project(Show)
add_executable(Show main.cpp)

Production Makefile

mkdir bulid
cd bulid
cmake …
make

run

./Show

result

CopyObj
Hello World!

Released two original articles · won praise 0 · Views 15

Guess you like

Origin blog.csdn.net/tangtinghao/article/details/104910762