Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build dependencies #19

Merged
merged 1 commit into from
Mar 9, 2023
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
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ project(gz-python)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT APPLE)
set(CMAKE_CXX_FLAGS "-fPIC")
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

#============================================================================
# Options
option(BUILD_protobuf "Build protobuf Library" ON)
message(STATUS "Build protobuf: ${BUILD_protobuf}")

option(BUILD_pybind11_protobuf "Build pybind11_protobuf Library" ON)
message(STATUS "Build pybind11_protobuf: ${BUILD_pybind11_protobuf}")
option(BUILD_TESTS "Build tests." OFF)

#============================================================================
# Find Python
Expand Down Expand Up @@ -46,11 +41,18 @@ find_package(gz-transport${GZ_TRANSPORT_VER} REQUIRED)

#============================================================================
# Build dependencies

set(_protobuf_repository "https://github.com/protocolbuffers/protobuf.git")
set(_protobuf_version 21.5)
set(_protobuf_tag v21.5)

set(_pybind11_protobuf_repository "https://github.com/pybind/pybind11_protobuf.git")
set(_pybind11_protobuf_version 0.0.0)
set(_pybind11_protobuf_tag main)

add_subdirectory(cmake/dependencies dependencies)
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/dependencies/install)

include(deps)

message("pybind11_protobuf_FOUND: ${pybind11_protobuf_FOUND}")
message("pybind11_protobuf_SOURCE_DIR: ${pybind11_protobuf_SOURCE_DIR}")
message("pybind11_protobuf_INCLUDE_DIRS: ${pybind11_protobuf_INCLUDE_DIRS}")
Expand Down
24 changes: 13 additions & 11 deletions cmake/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,38 @@ include(FetchContent)
#============================================================================
# Declare all dependencies first

if(BUILD_protobuf)
find_package(Protobuf ${_protobuf_version} EXACT QUIET)
if(NOT Protobuf_FOUND)
set(protobuf_BUILD_TESTS OFF CACHE INTERNAL "")
FetchContent_Declare(
protobuf
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
GIT_TAG "v21.5"
Protobuf
GIT_REPOSITORY ${_protobuf_repository}
GIT_TAG ${_protobuf_tag}
GIT_SUBMODULES ""
)
endif()

if(BUILD_pybind11_protobuf)
find_package(pybind11_protobuf ${_pybind11_protobuf_version} EXACT QUIET)
if(NOT pybind11_protobuf_FOUND)
FetchContent_Declare(
pybind11_protobuf
GIT_REPOSITORY "https://github.com/srmainwaring/pybind11_protobuf"
GIT_TAG "eea7c8e839bbcd624d8a8230773829cd49e41cba"
GIT_REPOSITORY ${_pybind11_protobuf_repository}
GIT_TAG ${_pybind11_protobuf_tag}
)
endif()

#============================================================================
# Make dependencies avaialble

if(BUILD_protobuf)
message(CHECK_START "Fetching protobuf")
if(NOT Protobuf_FOUND)
message(CHECK_START "Fetching Protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_MakeAvailable(protobuf)
FetchContent_MakeAvailable(Protobuf)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()

if(BUILD_pybind11_protobuf)
if(NOT pybind11_protobuf_FOUND)
message(CHECK_START "Fetching pybind11_protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_MakeAvailable(pybind11_protobuf)
Expand Down
8 changes: 0 additions & 8 deletions cmake/deps.cmake

This file was deleted.