3 Glog comes with a CMake build script ([CMakeLists.txt](../CMakeLists.txt)) that can be used on a wide range of platforms.
4 If you don't have CMake installed already, you can download it for free from <http://www.cmake.org/>.
6 CMake works by generating native makefiles or build projects that can be used in the compiler environment of your choice.
7 You can either build Glog with CMake as a standalone project or it can be incorporated into an existing CMake build for another project.
11 - [Building Glog with CMake](#building-glog-with-cmake)
12 - [Consuming Glog in a CMake Project](#consuming-glog-in-a-cmake-project)
13 - [Incorporating Glog into a CMake Project](#incorporating-glog-into-a-cmake-project)
15 ## Building Glog with CMake
17 When building Glog as a standalone project, on Unix-like systems with GNU Make as build tool, the typical workflow is:
19 1. Get the source code and change to it.
20 e.g. cloning with git:
22 git clone git@github.com:google/glog.git
26 2. Run CMake to configure the build tree.
28 cmake -H. -Bbuild -G "Unix Makefiles"
30 note: To get the list of available generators (e.g. Visual Studio), use `-G ""`
32 3. Afterwards, generated files can be used to compile the project.
37 4. Test the build software (optional).
39 cmake --build build --target test
42 5. Install the built files (optional).
44 cmake --build build --target install
47 ## Consuming Glog in a CMake Project
49 If you have Glog installed in your system, you can use the CMake command
50 `find_package()` to include it in your CMake Project.
53 cmake_minimum_required(VERSION 3.0.2)
54 project(myproj VERSION 1.0)
56 find_package(glog 0.3.5 REQUIRED)
58 add_executable(myapp main.cpp)
59 target_link_libraries(myapp glog::glog)
62 Compile definitions and options will be added automatically to your target as
65 ## Incorporating Glog into a CMake Project
67 You can also use the CMake command `add_subdirectory()` to include Glog directly from a subdirectory of your project.
68 The **glog::glog** target is in this case an ALIAS library target for the **glog** library target.
71 cmake_minimum_required(VERSION 3.0.2)
72 project(myproj VERSION 1.0)
74 add_subdirectory(glog)
76 add_executable(myapp main.cpp)
77 target_link_libraries(myapp glog::glog)
80 Again, compile definitions and options will be added automatically to your target as