![]() It is probably best to keep two windows open with one in the build tree for making and running your programs, and one window in the source tree for modifying source files. If you are only making changes in a subdirectory, you can simply run make in the corresponding subdirectory in the build tree to process updates.Īn initial source of confusion with out of source builds is that you basically have two copies of your source tree, one with actual source code, and one with Makefiles and binary executables (in the build tree). If you modify code in your source directory, including even a CMakeLists.txt file and re-run make in the build directory, make and cmake will recompile and rebuild necessary changes. Makefile cmake_install.cmake oglfirst* test_geometry* Include_directories($/w01-cpp), our freshly compiled binaries are in the w01-cpp folder in the build directory where we just ran make.ĬMakeFiles/ cdemo* libgeometry.a pointers* Let's take a look at the CMakeLists.txt file in the w01-cpp subdirectory: W01-cpp by telling our top-level CMakeLists.txt file to Finally we indicate that most of code is really in the Use this info in the CMakeLists.txt file in the w01-cppĭirectory. You can name your project whatever you want. I also gave this CMake project a name using In this example I enabled debugging symbols (-g)Īnd all warnings (-Wall). ![]() You can set common flags that you would set in a typical Makefile using Use one of these scripts, use find_package(PKGname) if theįor more on finding external libraries or creating your own find package macros, see the KitWare wiki on the subject. usr/local/share/cmake-2.6/Modules/Find*.cmake for more examples. CMake has support for finding lots of packages. Libraries and sets up the most common libraries that are linked to in a typical Thus find_package(GLUT) andįind_package(OpenGL) finds the location of the header files and Standard places to look however, and CMake automates this search usingįind_package macros. Install to install and from platform to platform. The location of the header files and libraries likely varies from ![]() Libraries to use, e.g., -lGL -lGLU -lglut, and the location of the Where the OpenGL header files are e.g., -I/usr/local/include, which In a typical Makefile configuration we would likely need to specify This demo code includes code that requires external OpenGL libraries for #see /usr/local/share/cmake-2.6/Modules/Find*.cmake for more examples Top-level cmake directory is pretty simple but demonstrates a few key features. Sub-directory inherit properties set in the parent directory, reducing theĪmount of code duplication. Is nice about CMake is that CMakeLists.txt files in a CMake is controlled by writing instructions in CMakeLists.txt files.Įach directory in your project should have a CMakeLists.txt file.
0 Comments
Leave a Reply. |