You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.0 KiB
65 lines
2.0 KiB
# Function that converts a version string of the form 'major[.minor[.patch]]' to
|
|
# the integer ((major * 100) + minor) * 100 + patch.
|
|
function(dgtd_version_to_int VersionString VersionIntVar)
|
|
if ("${VersionString}" MATCHES "^([0-9]+)(.*)$")
|
|
set(Major "${CMAKE_MATCH_1}")
|
|
set(MinorPatchString "${CMAKE_MATCH_2}")
|
|
else()
|
|
set(Major 0)
|
|
endif()
|
|
if ("${MinorPatchString}" MATCHES "^\\.([0-9]+)(.*)$")
|
|
set(Minor "${CMAKE_MATCH_1}")
|
|
set(PatchString "${CMAKE_MATCH_2}")
|
|
else()
|
|
set(Minor 0)
|
|
endif()
|
|
if ("${PatchString}" MATCHES "^\\.([0-9]+)(.*)$")
|
|
set(Patch "${CMAKE_MATCH_1}")
|
|
else()
|
|
set(Patch 0)
|
|
endif()
|
|
math(EXPR VersionInt "(${Major}*100+${Minor})*100+${Patch}")
|
|
set(${VersionIntVar} ${VersionInt} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
# A handy function to add the current source directory to a local
|
|
# filename. To be used for creating a list of sources.
|
|
function(convert_filenames_to_full_paths NAMES)
|
|
unset(tmp_names)
|
|
foreach(name ${${NAMES}})
|
|
list(APPEND tmp_names ${CMAKE_CURRENT_SOURCE_DIR}/${name})
|
|
endforeach()
|
|
set(${NAMES} ${tmp_names} PARENT_SCOPE)
|
|
endfunction()
|
|
|
|
# Auxiliary function, used in dgtd_find_package().
|
|
function(dgtd_find_component Prefix DirVar IncSuffixes Header LibSuffixes Lib
|
|
IncDoc LibDoc)
|
|
|
|
if (Lib)
|
|
if (${DirVar} OR EnvDirVar)
|
|
find_library(${Prefix}_LIBRARY ${Lib}
|
|
HINTS ${${DirVar}} ENV ${DirVar}
|
|
PATH_SUFFIXES ${LibSuffixes}
|
|
NO_DEFAULT_PATH
|
|
DOC "${LibDoc}")
|
|
endif()
|
|
find_library(${Prefix}_LIBRARY ${Lib}
|
|
PATH_SUFFIXES ${LibSuffixes}
|
|
DOC "${LibDoc}")
|
|
endif()
|
|
|
|
if (Header)
|
|
if (${DirVar} OR EnvDirVar)
|
|
find_path(${Prefix}_INCLUDE_DIR ${Header}
|
|
HINTS ${${DirVar}} ENV ${DirVar}
|
|
PATH_SUFFIXES ${IncSuffixes}
|
|
NO_DEFAULT_PATH
|
|
DOC "${IncDoc}")
|
|
endif()
|
|
find_path(${Prefix}_INCLUDE_DIR ${Header}
|
|
PATH_SUFFIXES ${IncSuffixes}
|
|
DOC "${IncDoc}")
|
|
endif()
|
|
|
|
endfunction(dgtd_find_component)
|
|
|