From 91b41a729717af299291be4b43fa86b20654a616 Mon Sep 17 00:00:00 2001 From: Pascal Thomet Date: Fri, 30 Nov 2018 09:29:32 +0100 Subject: [PATCH] Initial scaffolding for Hunter package support. --- CMakeLists.txt | 10 ++++++ package/hunter/HunterAddPackages.cmake | 36 ++++++++++++++++++++ package/hunter/HunterInit.cmake | 46 ++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100644 package/hunter/HunterAddPackages.cmake create mode 100644 package/hunter/HunterInit.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 87c556e40..6ebbd468a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,8 +49,18 @@ endif() if(NOT CMAKE_VERSION VERSION_LESS 3.4.0 AND NOT CMAKE_SYSTEM_NAME STREQUAL "Android") set(LANG CXX) endif() + +option(HUNTER_ENABLED "Get dependencies (Corrade, GLFW, SDL2, ...) via Hunter" OFF) +if(HUNTER_ENABLED) + include(${CMAKE_CURRENT_LIST_DIR}/package/hunter/HunterInit.cmake) +endif() + project(Magnum ${LANG}) +if(HUNTER_ENABLED) + include(${CMAKE_CURRENT_LIST_DIR}/package/hunter/HunterAddPackages.cmake) +endif() + # Use folders for nice tree in Visual Studio and XCode set_property(GLOBAL PROPERTY USE_FOLDERS ON) diff --git a/package/hunter/HunterAddPackages.cmake b/package/hunter/HunterAddPackages.cmake new file mode 100644 index 000000000..d28a11bf3 --- /dev/null +++ b/package/hunter/HunterAddPackages.cmake @@ -0,0 +1,36 @@ +# +# This file is part of Magnum. +# +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 +# Vladimír Vondruš +# Copyright © 2018 Pascal Thomet +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +hunter_add_package(corrade) +if(WITH_GLFWAPPLICATION) + hunter_add_package(glfw) +endif() +if(WITH_SDL2APPLICATION) + hunter_add_package(SDL2) +endif() +if(WITH_AUDIO) + hunter_add_package(OpenAL) +endif() diff --git a/package/hunter/HunterInit.cmake b/package/hunter/HunterInit.cmake new file mode 100644 index 000000000..d8d51ba4c --- /dev/null +++ b/package/hunter/HunterInit.cmake @@ -0,0 +1,46 @@ +# +# This file is part of Magnum. +# +# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 +# Vladimír Vondruš +# Copyright © 2018 Pascal Thomet +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# + +set(_HUNTER_GATE_FILE ${CMAKE_CURRENT_BINARY_DIR}/HunterGate.cmake) +if(NOT EXISTS ${_HUNTER_GATE_FILE}) + file(DOWNLOAD + https://raw.githubusercontent.com/hunter-packages/gate/c4e5b3e4d1c97fb46ae86af7f59baac95f7f1cf0/cmake/HunterGate.cmake + ${_HUNTER_GATE_FILE} + EXPECTED_HASH SHA1=b59156338f5722d6ef84321c8ccef5ecf2ac24e6 + STATUS _HUNTER_GATE_FILE_STATUS) + # If download fails, remove the bad file so it tries to download it again + # next time + list(GET _HUNTER_GATE_FILE_STATUS 0 _HUNTER_GATE_FILE_STATUS_CODE) + if(NOT _HUNTER_GATE_FILE_STATUS_CODE EQUAL 0) + file(REMOVE ${_HUNTER_GATE_FILE}) + message(FATAL_ERROR "Error downloading HunterGate.cmake. Please retry the CMake configure step.") + endif() +endif() + +include(${_HUNTER_GATE_FILE}) +HunterGate( + URL "https://github.com/ruslo/hunter/archive/v0.23.65.tar.gz" + SHA1 "00e252171605c290390a3cc90a372beeeb406d3c")