Regular expression in CMake install command

Amani

I have a folder with mixed source (.cpp) and header (.h and .hpp) files. How do I write a regex expression in the CMake install command for installing only header files into a specific destination?

My search for an example on how to use a regex expression in the CMake install command did not succeed.

user2288008

From install documentation:

The FILES_MATCHING option may be given before the first match option to disable installation of files (but not directories) not matched by any expression.

Usage

cmake_minimum_required(VERSION 2.8)
project(foo)

install(
    DIRECTORY
    "./src"
    DESTINATION
    "include/foo"
    FILES_MATCHING
    PATTERN
    "*.hpp"
)

Example

> cmake -H. -B_builds -DCMAKE_INSTALL_PREFIX=`pwd`/_install
> cmake --build _builds/ --target install
> find src/ -type f
src/a.hpp
src/a.cpp
src/B/b.hpp
src/B/b.cpp

Only *.hpp files installed:

> find _install/ -type f
_install/include/foo/src/a.hpp
_install/include/foo/src/B/b.hpp

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Version regular expression in CMake

From Dev

Version regular expression in CMake

From Dev

Regular Expression in Find command

From Dev

sed command with regular expression

From Dev

cmake - error in compile regular expression

From Dev

PASS_REGULAR_EXPRESSION in CMake

From Dev

understand Regular expression in a sed command

From Dev

Regular expression to parse AT command response

From Dev

grep with regular expression in command line

From Dev

find command from regular expression

From Dev

Regular expression find command cygwin?

From Dev

Regular Expression Match to Extract Command

From Dev

Regular expression help in context of locate command

From Dev

How to pass regular expression to the command find in Linux?

From Dev

Convert command line arguments to regular expression

From Dev

Regular Expression ^$ not working on UNIX using grep command

From Dev

regular expression search within command less

From Dev

Using a regular expression with zip command for directory exclusions

From Dev

Regular expression to print a string from a command outpout

From Dev

Regular expression not matching correctly in sed command

From Dev

Is there a cross-platform CMake command to install a project?

From Dev

CMake: How to execute a command before make install?

From Dev

python regular expression replace two situations with one command

From Dev

How can I match parameters in command line with one regular expression?

From Dev

Non-greedy regular expression to convert command tags

From Dev

How do I add a regular expression to a mapping command in vim?

From Dev

Why regular expression doesn't match input with sed command

From Dev

Why is the hyphen symbol - not discoverable in a regular expression in the find command?

From Dev

Regular Expression: Get digit from the ping command output

Related Related

  1. 1

    Version regular expression in CMake

  2. 2

    Version regular expression in CMake

  3. 3

    Regular Expression in Find command

  4. 4

    sed command with regular expression

  5. 5

    cmake - error in compile regular expression

  6. 6

    PASS_REGULAR_EXPRESSION in CMake

  7. 7

    understand Regular expression in a sed command

  8. 8

    Regular expression to parse AT command response

  9. 9

    grep with regular expression in command line

  10. 10

    find command from regular expression

  11. 11

    Regular expression find command cygwin?

  12. 12

    Regular Expression Match to Extract Command

  13. 13

    Regular expression help in context of locate command

  14. 14

    How to pass regular expression to the command find in Linux?

  15. 15

    Convert command line arguments to regular expression

  16. 16

    Regular Expression ^$ not working on UNIX using grep command

  17. 17

    regular expression search within command less

  18. 18

    Using a regular expression with zip command for directory exclusions

  19. 19

    Regular expression to print a string from a command outpout

  20. 20

    Regular expression not matching correctly in sed command

  21. 21

    Is there a cross-platform CMake command to install a project?

  22. 22

    CMake: How to execute a command before make install?

  23. 23

    python regular expression replace two situations with one command

  24. 24

    How can I match parameters in command line with one regular expression?

  25. 25

    Non-greedy regular expression to convert command tags

  26. 26

    How do I add a regular expression to a mapping command in vim?

  27. 27

    Why regular expression doesn't match input with sed command

  28. 28

    Why is the hyphen symbol - not discoverable in a regular expression in the find command?

  29. 29

    Regular Expression: Get digit from the ping command output

HotTag

Archive