Skip to content

Commit

Permalink
build: Cleanup version loading logic to make it available for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Jul 27, 2022
1 parent 54b31b8 commit 80c4949
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
# 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})
message("Project 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()
Expand Down
5 changes: 5 additions & 0 deletions cmake/build_helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 80c4949

Please sign in to comment.