diff --git a/.gitignore b/.gitignore index d6d47929120f8f..457ac90abadee0 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/scripts/azure-pipelines/azure-pipelines.yml b/scripts/azure-pipelines/azure-pipelines.yml index 939e8a8ec6bcf0..1c43adda1e518f 100644 --- a/scripts/azure-pipelines/azure-pipelines.yml +++ b/scripts/azure-pipelines/azure-pipelines.yml @@ -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 diff --git a/scripts/cmake/vcpkg_build_nmake.cmake b/scripts/cmake/vcpkg_build_nmake.cmake old mode 100755 new mode 100644 diff --git a/scripts/cmake/vcpkg_copy_pdbs.cmake b/scripts/cmake/vcpkg_copy_pdbs.cmake index 5f7bffe1136f1b..47ca2eee0b0b5a 100644 --- a/scripts/cmake/vcpkg_copy_pdbs.cmake +++ b/scripts/cmake/vcpkg_copy_pdbs.cmake @@ -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() diff --git a/scripts/toolchains/windows.cmake b/scripts/toolchains/windows.cmake index 3cc90cc8867454..e1a9b23c52a9c8 100644 --- a/scripts/toolchains/windows.cmake +++ b/scripts/toolchains/windows.cmake @@ -75,8 +75,8 @@ 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") @@ -84,11 +84,75 @@ if(NOT _VCPKG_WINDOWS_TOOLCHAIN) 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 "$" 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 "$,*.pdb>") + #get_target_property(pdb_name "${target}" PDB_NAME) + # install(FILES "$/${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 "") diff --git a/triplets/move_pdb_files.cmake b/triplets/move_pdb_files.cmake new file mode 100644 index 00000000000000..25b208bdd0669e --- /dev/null +++ b/triplets/move_pdb_files.cmake @@ -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() \ No newline at end of file diff --git a/triplets/x64-windows.cmake b/triplets/x64-windows.cmake index d0be7297f0c468..ceb029834f0688 100644 --- a/triplets/x64-windows.cmake +++ b/triplets/x64-windows.cmake @@ -2,3 +2,7 @@ set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE dynamic) +#set(VCPKG_CMAKE_CONFIGURE_OPTIONS "-DVCPKG_PORT=${PORT}" "-DCMAKE_JOB_POOL_LINK=console") # tell cmake to only run one link job pool +#set(VCPKG_MESON_CONFIGURE_OPTIONS "-Dbackend_max_links=1") # to tell meson to not run the linker in parallel +set(Z_VCPKG_POST_PORTFILE_INCLUDES "${CMAKE_CURRENT_LIST_DIR}/move_pdb_files.cmake") +#message(FATAL_ERROR "WIP: BLOCK CI")