From 04cf5d9e0ef562d676cd3f58530fed4e1901f428 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Mon, 3 May 2021 16:38:38 +0200 Subject: [PATCH] cmake: fix VERSION file path cmake fails when the variable CMAKE_SOURCE_DIR does not point to the libmetal directory. This is the case, for example, for the Zephyr project. Fix by defining LIBMETAL_ROOT_DIR in the main CmakeLists.txt. Signed-off-by: Arnaud Pouliquen --- CMakeLists.txt | 2 ++ cmake/options.cmake | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8095465..7ea8f7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif() +set (LIBMETAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" diff --git a/cmake/options.cmake b/cmake/options.cmake index 4b86616..cbf1c2b 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,4 +1,4 @@ -file(READ ${CMAKE_SOURCE_DIR}/VERSION ver) +file(READ ${LIBMETAL_ROOT_DIR}/VERSION ver) string(REGEX MATCH "VERSION_MAJOR = ([0-9]*)" _ ${ver}) set(PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1})