Created
November 28, 2015 12:47
-
-
Save alepez/537d8bc0b7ef94dcd3da to your computer and use it in GitHub Desktop.
cmake copy headers with regex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.3) | |
project(xxx) | |
file(GLOB_RECURSE Headers ${CMAKE_SOURCE_DIR}/src/*.h) | |
add_custom_target(copy) | |
foreach(HEADER ${Headers}) | |
STRING(REGEX REPLACE "${CMAKE_SOURCE_DIR}/src/([^/]*)/src/(.*)$" "\\1/\\2" DST_HEADER ${HEADER}) | |
add_custom_command(TARGET copy PRE_BUILD | |
COMMAND ${CMAKE_COMMAND} -E | |
copy ${HEADER} ${CMAKE_SOURCE_DIR}/dist/${DST_HEADER}) | |
endforeach() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment