From f231e8496a74df40893d2b73bf8d975c57fd7bd3 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sat, 21 Jun 2008 15:10:51 +0200 Subject: [PATCH] cmake: cmake < 2.6 doesn't know FILE(STRINGS ...) --- CMakeLists.txt | 20 ++++++++++++++++---- awesomeConfig.cmake | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab57db982..ab50b12a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/awesomeConfig.cmake b/awesomeConfig.cmake index 0d16c5bee..345c4c16d 100644 --- a/awesomeConfig.cmake +++ b/awesomeConfig.cmake @@ -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