Using glog in a CMake Project¶
Assuming that glog was previously built using CMake or
installed using a package manager, you can use the CMake command find_package
to build against glog in your CMake project as follows:
CMakeLists.txt
cmake_minimum_required (VERSION 3.16)
project (myproj VERSION 1.0)
find_package (glog 0.7.1 REQUIRED)
add_executable (myapp main.cpp)
target_link_libraries (myapp glog::glog)
Compile definitions and options will be added automatically to your target as needed.
Alternatively, glog can be incorporated into using the CMake command add_subdirectory
to include glog directly from a subdirectory of your project
by replacing the find_package
call from the previous snippet by
add_subdirectory
. The glog::glog
target is in this case an ALIAS
library target for the glog
library target.