Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ include(CTest) # Defines option BUILD_TESTING.
enable_testing()

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

include(OpenCensusDeps)

include(OpenCensusHelpers)
Expand Down
1,061 changes: 1,061 additions & 0 deletions cmake/FetchContent.cmake

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions cmake/FetchContent/CMakeLists.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

cmake_minimum_required(VERSION ${CMAKE_VERSION})

# We name the project and the target for the ExternalProject_Add() call
# to something that will highlight to the user what we are working on if
# something goes wrong and an error message is produced.

project(${contentName}-populate NONE)

include(ExternalProject)
ExternalProject_Add(${contentName}-populate
${ARG_EXTRA}
SOURCE_DIR "${ARG_SOURCE_DIR}"
BINARY_DIR "${ARG_BINARY_DIR}"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
USES_TERMINAL_DOWNLOAD YES
USES_TERMINAL_UPDATE YES
)
93 changes: 33 additions & 60 deletions cmake/OpenCensusDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,29 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include(FetchContent)

fetchcontent_declare(googletest
GIT_REPOSITORY
https://github.com/abseil/googletest
GIT_TAG
ed2fe122f8dc9aca844d724986d1d5cf5b65ea4e)
fetchcontent_declare(abseil
GIT_REPOSITORY
https://github.com/abseil/abseil-cpp
GIT_TAG
master)
fetchcontent_declare(prometheus
GIT_REPOSITORY
https://github.com/jupp0r/prometheus-cpp
GIT_TAG
master)

fetchcontent_getproperties(googletest)
if(BUILD_TESTING)
if(NOT TARGET gtest_main)
message(STATUS "Dependency: googletest (BUILD_TESTING=${BUILD_TESTING})")
message(STATUS "Dependency: googletest (BUILD_TESTING=${BUILD_TESTING})")

if(NOT googletest_POPULATED)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# All the libraries in the build must use either /MD or /MT (runtime
# library to link)
Expand All @@ -29,73 +48,27 @@ if(BUILD_TESTING)
ON)
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/googletest.CMakeLists.txt
${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
if(result)
message(FATAL_ERROR "CMake step failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download)
if(result)
message(FATAL_ERROR "Build step failed: ${result}")
endif()

add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL)
fetchcontent_populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()
endif()

# Load abseil second, it depends on googletest.
if(NOT TARGET absl::base)
message(STATUS "Dependency: abseil")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/abseil.CMakeLists.txt
${CMAKE_BINARY_DIR}/abseil-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/abseil-download)
if(result)
message(FATAL_ERROR "CMake step failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/abseil-download)
if(result)
message(FATAL_ERROR "Build step failed: ${result}")
endif()

add_subdirectory(${CMAKE_BINARY_DIR}/abseil-src
${CMAKE_BINARY_DIR}/abseil-build EXCLUDE_FROM_ALL)
fetchcontent_getproperties(abseil)
if(NOT abseil_POPULATED)
fetchcontent_populate(abseil)
add_subdirectory(${abseil_SOURCE_DIR} ${abseil_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

if(NOT TARGET prometheus-cpp::core)
message(STATUS "Dependency: prometheus-cpp")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/prometheus-cpp.CMakeLists.txt
${CMAKE_BINARY_DIR}/prometheus-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/prometheus-download)
if(result)
message(FATAL_ERROR "CMake step failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/prometheus-download)
if(result)
message(FATAL_ERROR "Build step failed: ${result}")
endif()

fetchcontent_getproperties(prometheus)
if(NOT prometheus_POPULATED)
set(ENABLE_PUSH OFF CACHE BOOL "Build prometheus-cpp push library" FORCE)
set(ENABLE_PULL OFF CACHE BOOL "Build prometheus-cpp pull library" FORCE)
set(ENABLE_COMPRESSION OFF
CACHE BOOL "Enable gzip compression for prometheus-cpp"
FORCE)
set(ENABLE_TESTING OFF CACHE BOOL "Build test for prometheus-cpp" FORCE)
add_subdirectory(${CMAKE_BINARY_DIR}/prometheus-src
${CMAKE_BINARY_DIR}/prometheus-build EXCLUDE_FROM_ALL)
fetchcontent_populate(prometheus)
add_subdirectory(${prometheus_SOURCE_DIR} ${prometheus_BINARY_DIR}
EXCLUDE_FROM_ALL)
endif()
31 changes: 0 additions & 31 deletions cmake/abseil.CMakeLists.txt

This file was deleted.

35 changes: 0 additions & 35 deletions cmake/googletest.CMakeLists.txt

This file was deleted.

31 changes: 0 additions & 31 deletions cmake/prometheus-cpp.CMakeLists.txt

This file was deleted.