Skip to content

Add support for installing PDBs with CMAKE_SHARED_LIBRARY_PREFIX_C - #958

Merged
NWilson merged 1 commit into
PCRE2Project:mainfrom
moyer-avs:install-pdb-with-prefix
Aug 23, 2026
Merged

Add support for installing PDBs with CMAKE_SHARED_LIBRARY_PREFIX_C#958
NWilson merged 1 commit into
PCRE2Project:mainfrom
moyer-avs:install-pdb-with-prefix

Conversation

@moyer-avs

@moyer-avs moyer-avs commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Hello,

We are building pcre2 with a custom prefix for shared libraries on Windows.
We use CMAKE_SHARED_LIBRARY_PREFIX_C to set the prefix, resulting in both the dll and pdb being prefixed with the content of the variable.

The pdb installation then fails, because the prefix is not taken into account in the install() command.

This PR intends to fix it.

cd ./pcre2
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug \
    -DBUILD_STATIC_LIBS=OFF \
    -DINSTALL_MSVC_PDB=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_SHARED_LIBRARY_PREFIX_C="prefix." \
    -B build
cmake --build build/
cmake --install build/ --prefix C:/test/pcre2

@NWilson

NWilson commented Aug 22, 2026

Copy link
Copy Markdown
Member

Thank you! I can see how and why this is failing.

We last changed this configuration in PR #370, where the author commented on the existence of $<TARGET_PDF_FILE:target>. However I didn't pick up on it realise the problem. The current situation is a bit of a patch on top of the previous system, which was also a bit broken.

Basically, the CMake is file is "guessing" what the exact filename is going to be for the PDB file. By adding CMOKE_SHARED_LIBRARY_PREFIX_C, you've improved the guess, but there are many other CMake properties the user could have set, to customise the file basenames, prefixes, suffixes, and so on.

Would you be able to fix it to request the actual pathname from CMake?

Replace:

-    list(APPEND DLL_PDB_FILES $<TARGET_PDB_FILE_DIR:pcre2-8-shared>/pcre2-8.pdb)
-    list(APPEND DLL_PDB_DEBUG_FILES $<TARGET_PDB_FILE_DIR:pcre2-8-shared>/pcre2-8d.pdb)
+    list(APPEND DLL_PDB_FILES "$<TARGET_PDB_FILE:pcre2-8-shared>")

We only need to track one filename - and CMake shouldn't ever give us the wrong one!

Delete all references to DLL_PDB_DEBUG_FILES.

Then, we only need to install them when they exist (in Debug and RelWithDebInfo configurations):

if(MSVC AND INSTALL_MSVC_PDB)
  install(
    FILES ${DLL_PDB_FILES}
    DESTINATION ${CMAKE_INSTALL_BINDIR}
    CONFIGURATIONS Debug RelWithDebInfo
  )
endif()

@moyer-avs
moyer-avs force-pushed the install-pdb-with-prefix branch from da66b46 to ee8d355 Compare August 22, 2026 21:06
@moyer-avs

Copy link
Copy Markdown
Contributor Author

I tested the proposed changes, they work as expected.
I amended my commit.

@NWilson

NWilson commented Aug 22, 2026

Copy link
Copy Markdown
Member

Thank you! I will do some testing of my own, and merge.

@NWilson

NWilson commented Aug 22, 2026

Copy link
Copy Markdown
Member

I have tested with the four different build types on Windows; using INSTALL_MSVC_PDB and with/without your CMAKE_SHARED_LIBRARY_PREFIX_C.

Everything appears to work.

@NWilson NWilson added this to the 10.48 milestone Aug 22, 2026
@NWilson
NWilson merged commit 7ac751e into PCRE2Project:main Aug 23, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants