[CMake] REGEX REPLACE help
Andreas Schneider
asn at cryptomilk.org
Mon Mar 18 14:48:29 EDT 2013
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
More information about the CMake
mailing list