My first CMakeLists.txt file

CMakeLists.txt文件:

project (test2)

set (src
	${CMAKE_CURRENT_SOURCE_DIR}/test2.cpp
)

add_executable(test2
	${src}
)

test2.cpp file:

#include <stdio.h>

int main(){
	
	printf ("cmakelist.txt生成的可执行文件\n");
	fflush(stdout);
	return 0;
}

The establishment of a build file in the directory CMakeLists.txt file and go to the next build file, execute the following command:

cmake ..
make

Run the resulting executable program:

./test2
Published 92 original articles · won praise 2 · Views 3404

Guess you like

Origin blog.csdn.net/zxc120389574/article/details/105310396