Incorrect regex in Cmake rule

Viewed 21

I want to exclude only one absolute path from the returned runtime dependencies list. I use regex for that, but I can't figure out CMake's regex format. It works in the online checkers, but it doesn't in the Cmake.

How to exclude only this path "/lib64"?

The code below:

install(CODE [[
      file(GET_RUNTIME_DEPENDENCIES
        EXECUTABLES $<TARGET_FILE:myApp1> $<TARGET_FILE:myApp2> $<TARGET_FILE:myApp3>
        RESOLVED_DEPENDENCIES_VAR RESOLVED_DEPS
        UNRESOLVED_DEPENDENCIES_VAR UNRESOLVED_DEPS
        CONFLICTING_DEPENDENCIES_PREFIX CONFLICTING_DEPENDENCIES
        POST_EXCLUDE_REGEXES "^(\/lib64)$"
      )
...
]]

Produces a warning:

  when parsing string

    ^(\/lib64)$

  Invalid escape sequence \/

If I change it to "^(/lib64)$" - it just does not excludes it...

1 Answers

I guess you want to exclude files in that directory; so you probably want something like "^/lib64/[^/]*$"

The [^/]*$ part is superfluous if you want to match subdirectories, too; then just matching on the prefix "^/lib64/" should be sufficient.

Related