Recently on the use of Linux CMake, for the use of GUI habits really can not adapt, really want to do everything possible to use the original CMake project created Codeblocks project. The project is too small to accept, the project is too much trouble.
Look at the official documents of CMake from 2.2.8 later versions can be directly used to generate the Codeblocks project, my little heart ah ... But the relevant article is not too much, may have I this idea is not too much, general use CMake is a master, will not be so daoteng, nonsense said, the following directly from the simplest project to start it.
Because CMake official recommends using external compilation, we'd better use external compilation as well. Create a new folder for T1, under which a new two directory is HELLO_SRC, build. HELLO_SRC store source files and Cmakelists.txt,build to store generated codeblocks works.
The MAIN.C code is
1 #include <stdio.h>2int main ()3{4 printf ("Hello World from T1 main!\n"); 5 return 0 ; 6 }
CMakeLists.txt
1 PROJECT (HELLO) 2 SET (src_list main.c) 3 " " ${hello_binary_dir})4""${hello_ Source_dir})5 add_executable (Hello ${src_list})
CMake. /hello_src-g "Codeblocks-unix makefiles"
Enter the build and see the Codeblocks project.
But the direct compile run is problematic,
Select project-"properties-" Build targets
Revision changed to
Then click Compile to run successfully:
Create a codeblocks project on Linux using CMake