[CMake] REGEX REPLACE help

Petr Kmoch petr.kmoch at gmail.com
Tue Mar 19 04:19:49 EDT 2013


Hi all,

I've recently found a nice site for regex trouble: http://regexpal.com/

Maybe you can find it useful.

Petr

On Mon, Mar 18, 2013 at 7:48 PM, Andreas Schneider <asn at cryptomilk.org> wrote:
> On Monday 18 March 2013 18:00:29 David Cole wrote:
>> Use “^.*” at the beginning of the regex and “.*$” at the end of it.
>>
>>
>>
>> The ^ and $ anchor the beginning and end of the input string in CMake, not
>> the beginning and end of a line.
>
> Ok, so it needs to look like this:
>
> +# openjdk
> +find_program(JAVA_EXE java)
> +if (JAVA_EXE)
> +    execute_process(
> +        COMMAND ${JAVA_EXE} -XshowSettings:properties
> +        OUTPUT_QUIET
> +        ERROR_VARIABLE __JAVA_SETTINGS
> +        ERROR_STRIP_TRAILING_WHITESPACE
> +    )
> +
> +    string(REPLACE "\n" ";" _JAVA_SETTINGS_LIST "${__JAVA_SETTINGS}")
> +    foreach (_line ${_JAVA_SETTINGS_LIST})
> +        if ("${_line}" MATCHES ".*java.home")
> +            string(REGEX REPLACE "^ *java.home = (.+)/jre$" "\\1"
> _JAVA_PROPERTIES_HOME "${_line}")
> +        endif()
> +    endforeach()
> +endif()
>
> --
> Andreas Schneider                   GPG-ID: F33E3FC6
> www.cryptomilk.org                asn at cryptomilk.org
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list