Move definition of configure_sources CMake function to utils module.

This commit is contained in:
Andreas Schuh 2013-08-01 00:17:53 +01:00
parent ffbc1cea57
commit 2ec91bffad
2 changed files with 17 additions and 23 deletions

View file

@ -114,19 +114,6 @@ else ()
set (__ATTRIBUTE__UNUSED)
endif ()
function (configure_sources out)
set (tmp)
foreach (src IN LISTS ARGN)
if (src MATCHES ".h$" AND EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in")
configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}" @ONLY)
list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}")
else ()
list (APPEND tmp "${PROJECT_SOURCE_DIR}/src/${src}")
endif ()
endforeach ()
set (${out} "${tmp}" PARENT_SCOPE)
endfunction ()
configure_sources (PUBLIC_HDRS ${PUBLIC_HDRS})
configure_sources (PRIVATE_HDRS ${PRIVATE_HDRS})
configure_sources (GFLAGS_SRCS ${GFLAGS_SRCS})

View file

@ -1,15 +1,7 @@
## @file utils.cmake
# @brief Utility CMake functions.
## Utility CMake functions.
# ----------------------------------------------------------------------------
## @brief Extract version numbers from version string.
#
# @param [in] VERSION Version string in the format "MAJOR[.MINOR[.PATCH]]".
# @param [out] MAJOR Major version number if given or 0.
# @param [out] MINOR Minor version number if given or 0.
# @param [out] PATCH Patch number if given or 0.
#
# @returns See @c [out] parameters.
## Extract version numbers from version string.
function (version_numbers VERSION MAJOR MINOR PATCH)
if (VERSION MATCHES "([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(rc[1-9][0-9]*|[a-z]+)?")
if (CMAKE_MATCH_1)
@ -38,3 +30,18 @@ function (version_numbers VERSION MAJOR MINOR PATCH)
set ("${MINOR}" "${VERSION_MINOR}" PARENT_SCOPE)
set ("${PATCH}" "${VERSION_PATCH}" PARENT_SCOPE)
endfunction ()
# ----------------------------------------------------------------------------
## Configure source files with .in suffix
function (configure_sources out)
set (tmp)
foreach (src IN LISTS ARGN)
if (src MATCHES ".h$" AND EXISTS "${PROJECT_SOURCE_DIR}/src/${src}.in")
configure_file ("${PROJECT_SOURCE_DIR}/src/${src}.in" "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}" @ONLY)
list (APPEND tmp "${PROJECT_BINARY_DIR}/include/${GFLAGS_NAMESPACE}/${src}")
else ()
list (APPEND tmp "${PROJECT_SOURCE_DIR}/src/${src}")
endif ()
endforeach ()
set (${out} "${tmp}" PARENT_SCOPE)
endfunction ()