-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathGetGFlags.cmake
45 lines (34 loc) · 1.05 KB
/
GetGFlags.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (c) 2023, AgiBot Inc.
# All rights reserved.
include(FetchContent)
message(STATUS "get gflags ...")
set(gflags_DOWNLOAD_URL
"https://github.com/gflags/gflags/archive/v2.2.2.tar.gz"
CACHE STRING "")
if(gflags_LOCAL_SOURCE)
FetchContent_Declare(
gflags
SOURCE_DIR ${gflags_LOCAL_SOURCE}
OVERRIDE_FIND_PACKAGE)
else()
FetchContent_Declare(
gflags
URL ${gflags_DOWNLOAD_URL}
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
OVERRIDE_FIND_PACKAGE)
endif()
# Wrap it in a function to restrict the scope of the variables
function(get_gflags)
FetchContent_GetProperties(gflags)
if(NOT gflags_POPULATED)
FetchContent_Populate(gflags)
set(BUILD_TESTING OFF)
file(READ ${gflags_SOURCE_DIR}/CMakeLists.txt TMP_VAR)
string(REPLACE " set (PKGCONFIG_INSTALL_DIR " "# set (PKGCONFIG_INSTALL_DIR " TMP_VAR "${TMP_VAR}")
file(WRITE ${gflags_SOURCE_DIR}/CMakeLists.txt "${TMP_VAR}")
add_subdirectory(${gflags_SOURCE_DIR} ${gflags_BINARY_DIR})
endif()
endfunction()
get_gflags()
# import targets:
# gflags::gflags