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 <arnaud.pouliquen@foss.st.com>
This commit is contained in:
Arnaud Pouliquen
2021-05-04 09:19:11 +02:00
committed by Arnaud Pouliquen
parent 59e2f084d3
commit 04cf5d9e0e
2 changed files with 3 additions and 1 deletions
+2
View File
@@ -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"
+1 -1
View File
@@ -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})