Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
21d9c65
reduce pipeline load
Neumann-A Jul 11, 2022
2211d43
post/pre portfile includes
Neumann-A Jul 11, 2022
d09d5c7
trying to add Zi
Neumann-A Jul 11, 2022
de92c9e
cmake_language magic to inject install rules
Neumann-A Jul 11, 2022
c90ddc0
Zi magic.
Neumann-A Jul 11, 2022
7f95bec
don't use bin dir in static builds
Neumann-A Jul 11, 2022
5409c28
make sure pdbs exist before installing them
Neumann-A Jul 11, 2022
77f562c
Fix parallel link jobs with meson ports. (cannot run parallel link jo…
Neumann-A Jul 11, 2022
664e2fe
only one link job at a time for cmake
Neumann-A Jul 11, 2022
b27e945
use job pools correctly
Neumann-A Jul 12, 2022
8bc387a
try fixing boost-build
Neumann-A Jul 12, 2022
5a5b2cc
not possible to trick b2 with invalid values
Neumann-A Jul 12, 2022
468ed0a
actually use regex replace ;) [skip actions]
Neumann-A Jul 12, 2022
8b0f4f0
fix openssl (already uses pdbs)
Neumann-A Jul 13, 2022
2f4001b
disable pch in boost since it seems to be broken in most cases.
Neumann-A Jul 13, 2022
2300d5b
use console instead of a new job pool (some ports seem to choke on that)
Neumann-A Jul 13, 2022
3f916c8
WIP commit
Neumann-A Jul 14, 2022
557db4d
pdb stuff
Neumann-A Jul 15, 2022
87dd582
WIP [skip actions]
Neumann-A Jul 15, 2022
d6bdf1d
WIP cleanup [skip actions]
Neumann-A Jul 15, 2022
271ef80
more WIP [skip actions]
Neumann-A Jul 16, 2022
2408612
pdb testrun
Neumann-A Jul 17, 2022
c558376
make sure /Z7 is only added for targets without assembly
Neumann-A Jul 17, 2022
d868304
bit of refactor and fixing boost-build
Neumann-A Jul 18, 2022
9470123
fix additional regex characters
Neumann-A Jul 18, 2022
6423c89
fix protobuf
Neumann-A Jul 18, 2022
7b1f89e
filter files
Neumann-A Jul 18, 2022
06762ab
crashpad don't include toolchain
Neumann-A Jul 18, 2022
8494ba4
build nmkae don't include toolchain
Neumann-A Jul 18, 2022
aa85d23
fix already installed search
Neumann-A Jul 18, 2022
1ff1a87
fix typo
Neumann-A Jul 18, 2022
c688169
minor fixes to the boost build helper
Neumann-A Jul 19, 2022
9f5d571
v db
Neumann-A Jul 19, 2022
262385c
Merge remote-tracking branch 'upstream/master' into fix_zi_in_boost_b…
Neumann-A Jul 20, 2022
93ce164
Merge remote-tracking branch 'upstream/master' into try_to_use_Zi
Neumann-A Jul 26, 2022
557298e
Merge remote-tracking branch 'origin/fix_zi_in_boost_build' into try_…
Neumann-A Jul 26, 2022
fdbf37f
fix copying of pdbs in boost-* ports
Neumann-A Jul 26, 2022
33d6a0a
Merge remote-tracking branch 'origin/master' into try_to_use_Zi
Osyotr Dec 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ __pycache__/
!/triplets/x64-uwp.cmake
!/triplets/x64-windows-static.cmake
!/triplets/x64-windows.cmake
!/triplets/move_pdb_files.cmake
!/triplets/x86-windows.cmake

!/triplets/community
Expand Down
2 changes: 1 addition & 1 deletion scripts/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parameters:
- name: tripletPattern
displayName: 'Enable triplets which contain this substring (^ matches begin, $ matches end)'
type: string
default: '^'
default: '^x64-windows$'

jobs:
- template: windows/azure-pipelines.yml
Expand Down
Empty file modified scripts/cmake/vcpkg_build_nmake.cmake
100755 → 100644
Empty file.
45 changes: 1 addition & 44 deletions scripts/cmake/vcpkg_copy_pdbs.cmake
Original file line number Diff line number Diff line change
@@ -1,49 +1,6 @@
function(vcpkg_copy_pdbs)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "" "BUILD_PATHS")

if(DEFINED arg_UNPARSED_ARGUMENTS)
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

if(NOT DEFINED arg_BUILD_PATHS)
set(arg_BUILD_PATHS
"${CURRENT_PACKAGES_DIR}/bin/*.dll"
"${CURRENT_PACKAGES_DIR}/debug/bin/*.dll"
)
endif()

set(dlls_without_matching_pdbs "")

if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
file(GLOB_RECURSE dlls ${arg_BUILD_PATHS})

set(vslang_backup "$ENV{VSLANG}")
set(ENV{VSLANG} 1033)

foreach(dll IN LISTS dlls)
execute_process(COMMAND dumpbin /PDBPATH "${dll}"
COMMAND findstr PDB
OUTPUT_VARIABLE pdb_line
ERROR_QUIET
RESULT_VARIABLE error_code
)

if(error_code EQUAL "0" AND pdb_line MATCHES "PDB[^/]*(([A-Za-z]:|/).*\\.[Pp][Dd][Bb])")
set(pdb_path "${CMAKE_MATCH_1}")
cmake_path(GET dll PARENT_PATH dll_dir)
file(COPY "${pdb_path}" DESTINATION "${dll_dir}")
else()
list(APPEND dlls_without_matching_pdbs "${dll}")
endif()
endforeach()

set(ENV{VSLANG} "${vslang_backup}")

if(NOT dlls_without_matching_pdbs STREQUAL "")
list(JOIN dlls_without_matching_pdbs "\n " message)
message(WARNING "Could not find a matching pdb file for:
${message}\n")
endif()
endif()
message(STATUS "${CMAKE_CURRENT_FUNCTION} is deprecated. Please remove the call from the portfile!")

endfunction()
76 changes: 70 additions & 6 deletions scripts/toolchains/windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,84 @@ if(NOT _VCPKG_WINDOWS_TOOLCHAIN)
set(MP_BUILD_FLAG "/MP ")
endif()

set(CMAKE_CXX_FLAGS " /nologo /DWIN32 /D_WINDOWS ${CHARSET_FLAG} /GR /EHsc ${MP_BUILD_FLAG}${VCPKG_CXX_FLAGS}" CACHE STRING "")
set(CMAKE_C_FLAGS " /nologo /DWIN32 /D_WINDOWS ${CHARSET_FLAG} ${MP_BUILD_FLAG}${VCPKG_C_FLAGS}" CACHE STRING "")
set(CMAKE_CXX_FLAGS " /nologo /Brepro /DWIN32 /D_WINDOWS ${CHARSET_FLAG} /GR /EHsc ${MP_BUILD_FLAG} ${VCPKG_CXX_FLAGS}" CACHE STRING "")
set(CMAKE_C_FLAGS " /nologo /Brepro /DWIN32 /D_WINDOWS ${CHARSET_FLAG} ${MP_BUILD_FLAG} ${VCPKG_C_FLAGS}" CACHE STRING "")

if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64ec")
string(APPEND CMAKE_CXX_FLAGS " /arm64EC /D_AMD64_ /DAMD64 /D_ARM64EC_ /DARM64EC")
string(APPEND CMAKE_C_FLAGS " /arm64EC /D_AMD64_ /DAMD64 /D_ARM64EC_ /DARM64EC")
endif()
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "")

set(CMAKE_CXX_FLAGS_DEBUG "${VCPKG_CRT_LINK_FLAG_PREFIX}d /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" CACHE STRING "")
set(CMAKE_C_FLAGS_DEBUG "${VCPKG_CRT_LINK_FLAG_PREFIX}d /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}" CACHE STRING "")
set(CMAKE_C_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}" CACHE STRING "")
if(BUILD_SHARED_LIBS)
set(VCPKG_DBG_FLAGS "/Zi /FS")
else()
set(VCPKG_DBG_FLAGS "/Z7")
endif()

set(CMAKE_CXX_FLAGS_DEBUG "${VCPKG_CRT_LINK_FLAG_PREFIX}d ${VCPKG_DBG_FLAGS} /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" CACHE STRING "")
set(CMAKE_C_FLAGS_DEBUG "${VCPKG_CRT_LINK_FLAG_PREFIX}d ${VCPKG_DBG_FLAGS} /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_DBG_FLAGS} ${VCPKG_CXX_FLAGS_RELEASE}" CACHE STRING "")
set(CMAKE_C_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_DBG_FLAGS} ${VCPKG_C_FLAGS_RELEASE}" CACHE STRING "")

get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_SHARED_LINKER_FLAGS " /PDBALTPATH:%_PDB%")
string(APPEND CMAKE_EXE_LINKER_FLAGS " /PDBALTPATH:%_PDB%")

function(z_vcpkg_install_pdbs)
# from https://stackoverflow.com/a/62311397
# changed to not add an empty element add the end of the list and adjusted to vcpkg policies.
function(get_all_targets var)
set(targets "")
get_all_targets_recursive(targets "${CMAKE_CURRENT_SOURCE_DIR}")
set("${var}" "${targets}" PARENT_SCOPE)
endfunction()

macro(get_all_targets_recursive targets dir)
get_property(subdirectories DIRECTORY "${dir}" PROPERTY SUBDIRECTORIES)
foreach(subdir IN LISTS subdirectories)
get_all_targets_recursive("${targets}" "${subdir}")
endforeach()
get_property(current_targets DIRECTORY "${dir}" PROPERTY BUILDSYSTEM_TARGETS)
if(current_targets)
list(APPEND "${targets}" "${current_targets}")
endif()
endmacro()

get_all_targets(build_targets)
#get_directory_property(build_targets DIRECTORY "${CMAKE_SOURCE_DIR}" BUILDSYSTEM_TARGETS)
message(STATUS "BUILDSYSTEM_TARGETS: ${build_targets}")
foreach(target IN LISTS build_targets)
get_target_property(type "${target}" TYPE)
if(type MATCHES "(SHARED_LIBRARY|EXECUTABLE|MODULE_LIBRARY)")
#message(STATUS "Toolchain shared pdb install: ${target}")
#install(FILES "$<TARGET_PDB_FILE:${target}>" TYPE BIN OPTIONAL)
elseif(type MATCHES "(STATIC_LIBRARY|OBJECT_LIBRARY)")
get_target_property(sources "${target}" SOURCES)
if("${sources}" MATCHES "(\\\.asm|\\\.s)")
else()
target_compile_options("${target}" PRIVATE "/Z7")
endif()
# message(STATUS "Toolchain static pdb install: ${target}")
# set(pdb_filename "$<PATH:REPLACE_EXTENSION,LAST_ONLY,$<TARGET_FILE_NAME:${target}>,*.pdb>")
#get_target_property(pdb_name "${target}" PDB_NAME)
# install(FILES "$<TARGET_FILE_DIR:${target}>/${pdb_filename}" DESTINATION "pdb" OPTIONAL)
#elseif(type MATCHES "(OBJECT_LIBRARY)")
#set(z_vcpkg_has_obj_libs ON)
#message(STATUS "Toolchain object libraries pdb install: ${target}")
#set_target_properties("${target}" PROPERTIES
# COMPILE_PDB_NAME "${VCPKG_PORT_NAME}_${target}_obj.pdb"
# COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
# )
#install(FILES "${CMAKE_BINARY_DIR}/${VCPKG_PORT_NAME}_${target}_obj.pdb" DESTINATION "pdb" OPTIONAL)
else()
message(STATUS "Toolchain no pdb installed: ${target}|${type}")
endif()
endforeach()
endfunction()
cmake_language(DEFER CALL z_vcpkg_install_pdbs)
endif()
string(APPEND CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT " /nologo ")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "/nologo /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS} ${VCPKG_LINKER_FLAGS_RELEASE}" CACHE STRING "")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/nologo /DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS} ${VCPKG_LINKER_FLAGS_RELEASE}" CACHE STRING "")
Expand Down
223 changes: 223 additions & 0 deletions triplets/move_pdb_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
set(Z_VCPKG_BUILD_PATH_RELEASE "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel")
set(Z_VCPKG_BUILD_PATH_DEBUG "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg")


function(z_vcpkg_copy_pdbs)
cmake_parse_arguments(PARSE_ARGV 0 "arg" "" "BUILD_PATH_RELEASE;BUILD_PATH_DEBUG" "")


if(DEFINED arg_UNPARSED_ARGUMENTS)
message(WARNING "${CMAKE_CURRENT_FUNCTION} was passed extra arguments: ${arg_UNPARSED_ARGUMENTS}")
endif()

file(GLOB_RECURSE rel_dlls_or_exe "${CURRENT_PACKAGES_DIR}/*.dll" "${CURRENT_PACKAGES_DIR}/*.exe")

set(dbg_dlls_or_exe "${rel_dlls_or_exe}")
list(FILTER dbg_dlls_or_exe INCLUDE REGEX "(${CURRENT_PACKAGES_DIR}/([^/]+/)*debug/)")
list(FILTER rel_dlls_or_exe EXCLUDE REGEX "(${CURRENT_PACKAGES_DIR}/([^/]+/)*debug/)")

file(GLOB_RECURSE rel_dlls_installed "${CURRENT_INSTALLED_DIR}/*.dll")
set(dbg_dlls_installed "${rel_dlls_installed}")
list(FILTER dbg_dlls_installed INCLUDE REGEX "(${CURRENT_INSTALLED_DIR}/([^/]+/)*debug/)")
list(FILTER rel_dlls_installed EXCLUDE REGEX "(${CURRENT_INSTALLED_DIR}/([^/]+/)*debug/)")

string(REGEX REPLACE "${CURRENT_INSTALLED_DIR}/([^/;]+/)*" "" rel_dlls_installed "${rel_dlls_installed}")
string(REGEX REPLACE "${CURRENT_INSTALLED_DIR}/([^/;]+/)*" "" dbg_dlls_installed "${dbg_dlls_installed}")
#string(REPLACE "." "\\\." rel_dlls_installed "${rel_dlls_installed}")
#string(REPLACE "." "\\\." dbg_dlls_installed "${dbg_dlls_installed}")
#string(REPLACE "+" "\\\+" rel_dlls_installed "${rel_dlls_installed}")
#string(REPLACE "+" "\\\+" dbg_dlls_installed "${dbg_dlls_installed}")
#string(REPLACE "*" "\\\*" rel_dlls_installed "${rel_dlls_installed}")
#string(REPLACE "*" "\\\*" dbg_dlls_installed "${dbg_dlls_installed}")
#list(JOIN rel_dlls_installed "|" rel_dlls_installed)
#list(JOIN dbg_dlls_installed "|" dbg_dlls_installed)
#list(FILTER rel_dlls_or_exe EXCLUDE REGEX "/(${rel_dlls_installed})") # This Regex will be too long for cmake to handle
#list(FILTER dbg_dlls_or_exe EXCLUDE REGEX "/(${dbg_dlls_installed})")

file(GLOB_RECURSE build_rel_pdbs "${Z_VCPKG_BUILD_PATH_RELEASE}/*.pdb")
set(build_rel_vc_pdbs "${build_rel_pdbs}")
list(FILTER build_rel_vc_pdbs INCLUDE REGEX "/[Vv][Cc][0-9]+\\\.pdb")
list(FILTER build_rel_pdbs EXCLUDE REGEX "/[Vv][Cc][0-9]+\\\.pdb")

file(GLOB_RECURSE build_dbg_pdbs "${Z_VCPKG_BUILD_PATH_DEBUG}/*.pdb")
set(build_dbg_vc_pdbs "${build_rel_pdbs}")
list(FILTER build_dbg_vc_pdbs INCLUDE REGEX "/[Vv][Cc][0-9]+\\\.pdb")
list(FILTER build_dbg_pdbs EXCLUDE REGEX "/[Vv][Cc][0-9]+\\\.pdb")

set(vslang_backup "$ENV{VSLANG}")
set(ENV{VSLANG} 1033) # to get english output from dumpbin

set(no_matching_pdbs "")
#If you specify a path name that does not include a file name (the path ends in backslash), the compiler creates a .pdb file named VCx.pdb in the specified directory.

file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}/" current_packages_native)
file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}/" current_buildtrees_native)
string(REPLACE [[\]] [[\\]] current_packages_native "${current_packages_native}")
string(REPLACE [[\]] [[\\]] current_buildtrees_native "${current_buildtrees_native}")

function(not_found dll_or_exe)
string(STRIP "${dll_or_exe}" stripped)
list(APPEND no_matching_pdbs "${stripped}")
set(no_matching_pdbs "${no_matching_pdbs}" PARENT_SCOPE)
endfunction()

function(ambigous_pdbs_found dll_or_exe found_pdbs)
message(FATAL_ERROR "More than one possible pdb for '${dll_or_exe}' found: '${found_pdbs}'! Please install the correct pdb manually!")
endfunction()

function(install_found_pdb dll_or_exe found_pdb)
cmake_path(GET dll_or_exe PARENT_PATH dll_or_exe_dir)
file(INSTALL "${found_pdb}" DESTINATION "${dll_or_exe_dir}")
set(pdb_not_found FALSE PARENT_SCOPE)
endfunction()

function(find_path_pdb_in_buildtree dll_or_exe search_pdbs found_pdbs function_found function_ambigous function_not_found)
list(LENGTH found_pdbs found_pdbs_length)
if(found_pdbs_length EQUAL "1")
cmake_language(CALL "${function_found}" "${dll_or_exe}" "${found_pdbs}")
elseif(found_pdbs_length GREATER "1")
cmake_language(CALL "${function_ambigous}" "${dll_or_exe}" "${search_pdbs}" "${found_pdbs}")
else()
cmake_language(CALL "${function_not_found}" "${dll_or_exe}" "${search_pdbs}" "${found_pdbs}")
endif()
set(no_matching_pdbs "${no_matching_pdbs}" PARENT_SCOPE)
set(pdb_not_found "${pdb_not_found}" PARENT_SCOPE)
endfunction()

function(find_ambigous_retry_1 dll_or_exe search_pdbs found_pdbs)
if(PORT MATCHES "boost-.+")
list(FILTER found_pdbs INCLUDE REGEX "/stage/lib/")
else()
list(FILTER found_pdbs INCLUDE REGEX "/\\\.libs/") # libtool build folder
endif()
find_path_pdb_in_buildtree("${dll_or_exe}" "${search_pdbs}" "${found_pdbs}" install_found_pdb ambigous_pdbs_found not_found)
set(no_matching_pdbs "${no_matching_pdbs}" PARENT_SCOPE)
set(pdb_not_found "${pdb_not_found}" PARENT_SCOPE)
endfunction()

function(find_pdb_by_name dll_or_exe search_pdbs)
cmake_path(GET pdb_path_not_found FILENAME pdb_path)
if(pdb_path MATCHES "[Vv][Cc][0-9]?[0-9][0-9]\\\.pdb")
message(FATAL_ERROR "Error cannot install pdb with generic name '${CMAKE_MATCH_O}' found in ${dll_or_exe}")
endif()
string(REPLACE [[.]] [[\.]] pdb_regex "${pdb_path}")
string(REPLACE [[+]] [[\+]] pdb_regex "${pdb_regex}")
string(REPLACE [[*]] [[\*]] pdb_regex "${pdb_regex}")
set(found_pdbs "${search_pdbs}")
list(FILTER found_pdbs INCLUDE REGEX "/${pdb_regex}")
find_path_pdb_in_buildtree("${dll_or_exe}" "${search_pdbs}" "${found_pdbs}" install_found_pdb find_ambigous_retry_1 not_found)
set(no_matching_pdbs "${no_matching_pdbs}" PARENT_SCOPE)
set(pdb_not_found "${pdb_not_found}" PARENT_SCOPE)
endfunction()

macro(analyze_dumpbin_pdbs dll_or_exe search_pdbs_var pdb_lines_var packages_subpath)
string(REGEX MATCHALL "PDB file '([^']+)'" pdb_paths_not_found "${${pdb_lines_var}}") # This will always have 4 elements
list(TRANSFORM pdb_paths_not_found REPLACE "PDB file '([^']+)'" "\\1")
cmake_path(CONVERT "${pdb_paths_not_found}" TO_CMAKE_PATH_LIST pdb_paths_not_found)
message(DEBUG "pdb_paths_not_found: ${pdb_paths_not_found}")
string(REGEX MATCHALL "PDB file found at '([^']+)'" pdb_path_found "${${pdb_lines_var}}") # This will always be just 1 element
list(TRANSFORM pdb_path_found REPLACE "PDB file found at '([^']+)'" "\\1")
cmake_path(CONVERT "${pdb_path_found}" TO_CMAKE_PATH_LIST pdb_path_found)
message(DEBUG "pdb_path_found: ${pdb_path_found}")

set(pdb_not_found TRUE)
if(pdb_path_found AND pdb_path_found MATCHES "${CURRENT_BUILDTREES_DIR}") # This is the old vcpkg behavior
message(WARNING "File: '${dll_or_exe}' encodes absolute path to a pdb to the buildtree!")
install_found_pdb("${dll_or_exe}" "${pdb_path_found}")
elseif(pdb_path_found AND NOT pdb_path_found MATCHES "${CURRENT_PACKAGES_DIR}")
message(FATAL_ERROR "PDB found outside vcpkg package dir: ${pdb_path_found}") # pdb found outside vcpkg
elseif(pdb_path_found AND pdb_path_found MATCHES "${CURRENT_PACKAGES_DIR}")
message(VERBOSE "PDB for '${dll_or_exe}' already installed at: ${pdb_path_found}")
set(pdb_not_found FALSE)
endif()

foreach(pdb_path_not_found IN LISTS pdb_paths_not_found)
if(NOT pdb_not_found)
break()
endif()
set(found_pdbs "${${search_pdbs_var}}")
string(REPLACE "${CURRENT_PACKAGES_DIR}/${packages_subpath}" "" pdb_path "${pdb_path_not_found}")
string(REPLACE [[.]] [[\.]] pdb_regex "${pdb_path}")
string(REPLACE [[+]] [[\+]] pdb_regex "${pdb_regex}")
string(REPLACE [[*]] [[\*]] pdb_regex "${pdb_regex}")
list(FILTER found_pdbs INCLUDE REGEX "/${pdb_regex}")
find_path_pdb_in_buildtree("${dll_or_exe}" "${${search_pdbs_var}}" "${found_pdbs}" install_found_pdb ambigous_pdbs_found find_pdb_by_name)
endforeach()
endmacro()

find_program(DUMPBIN NAMES dumpbin)
find_program(FINDSTR NAMES findstr)

# Release pdbs
foreach(dll_or_exe IN LISTS rel_dlls_or_exe)
cmake_path(GET dll_or_exe FILENAME dll_or_exe_filename)
list(FIND rel_dlls_installed "${dll_or_exe_filename}" already_installed)
if(NOT already_installed EQUAL "-1")
continue()
endif()

execute_process(COMMAND "${DUMPBIN}" /NOLOGO /PDBPATH:VERBOSE "${dll_or_exe}"
COMMAND "${FINDSTR}" PDB
OUTPUT_VARIABLE pdb_lines
ERROR_QUIET
RESULT_VARIABLE error_code
)
## Alternatives to dumpbin:
## llvm-readobj --coff-debug-directory bin/szip.dll
## PDBFileName: szip.pdb

## For Dlls deps:
## llvm-readobj --needed-libs bin/szip.dll
# NeededLibraries [
# KERNEL32.dll
# VCRUNTIME140.dll
# api-ms-win-crt-heap-l1-1-0.dll
# api-ms-win-crt-runtime-l1-1-0.dll
# ]

if(NOT error_code EQUAL "0" AND pdb_lines) # If findstr doesn't match anything it will also return -1; So test for output via pdb_lines
message(FATAL_ERROR "Unable to run dumpbin and findstr! Error code: ${error_code};${pdb_lines}")
endif()
if(pdb_lines)
set(search_pdbs "${build_rel_pdbs}")
analyze_dumpbin_pdbs("${dll_or_exe}" search_pdbs pdb_lines "")
if(pdb_not_found)
list(APPEND no_matching_pdbs "${dll_or_exe}")
endif()
endif()
endforeach()
# Debug pdbs
foreach(dll_or_exe IN LISTS dbg_dlls_or_exe)
cmake_path(GET dll_or_exe FILENAME dll_or_exe_filename)
list(FIND dbg_dlls_installed "${dll_or_exe_filename}" already_installed)
if(NOT already_installed EQUAL "-1")
continue()
endif()
execute_process(COMMAND "${DUMPBIN}" /NOLOGO /PDBPATH:VERBOSE "${dll_or_exe}"
COMMAND "${FINDSTR}" PDB
OUTPUT_VARIABLE pdb_lines
ERROR_QUIET
RESULT_VARIABLE error_code
)
if(NOT error_code EQUAL "0" AND pdb_lines) # If findstr doesn't match anything it will also return -1; So test for output via pdb_lines
message(FATAL_ERROR "Unable to run dumpbin and findstr! Error code: ${error_code};${pdb_lines}")
endif()
if(pdb_lines)
set(search_pdbs "${build_dbg_pdbs}")
analyze_dumpbin_pdbs("${dll_or_exe}" search_pdbs pdb_lines "debug/")
if(pdb_not_found)
list(APPEND no_matching_pdbs "${dll_or_exe}")
endif()
endif()
endforeach()

set(ENV{VSLANG} "${vslang_backup}")

if(NOT no_matching_pdbs STREQUAL "")
list(REMOVE_DUPLICATES no_matching_pdbs)
list(JOIN no_matching_pdbs "\n\t" msg)
message(WARNING "Could not find a matching pdb file for:\n${msg}\n")
endif()
endfunction()

z_vcpkg_copy_pdbs()
Loading
Loading