Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit 8c811a7

Browse files
committed
docs: give a example to show how to import glog by add_subdirectory
Change-Id: I2e77e155c134d36f36ff38f3d3bc396a48b07ff6
1 parent ac12a9e commit 8c811a7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,27 @@ Alternatively, glog can be incorporated into using the CMake command
7979
project by replacing the :cmake:`find_package` call from the previous snippet by
8080
:cmake:`add_subdirectory`. The :cmake:`glog::glog` target is in this case an
8181
:cmake:`ALIAS` library target for the ``glog`` library target.
82+
Here is an example which using :cmake:`FetchContent` and :cmake:`add_subdirectory`
83+
to enable glog in your CMake project:
84+
.. code:: cmake
85+
86+
cmake_minimum_required (VERSION 3.16)
87+
project (myproj VERSION 1.0)
88+
89+
include(FetchContent)
90+
FetchContent_Declare(
91+
glog
92+
GIT_REPOSITORY https://github.com/google/glog.git
93+
GIT_TAG v0.6.0
94+
)
95+
FetchContent_GetProperties(glog)
96+
if(NOT glog_POPULATED)
97+
FetchContent_Populate(glog)
98+
add_subdirectory(${glog_SOURCE_DIR} ${glog_BINARY_DIR})
99+
endif()
100+
101+
add_executable (myapp main.cpp)
102+
target_link_libraries (myapp glog::glog)
82103
83104
Building from Source
84105
~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)