Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy all files with given extension to output directory using CMake

Tags:

copy

cmake

I've seen that I can use this command in order to copy a directory using cmake:

file(COPY "myDir" DESTINATION "myDestination") 

(from this post)

My problem is that I don't want to copy all of myDir, but only the .h files that are in there. I've tried with

file(COPY "myDir/*.h" DESTINATION "myDestination") 

but I obtain the following error:

CMake Error at CMakeLists.txt:23 (file):   file COPY cannot find   "/full/path/to/myDIR/*.h". 

How can I filter the files that I want to copy to a destination folder?

like image 550
Jepessen Avatar asked Jun 19 '14 16:06

Jepessen


People also ask

What does Add_subdirectory do in CMake?

Add a subdirectory to the build. Adds a subdirectory to the build. The source_dir specifies the directory in which the source CMakeLists.

What is CMakeLists txt?

CMakeLists. txt file contains a set of directives and instructions describing the project's source files and targets (executable, library, or both). When you create a new project, CLion generates CMakeLists. txt file automatically and places it in the project root directory.

What is .CMake file?

CMake is an open-source, cross-platform tool that uses compiler and platform independent configuration files to generate native build tool files specific to your compiler and platform. The CMake Tools extension integrates Visual Studio Code and CMake to make it easy to configure, build, and debug your C++ project.


1 Answers

I've found the solution by myself:

file(GLOB MY_PUBLIC_HEADERS   "myDir/*.h" ) file(COPY ${MY_PUBLIC_HEADERS} DESTINATION myDestination) 
like image 61
Jepessen Avatar answered Sep 19 '22 03:09

Jepessen