Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue installing PDB files on Windows with static Debug configuration #81

Open
phetdam opened this issue Jan 27, 2024 · 0 comments
Open

Comments

@phetdam
Copy link

phetdam commented Jan 27, 2024

Hi,

When building the 2.7.0 release tag source statically using CMake on Windows, I found that CMake errored out on installation of the Debug configuration PDB files. The issue seems to stem from the fact that when the GSL libraries are built statically, the PDB files are placed in ${PROJECT_BINARY_DIR}/Debug, not ${PROJECT_BINARY_DIR}/bin/Debug as is expected when building DLLs.

Here are some steps to reproduce my observation. I am using Visual Studio 2019 as the generator here, CMake 3.22, and all these commands are run from a Developer Command Prompt from the AMPL GSL top-level directory.

  1. cmake -S . -B build_windows_x64 -A x64 -DGSL_INSTALL_MULTI_CONFIG=ON -DMSVC_RUNTIME_DYNAMIC=ON -DNO_AMPL_BINDINGS=1
  2. cmake --build build_windows_x64 --config Debug -j
  3. cmake --install build_windows_x64 --prefix install_windows_x64 --config Debug

Step 3. will error out with the following message from the generated cmake_install.cmake:

CMake Error at build_windows_x64/cmake_install.cmake:61 (file):
  file INSTALL cannot find
  "C:/Users/Derek/START/gsl-2.7.0/build_windows_x64/bin/Debug/gsl.pdb": File
  exists.

Fortunately, I was able to quickly trace the problem to this chunk in the top-level CMakeLists.txt in the master branch:

gsl/CMakeLists.txt

Lines 865 to 872 in 60539d2

# For Debug under VS, also install the pdb files.
install(
FILES
${PROJECT_BINARY_DIR}/bin/Debug/gsl.pdb
${PROJECT_BINARY_DIR}/bin/Debug/gslcblas.pdb
CONFIGURATIONS Debug
DESTINATION bin/$<CONFIG>
COMPONENT gsl)

Since the listed PDB files are rather in ${PROJECT_BINARY_DIR}/Debug with the GSL .lib static libraries instead of listed directory ${PROJECT_BINARY_DIR}/bin/Debug, this install command fails because the PDB files won't be found. To work around this on my end, I modified the CMakeLists.txt at that location with some extra logic to instead read as follows:

    # PDB file directories for shared GSL build
    if(BUILD_SHARED_LIBS)
      set(GSL_PDB_BUILD_DIR ${PROJECT_BINARY_DIR}/bin)
      set(GSL_PDB_INSTALL_SUBDIR bin)
    # PDB file directories for static GSL build
    else()
      set(GSL_PDB_BUILD_DIR ${PROJECT_BINARY_DIR})
      set(GSL_PDB_INSTALL_SUBDIR lib)
    endif()
    # install PDB files for VS Debug configuration
    install(
      FILES
        ${GSL_PDB_BUILD_DIR}/Debug/gsl.pdb
        ${GSL_PDB_BUILD_DIR}/Debug/gslcblas.pdb
      CONFIGURATIONS Debug
      DESTINATION ${GSL_PDB_INSTALL_SUBDIR}/$<CONFIG>)

Making this modification resulted in PDB file installation to lib\Debug of my chosen installation root as desired. However, I decided to make an issue about this to get some feedback on whether or not this is the approach to take here.

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

No branches or pull requests

1 participant