Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-02-21 11:31:00 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-21 11:31:00 +0300
commit72d5d692eaed12bee01da0b441cb740d131e80b0 (patch)
tree504fc52257ae03a6afeb55ee5531b2ed041b5281 /build_files/cmake
parentb26a4dc4afdd51bca1bd4f2dce4e3b12ecc06b51 (diff)
better macro for getting the blender version from BKE_blender.h, also re-run CMake if BKE_blender.h changes.
Diffstat (limited to 'build_files/cmake')
-rw-r--r--build_files/cmake/macros.cmake56
1 files changed, 30 insertions, 26 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index b84950c47aa..007c147ccef 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -332,35 +332,39 @@ macro(ADD_CHECK_CXX_COMPILER_FLAG
endmacro()
macro(get_blender_version)
- file(READ ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h CONTENT)
- string(REGEX REPLACE "\n" ";" CONTENT "${CONTENT}")
- string(REGEX REPLACE "\t" ";" CONTENT "${CONTENT}")
- string(REGEX REPLACE " " ";" CONTENT "${CONTENT}")
-
- foreach(ITEM ${CONTENT})
- if(LASTITEM MATCHES "^BLENDER_VERSION$")
- MATH(EXPR BLENDER_VERSION_MAJOR "${ITEM} / 100")
- MATH(EXPR BLENDER_VERSION_MINOR "${ITEM} % 100")
- set(BLENDER_VERSION "${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}")
- endif()
+ # So cmake depends on BKE_blender.h, beware of inf-loops!
+ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h ${CMAKE_BINARY_DIR}/source/blender/blenkernel/BKE_blender.h.done)
- if(LASTITEM MATCHES "^BLENDER_SUBVERSION$")
- set(BLENDER_SUBVERSION ${ITEM})
- endif()
+ file(STRINGS ${CMAKE_SOURCE_DIR}/source/blender/blenkernel/BKE_blender.h _contents REGEX "^#define[ \t]+BLENDER_.*$")
- if(LASTITEM MATCHES "^BLENDER_MINVERSION$")
- MATH(EXPR BLENDER_MINVERSION_MAJOR "${ITEM} / 100")
- MATH(EXPR BLENDER_MINVERSION_MINOR "${ITEM} % 100")
- set(BLENDER_MINVERSION "${BLENDER_MINVERSION_MAJOR}.${BLENDER_MINVERSION_MINOR}")
- endif()
+ string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION[ \t]+([0-9]+).*" "\\1" _out_version "${_contents}")
+ string(REGEX REPLACE ".*#define[ \t]+BLENDER_SUBVERSION[ \t]+([0-9]+).*" "\\1" _out_subversion "${_contents}")
+ string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION_CHAR[ \t]+([a-z]+).*" "\\1" _out_version_char "${_contents}")
+ string(REGEX REPLACE ".*#define[ \t]+BLENDER_VERSION_CYCLE[ \t]+([a-z]+).*" "\\1" _out_version_cycle "${_contents}")
- if(LASTITEM MATCHES "^BLENDER_MINSUBVERSION$")
- set(BLENDER_MINSUBVERSION ${ITEM})
- endif()
+ if(NOT ${_out_version} MATCHES "[0-9]+")
+ message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION")
+ endif()
- set(LASTITEM ${ITEM})
- endforeach()
+ if(NOT ${_out_subversion} MATCHES "[0-9]+")
+ message(FATAL_ERROR "Version parsing failed for BLENDER_SUBVERSION")
+ endif()
+
+ if(NOT ${_out_version_char} MATCHES "[a-z]+")
+ message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CHAR")
+ endif()
+
+ if(NOT ${_out_version_cycle} MATCHES "[a-z]+")
+ message(FATAL_ERROR "Version parsing failed for BLENDER_VERSION_CYCLE")
+ endif()
+
+ MATH(EXPR BLENDER_VERSION_MAJOR "${_out_version} / 100")
+ MATH(EXPR BLENDER_VERSION_MINOR "${_out_version} % 100")
+ set(BLENDER_VERSION "${BLENDER_VERSION_MAJOR}.${BLENDER_VERSION_MINOR}")
+
+ set(BLENDER_SUBVERSION ${_out_subversion})
+ set(BLENDER_VERSION_CHAR ${_out_version_char})
+ set(BLENDER_VERSION_CYCLE ${_out_version_cycle})
- # message(STATUS "Version major: ${BLENDER_VERSION_MAJOR}, Version minor: ${BLENDER_VERSION_MINOR}, Subversion: ${BLENDER_SUBVERSION}, Version: ${BLENDER_VERSION}")
- # message(STATUS "Minversion major: ${BLENDER_MINVERSION_MAJOR}, Minversion minor: ${BLENDER_MINVERSION_MINOR}, MinSubversion: ${BLENDER_MINSUBVERSION}, Minversion: ${BLENDER_MINVERSION}")
+ # message(STATUS "Version (Internal): ${BLENDER_VERSION}.${BLENDER_SUBVERSION}, Version (external): ${BLENDER_VERSION}${BLENDER_VERSION_CHAR}-${BLENDER_VERSION_CYCLE}")
endmacro()