Skip to content

Commit

Permalink
Initial hunter support (#1578)
Browse files Browse the repository at this point in the history
* Initial hunter support

* TIdy hunter cmake

* Tidy cmake hunter options

Co-authored-by: Seb Horsewell <[email protected]>
  • Loading branch information
bazfp and Seb Horsewell authored Oct 25, 2021
1 parent a6cd530 commit ab7caae
Show file tree
Hide file tree
Showing 6 changed files with 558 additions and 7 deletions.
19 changes: 15 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
cmake_minimum_required(VERSION 3.10.2)

option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
option(SUPERBUILD "Build dependencies" ON)
option(BUILD_MAVSDK_SERVER "Build mavsdk_server" OFF)
option(BUILD_SHARED_LIBS "Build core as shared libraries instead of static ones" ON)

if(SUPERBUILD AND HUNTER_ENABLED)
message(FATAL_ERROR "Cannot SUPERBUILD while HUNTER_ENABLED. Set -DSUPERBUILD=OFF when using Hunter")
endif()

include("src/cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/cpp-pm/hunter/archive/v0.23.315.tar.gz"
SHA1 "ea5d72afc0df67f2126e7fd069f20c5f723709e1"
)

execute_process(
COMMAND git describe --abbrev=8 --dirty --always --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -25,10 +40,6 @@ if (BUILD_BACKEND)
message(FATAL_ERROR "The argument BUILD_BACKEND has been replaced by BUILD_MAVSDK_SERVER. To build mavsdk_server, use -DBUILD_MAVSDK_SERVER=ON.")
endif()

option(SUPERBUILD "Build dependencies" ON)
option(BUILD_MAVSDK_SERVER "Build mavsdk_server" OFF)
option(BUILD_SHARED_LIBS "Build core as shared libraries instead of static ones" ON)

set(DEPS_BUILD_PATH "${PROJECT_BINARY_DIR}/third_party" CACHE PATH "Install path for the dependencies. Ignored if SUPERBUILD=OFF.")
set(DEPS_INSTALL_PATH "${DEPS_BUILD_PATH}/install" CACHE PATH "Install path for the dependencies. Ignored if SUPERBUILD=OFF.")

Expand Down
12 changes: 10 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ option(CMAKE_POSITION_INDEPENDENT_CODE "Position independent code" ON)

include(cmake/compiler_flags.cmake)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")

find_package(Threads REQUIRED)

if(NOT HUNTER_ENABLED)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
endif()

# This will noop if hunter is not enabled
hunter_add_package(jsoncpp)
hunter_add_package(tinyxml2)
hunter_add_package(CURL)

find_package(CURL REQUIRED)
find_package(tinyxml2 REQUIRED)

Expand Down
Loading

0 comments on commit ab7caae

Please sign in to comment.