From 80c4949dfbbab527ca0945ea862be9c773619048 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 27 Jul 2022 08:27:38 +0200 Subject: [PATCH] build: Cleanup version loading logic to make it available for plugins --- CMakeLists.txt | 16 +++++++++------- cmake/build_helpers.cmake | 5 +++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cba0c6b2..bbce2bc6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,20 @@ cmake_minimum_required(VERSION 3.16) -# Updating the version here will update it throughout ImHex as well -file(READ "VERSION" IMHEX_VERSION) -project(imhex VERSION ${IMHEX_VERSION}) -message("Project version ${IMHEX_VERSION}") +# Options +option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF) +option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF) +# Setup project +loadVersion(IMHEX_VERSION) +set(IMHEX_VERSION ${IMHEX_VERSION} PARENT_SCOPE) +project(imhex VERSION ${IMHEX_VERSION}) + +# Basic compiler and cmake configurations set(CMAKE_CXX_STANDARD 23) set(IMHEX_BASE_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_MODULE_PATH "${IMHEX_BASE_FOLDER}/cmake/modules") include("${IMHEX_BASE_FOLDER}/cmake/build_helpers.cmake") -option(IMHEX_OFFLINE_BUILD "Enable offline build" OFF) -option(IMHEX_PATTERNS_PULL_MASTER "Download latest files from master branch of the ImHex-Patterns repo" OFF) - # Make sure project is configured correctly setDefaultBuiltTypeIfUnset() detectBadClone() diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 8a40a609e..db14b1ec0 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -277,6 +277,11 @@ macro(setDefaultBuiltTypeIfUnset) endif() endmacro() +function(loadVersion version) + file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" read_version) + set(${version} ${read_version} PARENT_SCOPE) +endfunction() + macro(detectBadClone) file (GLOB EXTERNAL_DIRS "lib/external/*") foreach (EXTERNAL_DIR ${EXTERNAL_DIRS})