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