cmake: cmake < 2.6 doesn't know FILE(STRINGS ...)

This commit is contained in:
Michael Gehring 2008-06-21 15:10:51 +02:00
parent 452b89d6ec
commit f231e8496a
2 changed files with 17 additions and 4 deletions

View File

@ -130,11 +130,23 @@ ADD_DEPENDENCIES(${PROJECT_AWE_NAME} generated_headers)
IF(GENERATE_MANPAGES)
MACRO(a_file_match infile regex result_var)
FILE(STRINGS ${infile} matches REGEX ${regex} LIMIT_COUNT 1)
IF(matches)
SET(${result_var} TRUE)
IF(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION LESS 6)
# cmake < 2.6 doesn't know FILE(STRINGS ...)
EXECUTE_PROCESS(COMMAND ${GREP_EXECUTABLE} -l ${regex} ${infile}
RESULT_VARIABLE exit_code
OUTPUT_QUIET)
IF(exit_code EQUAL 0)
SET(${result_var} TRUE)
ELSE()
SET(${result_var} FALSE)
ENDIF()
ELSE()
SET(${result_var} FALSE)
FILE(STRINGS ${infile} match REGEX ${regex} LIMIT_COUNT 1)
IF(match)
SET(${result_var} TRUE)
ELSE()
SET(${result_var} FALSE)
ENDIF()
ENDIF()
ENDMACRO()

View File

@ -23,6 +23,7 @@ ADD_DEFINITIONS(-std=gnu99 -ggdb3 -fno-strict-aliasing -Wall -Wextra
# {{{ Find external utilities
FIND_PROGRAM(CAT_EXECUTABLE cat)
FIND_PROGRAM(GREP_EXECUTABLE grep)
FIND_PROGRAM(GIT_EXECUTABLE git)
FIND_PROGRAM(LUA_EXECUTABLE lua)
# programs needed for man pages