Reputation: 18153
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.
Upvotes: 1
Views: 5763
Reputation:
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.
cmake_minimum_required(VERSION 2.8)
project(foo)
install(
DIRECTORY
"./src"
DESTINATION
"include/foo"
FILES_MATCHING
PATTERN
"*.hpp"
)
> 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
Upvotes: 6