mirror of https://github.com/CGAL/cgal
parent
7cc46441b5
commit
17032feff4
|
|
@ -0,0 +1,17 @@
|
|||
function(cgal_parse_version_h version_h_file name)
|
||||
file(READ "${version_h_file}" version_file_content)
|
||||
string(REGEX MATCH "define CGAL_VERSION (.*)\n#define *CGAL_VERSION_NR 1(0([0-9])|([1-9][0-9]))([0-9][0-9])([0-9])([0-9][0-9][0-9])" CGAL_VERSION_FOUND "${version_file_content}")
|
||||
if (NOT CGAL_VERSION_FOUND)
|
||||
message(FATAL_ERROR "Cannot extract CGAL version number.")
|
||||
endif()
|
||||
set(${name} "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||
|
||||
# Now handle the optional arguments, to fill the version numbers
|
||||
# CMAKE_MATCH_2 corresponds to the alternative ([0-9])|([1-9][0-9])).
|
||||
# CMAKE_MATCH_3 and CMAKE_MATCH_4 corresponds to the two sub-expressions
|
||||
# of the alternative, and cannot be non-empty at the same time.
|
||||
set(${ARGV2} "${CMAKE_MATCH_3}${CMAKE_MATCH_4}" PARENT_SCOPE) # major version
|
||||
set(${ARGV3} "${CMAKE_MATCH_5}" PARENT_SCOPE) # minor version
|
||||
set(${ARGV4} "${CMAKE_MATCH_6}" PARENT_SCOPE) # patch number
|
||||
set(${ARGV5} "${CMAKE_MATCH_7}" PARENT_SCOPE) # build number
|
||||
endfunction()
|
||||
|
|
@ -140,4 +140,13 @@ cgal_setup_module_path()
|
|||
|
||||
set(CGAL_USE_FILE ${CGAL_MODULES_DIR}/UseCGAL.cmake)
|
||||
|
||||
include("${CGAL_MODULES_DIR}/CGAL_parse_version_h.cmake")
|
||||
cgal_parse_version_h( "${CGAL_INSTALLATION_PACKAGE_DIR}/include/CGAL/version.h"
|
||||
"CGAL_VERSION_NAME"
|
||||
"CGAL_MAJOR_VERSION"
|
||||
"CGAL_MINOR_VERSION"
|
||||
"CGAL_BUGFIX_VERSION"
|
||||
"CGAL_BUILD_VERSION")
|
||||
set(CGAL_VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUGFIX_VERSION}.${CGAL_BUILD_VERSION}")
|
||||
|
||||
include("${CGAL_MODULES_DIR}/CGAL_enable_end_of_configuration_hook.cmake")
|
||||
|
|
|
|||
Loading…
Reference in New Issue