mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-28 03:36:40 +08:00
38acea0c4c
* [freexl] Update to 2.0.0 * Skip tests, examples * [minizip] Build DLL * [libspatialite] Update to 5.1.0 * Fix utf8 source * [spatialite-tools] Update to 5.1.0a * [libkml] Update minizip prefix * [libkml] Fix all minizip names
41 lines
1.7 KiB
CMake
41 lines
1.7 KiB
CMake
function(lib_to_def)
|
|
if(NOT VCPKG_TARGET_IS_WINDOWS OR VCPKG_TARGET_IS_MINGW OR NOT VCPKG_LIBRARY_LINKAGE STREQUAL "static")
|
|
return()
|
|
endif()
|
|
|
|
cmake_parse_arguments(PARSE_ARGV 0 arg "" "BASENAME;REGEX" "")
|
|
if(NOT arg_BASENAME)
|
|
message(FATAL_ERROR "BASENAME is a required argument.")
|
|
endif()
|
|
if(NOT arg_REGEX)
|
|
set(arg_REGEX "[^ ]+")
|
|
endif()
|
|
|
|
set(logfile "${CURRENT_BUILDTREES_DIR}/dumpbin-${arg_BASENAME}-${TARGET_TRIPLET}-symbols.log")
|
|
vcpkg_execute_required_process(
|
|
COMMAND dumpbin /symbols "/OUT:${logfile}" "${CURRENT_PACKAGES_DIR}/lib/${arg_BASENAME}.lib"
|
|
WORKING_DIRECTORY "${CURRENT_BUILDTREES_DIR}"
|
|
LOGNAME "dumpbin-${arg_BASENAME}-${TARGET_TRIPLET}"
|
|
)
|
|
file(STRINGS "${logfile}" symbols REGEX "^... ........ SECT.. notype .. External [|] ${arg_REGEX}")
|
|
list(TRANSFORM symbols REPLACE "^[^|]+[|] " " ")
|
|
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
|
|
string(REPLACE " _" " " symbols "${symbols}")
|
|
endif()
|
|
list(JOIN symbols "\n" symbols)
|
|
set(symbols "EXPORTS\n${symbols}\n")
|
|
set(def_file "${CMAKE_CURRENT_LIST_DIR}/${arg_BASENAME}-${VCPKG_TARGET_ARCHITECTURE}.def")
|
|
if(NOT EXISTS "${def_file}")
|
|
set(def_file "${CMAKE_CURRENT_LIST_DIR}/${arg_BASENAME}-win32.def")
|
|
endif()
|
|
if(EXISTS "${def_file}")
|
|
file(READ "${def_file}" original_symbols)
|
|
else()
|
|
set(original_symbols "")
|
|
endif()
|
|
if(NOT symbols STREQUAL original_symbols)
|
|
file(WRITE "${CURRENT_BUILDTREES_DIR}/${arg_BASENAME}-${VCPKG_TARGET_ARCHITECTURE}.def.log" "${symbols}")
|
|
message(SEND_ERROR "${arg_BASENAME}-${VCPKG_TARGET_ARCHITECTURE}.def has changed.")
|
|
endif()
|
|
endfunction()
|