diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-05-02 20:34:11 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-05-03 04:12:28 -0700 |
| commit | 4633c5e0ea8560ac17c14aa56e50bf3693017f51 (patch) | |
| tree | 543c1994c5b9b244bb3a9517fd4dfbde389afffc /scripts/cmake/vcpkg_fixup_cmake_targets.cmake | |
| parent | f10861fa7af9bd675cb4e80ea31d85d7e5c6d906 (diff) | |
| download | vcpkg-4633c5e0ea8560ac17c14aa56e50bf3693017f51.tar.gz vcpkg-4633c5e0ea8560ac17c14aa56e50bf3693017f51.zip | |
[vcpkg] Add support for installing from HEAD
Diffstat (limited to 'scripts/cmake/vcpkg_fixup_cmake_targets.cmake')
| -rw-r--r-- | scripts/cmake/vcpkg_fixup_cmake_targets.cmake | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/cmake/vcpkg_fixup_cmake_targets.cmake b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake new file mode 100644 index 000000000..c2829be7e --- /dev/null +++ b/scripts/cmake/vcpkg_fixup_cmake_targets.cmake @@ -0,0 +1,47 @@ +#.rst: +# .. command:: vcpkg_fixup_cmake_targets +# +# Transform all /debug/share/<port>/*targets-debug.cmake files and move them to /share/<port>. +# Removes all /debug/share/<port>/*targets.cmake and /debug/share/<port>/*config.cmake +# +# :: +# vcpkg_fixup_cmake_targets() +# + +function(vcpkg_fixup_cmake_targets) + cmake_parse_arguments(_vfct "" "" "" ${ARGN}) + + set(DEBUG_SHARE ${CURRENT_PACKAGES_DIR}/debug/share/${PORT}) + set(RELEASE_SHARE ${CURRENT_PACKAGES_DIR}/share/${PORT}) + + if(NOT EXISTS ${DEBUG_SHARE}) + message(FATAL_ERROR "'${DEBUG_SHARE}' does not exist") + endif() + + file(GLOB UNUSED_FILES "${DEBUG_SHARE}/*[Tt]argets.cmake" "${DEBUG_SHARE}/*[Cc]onfig.cmake") + file(REMOVE ${UNUSED_FILES}) + + file(GLOB DEBUG_TARGETS "${DEBUG_SHARE}/*[Tt]argets-debug.cmake") + + foreach(DEBUG_TARGET ${DEBUG_TARGETS}) + get_filename_component(DEBUG_TARGET_NAME ${DEBUG_TARGET} NAME) + + file(READ ${DEBUG_TARGET} _contents) + string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" _contents "${_contents}") + file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/${DEBUG_TARGET_NAME} "${_contents}") + + file(REMOVE ${DEBUG_TARGET}) + endforeach() + + # Remove /debug/share/<port>/ if it's empty. + file(GLOB_RECURSE REMAINING_FILES "${DEBUG_SHARE}/*") + if(NOT REMAINING_FILES) + file(REMOVE_RECURSE ${DEBUG_SHARE}) + endif() + + # Remove /debug/share/ if it's empty. + file(GLOB_RECURSE REMAINING_FILES "${CURRENT_PACKAGES_DIR}/debug/share/*") + if(NOT REMAINING_FILES) + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) + endif() +endfunction() |
