diff options
author | Cyrille Berger Skott <cyb@lepi.org> | 2009-07-05 14:04:26 +0000 |
---|---|---|
committer | Cyrille Berger Skott <cyb@lepi.org> | 2009-07-05 14:04:26 +0000 |
commit | a513aa5bcd0bd58344a102f1e54376f6f40e2d76 (patch) | |
tree | 581d046be911afa3c31f70f08a73d693ae06086a /modules | |
parent | 6f621faba414c1c0b0398a1a68194a451f545fc6 (diff) | |
download | extra-cmake-modules-a513aa5bcd0bd58344a102f1e54376f6f40e2d76.tar.gz extra-cmake-modules-a513aa5bcd0bd58344a102f1e54376f6f40e2d76.tar.bz2 |
Find lcms version using a regexp, instead of compiling a program.
svn path=/trunk/KDE/kdelibs/; revision=991725
Diffstat (limited to 'modules')
-rw-r--r-- | modules/FindLCMS.cmake | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/modules/FindLCMS.cmake b/modules/FindLCMS.cmake index cbb6b179..92604e3d 100644 --- a/modules/FindLCMS.cmake +++ b/modules/FindLCMS.cmake @@ -8,6 +8,7 @@ # Copyright (c) 2008, Adrian Page, <adrian@pagenet.plus.com> +# Copyright (c) 2009, Cyrille Berger, <cberger@cberger.net> # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. @@ -17,7 +18,7 @@ # in the FIND_PATH() and FIND_LIBRARY() calls if(NOT WIN32) find_package(PkgConfig) - pkg_check_modules(PC_LCMS QUIET lcms) + pkg_check_modules(PC_LCMS lcms) set(LCMS_DEFINITIONS ${PC_LCMS_CFLAGS_OTHER}) endif(NOT WIN32) @@ -42,34 +43,22 @@ else(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES) endif(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES) if(LCMS_FOUND) - set(FIND_LCMS_VERSION_SOURCE - "#include <lcms.h>\n int main()\n {\n return LCMS_VERSION;\n }\n") - set(FIND_LCMS_VERSION_SOURCE_FILE ${CMAKE_BINARY_DIR}/CMakeTmp/FindLCMS.cxx) - file(WRITE "${FIND_LCMS_VERSION_SOURCE_FILE}" "${FIND_LCMS_VERSION_SOURCE}") - - set(FIND_LCMS_VERSION_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${LCMS_INCLUDE_DIR}") - - try_run(LCMS_VERSION LCMS_COMPILE_RESULT - ${CMAKE_BINARY_DIR} - ${FIND_LCMS_VERSION_SOURCE_FILE} - CMAKE_FLAGS "${FIND_LCMS_VERSION_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - - if(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN) + file(READ ${LCMS_INCLUDE_DIR}/lcms.h LCMS_VERSION_CONTENT) + string(REGEX MATCH "#define LCMS_VERSION[ ]*[0-9]*\n" LCMS_VERSION_MATCH ${LCMS_VERSION_CONTENT}) + if(LCMS_VERSION_MATCH) + message(STATUS "hello") + string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" LCMS_VERSION ${LCMS_VERSION_MATCH}) if(NOT LCMS_FIND_QUIETLY) string(SUBSTRING ${LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION) string(SUBSTRING ${LCMS_VERSION} 1 2 LCMS_MINOR_VERSION) message(STATUS "Found lcms version ${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}, ${LCMS_LIBRARIES}") endif(NOT LCMS_FIND_QUIETLY) - else(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN) + else(LCMS_VERSION_MATCH) if(NOT LCMS_FIND_QUIETLY) message(STATUS "Found lcms but failed to find version ${LCMS_LIBRARIES}") - file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Find lcms version failed with the following output:\n${OUTPUT}\nFindLCMS.cxx:\n${FIND_LCMS_VERSION_SOURCE}\n\n") endif(NOT LCMS_FIND_QUIETLY) set(LCMS_VERSION NOTFOUND) - endif(LCMS_COMPILE_RESULT AND NOT LCMS_VERSION STREQUAL FAILED_TO_RUN) + endif(LCMS_VERSION_MATCH) else(LCMS_FOUND) if(NOT LCMS_FIND_QUIETLY) if(LCMS_FIND_REQUIRED) |