diff --git a/CMakeLists.txt b/CMakeLists.txt index bbce2bc6f..e11ba9863 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,17 +4,17 @@ cmake_minimum_required(VERSION 3.16) 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") +# Setup project +loadVersion(IMHEX_VERSION) +setVariableInParent(IMHEX_VERSION ${IMHEX_VERSION}) +project(imhex VERSION ${IMHEX_VERSION}) + # Make sure project is configured correctly setDefaultBuiltTypeIfUnset() detectBadClone() diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index db14b1ec0..affdddff1 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -293,6 +293,15 @@ macro(detectBadClone) endforeach () endmacro() +macro(setVariableInParent variable value) + get_directory_property(hasParent PARENT_DIRECTORY) + + if (hasParent) + set(${variable} "${${value}}" PARENT_SCOPE) + else () + set(${variable} "${value}") + endif () +endmacro() function(downloadImHexPatternsFiles dest) if (NOT IMHEX_OFFLINE_BUILD)