diff --git a/ports/duktape/portfile.cmake b/ports/duktape/portfile.cmake index 84278616c6c..14934a31a93 100644 --- a/ports/duktape/portfile.cmake +++ b/ports/duktape/portfile.cmake @@ -8,11 +8,13 @@ vcpkg_download_distfile(ARCHIVE_FILE ) vcpkg_extract_source_archive(${ARCHIVE_FILE}) -# Patch duk_config.h to remove 'undef DUK_F_DLL_BUILD' -vcpkg_apply_patches( - SOURCE_PATH ${SOURCE_PATH} - PATCHES "${CMAKE_CURRENT_LIST_DIR}/duk_config.h.patch" -) +if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + # Patch duk_config.h to remove 'undef DUK_F_DLL_BUILD' + vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/duk_config.h.patch" + ) +endif() vcpkg_configure_cmake( SOURCE_PATH ${CMAKE_PATH} @@ -21,6 +23,13 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +# Revert duk_config.h to its original state +# This is always done in case the file has already been previously patched +set(DUK_CONFIG_H_PATH "${CURRENT_PACKAGES_DIR}/include/duk_config.h") +file(READ ${DUK_CONFIG_H_PATH} CONTENT) +string(REPLACE "// #undef DUK_F_DLL_BUILD" "#undef DUK_F_DLL_BUILD" CONTENT "${CONTENT}") +file(WRITE ${DUK_CONFIG_H_PATH} "${CONTENT}") + # Remove debug include file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)