Skip to content

Commit dc8d5e6

Browse files
authored
Merge pull request #391 from chewi/offline-build
Enable offline builds and fix CMake warnings
2 parents 222aa97 + 196faca commit dc8d5e6

File tree

15 files changed

+58
-50
lines changed

15 files changed

+58
-50
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ if(${BUILD_CURL_FROM_SOURCE})
1414
# In libcurl, CMakeLists build static lib is broken add build command via
1515
# make
1616
if(NOT TARGET libcurl_static_build)
17-
if (NOT curl_bundle_POPULATED)
18-
FetchContent_Populate(curl_bundle)
19-
endif()
20-
find_package(openssl)
17+
FetchContent_MakeAvailable(curl_bundle)
18+
find_package(OpenSSL)
2119
add_custom_command(
2220
OUTPUT ${curl_bundle_BINARY_DIR}/lib/libcurl.a
2321
WORKING_DIRECTORY ${curl_bundle_SOURCE_DIR}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ if(${BUILD_CURL_FROM_SOURCE})
1414
FetchContent_GetProperties(openssl102)
1515

1616
if(NOT TARGET openssl102_static_build)
17-
if(NOT openssl102_POPULATED)
18-
FetchContent_Populate(openssl102)
19-
endif()
17+
FetchContent_MakeAvailable(openssl102)
2018
add_custom_command(
2119
OUTPUT ${openssl102_BINARY_DIR}/lib/libssl.a
2220
WORKING_DIRECTORY ${openssl102_SOURCE_DIR}

CMake/FindRapidJSON.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
find_package(PkgConfig)
2+
if (PKG_CONFIG_FOUND)
3+
pkg_check_modules(RAPIDJSON RapidJSON)
4+
endif()
5+
6+
if (NOT RAPIDJSON_FOUND)
7+
if (NOT rapidjson_POPULATED)
8+
FetchContent_Populate(
9+
rapidjson
10+
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
11+
GIT_TAG 80b6d1c83402a5785c486603c5611923159d0894
12+
GIT_SUBMODULES ""
13+
)
14+
endif()
15+
FetchContent_GetProperties(rapidjson)
16+
set(RAPIDJSON_INCLUDE_DIRS "${rapidjson_SOURCE_DIR}/include")
17+
endif()
18+
19+
add_definitions("-DRAPIDJSON_HAS_STDSTRING=1")

CMake/Finde2fs.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ if(NOT ORIGIN_EXT2FS)
99
FetchContent_GetProperties(e2fsprogs)
1010

1111
if(NOT TARGET libext2fs_build)
12-
if (NOT e2fsprogs_POPULATED)
13-
FetchContent_Populate(e2fsprogs)
14-
endif()
12+
FetchContent_MakeAvailable(e2fsprogs)
1513
set(LIBEXT2FS_INSTALL_DIR ${e2fsprogs_SOURCE_DIR}/build/libext2fs CACHE STRING "")
1614

1715
add_custom_command(

CMake/Findphoton.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ else()
1717
endif()
1818

1919
if (BUILD_CURL_FROM_SOURCE)
20-
find_package(openssl REQUIRED)
21-
find_package(curl REQUIRED)
20+
find_package(OpenSSL REQUIRED)
21+
find_package(CURL REQUIRED)
2222
add_dependencies(photon_obj CURL::libcurl OpenSSL::SSL OpenSSL::Crypto)
2323
endif()
2424

CMake/Findrapidjson.cmake

Lines changed: 0 additions & 12 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,23 @@ set(CMAKE_CXX_STANDARD_REQUIRED on)
4444
set(ENABLE_MIMIC_VDSO off)
4545

4646
option(BUILD_CURL_FROM_SOURCE "Compile static libcurl" off)
47+
option(BUILD_STREAM_CONVERTOR "Build the stream convertor" on)
4748
option(ORIGIN_EXT2FS "Use original libext2fs" off)
49+
4850
find_package(photon REQUIRED)
4951
find_package(tcmu REQUIRED)
50-
find_package(yaml-cpp)
51-
if (NOT yaml-cpp_FOUND)
52-
FetchContent_Declare(
53-
yaml-cpp
54-
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
55-
GIT_TAG 0.8.0
56-
)
57-
FetchContent_MakeAvailable(yaml-cpp)
58-
endif()
5952

53+
if(BUILD_STREAM_CONVERTOR)
54+
find_package(yaml-cpp)
55+
if (NOT yaml-cpp_FOUND)
56+
FetchContent_Declare(
57+
yaml-cpp
58+
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
59+
GIT_TAG 0.8.0
60+
)
61+
FetchContent_MakeAvailable(yaml-cpp)
62+
endif()
63+
endif()
6064

6165
if(BUILD_TESTING)
6266
enable_testing()

src/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
find_package(curl REQUIRED)
2-
find_package(openssl REQUIRED)
1+
find_package(CURL REQUIRED)
2+
find_package(OpenSSL REQUIRED)
33
find_package(aio REQUIRED)
4-
find_package(rapidjson REQUIRED)
4+
find_package(RapidJSON REQUIRED MODULE)
55

66
link_libraries(rt pthread resolv)
77

@@ -19,7 +19,7 @@ add_library(overlaybd_image_lib
1919
target_include_directories(overlaybd_image_lib PUBLIC
2020
${CURL_INCLUDE_DIRS}
2121
${OPENSSL_INCLUDE_DIR}
22-
${rapidjson_SOURCE_DIR}/include
22+
${RAPIDJSON_INCLUDE_DIRS}
2323
${PHOTON_INCLUDE_DIR}
2424
)
2525

@@ -39,7 +39,7 @@ target_include_directories(overlaybd-tcmu PUBLIC
3939
${TCMU_INCLUDE_DIR}
4040
${CURL_INCLUDE_DIRS}
4141
${OPENSSL_INCLUDE_DIR}
42-
${rapidjson_SOURCE_DIR}/include
42+
${RAPIDJSON_INCLUDE_DIRS}
4343
${PHOTON_INCLUDE_DIR}
4444
)
4545
target_link_libraries(overlaybd-tcmu

src/overlaybd/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ add_subdirectory(cache)
66
add_subdirectory(tar)
77
add_subdirectory(gzip)
88
add_subdirectory(gzindex)
9-
add_subdirectory(stream_convertor)
9+
10+
if(BUILD_STREAM_CONVERTOR)
11+
add_subdirectory(stream_convertor)
12+
endif()
1013

1114
add_library(overlaybd_lib INTERFACE)
1215
target_include_directories(overlaybd_lib INTERFACE

src/overlaybd/cache/ocf_cache/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include_directories($ENV{GFLAGS}/include)
22
link_directories($ENV{GFLAGS}/lib)
33

4-
find_package(curl REQUIRED)
4+
find_package(CURL REQUIRED)
55

66
add_executable(ocf_perf_test ocf_perf_test.cpp)
77
target_include_directories(

0 commit comments

Comments
 (0)