From b22774e33d61b8b66ba42f83aef48fe3e70c9ef0 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Fri, 17 Dec 2021 08:38:25 +0100 Subject: [PATCH] build: Added check for cloning ImHex without initializing its submodules --- CMakeLists.txt | 1 + cmake/build_helpers.cmake | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccaa8cef6..ced0d8dd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") include("${CMAKE_SOURCE_DIR}/cmake/build_helpers.cmake") setDefaultBuiltTypeIfUnset() +detectBadClone() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") # List plugin names here. Project name must match folder name diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 1afe9dee2..9bee5b795 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -256,4 +256,15 @@ macro(setDefaultBuiltTypeIfUnset) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Using Release build type as it was left unset" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release") endif() +endmacro() + +macro(detectBadClone) + file (GLOB EXTERNAL_DIRS "external/*") + foreach (EXTERNAL_DIR ${EXTERNAL_DIRS}) + file(GLOB RESULT "${EXTERNAL_DIR}/*") + list(LENGTH RESULT ENTRY_COUNT) + if(ENTRY_COUNT LESS_EQUAL 1) + message(FATAL_ERROR "External dependency ${EXTERNAL_DIR} is empty!\nMake sure to correctly clone ImHex using the --recurse-submodules git option or initialize the submodules manually.") + endif() + endforeach () endmacro() \ No newline at end of file