Skip to content

Commit

Permalink
Add cmake option to control whether to install pdb files.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewgr committed May 30, 2024
1 parent 7652828 commit a0ce1d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ set(ZLIB_SHARED_PROJECT_NAME "${PROJECT_NAME}" CACHE STRING "Shared library targ
set(ZLIB_STATIC_PROJECT_NAME "${ZLIB_SHARED_PROJECT_NAME}static" CACHE STRING "Static library target name")

option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
if(MSVC)
# Note that we want to let the consumer project to control this, because on msvc one can set via the
# CMAKE_MSVC_DEBUG_INFORMATION_FORMAT cmake option the /Z7 linker flag to embed the symbols into the
# static archive, so there won't be any pdb files generated to actually install unless it is a shared
# library build.
option(ZLIB_INSTALL_MSVC_SYMBOLS "Enable to install generated debug symbols (*.pdb) files" OFF)
endif()

set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
Expand Down Expand Up @@ -186,7 +193,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
if(MSVC)
if(MSVC AND ZLIB_INSTALL_MSVC_SYMBOLS)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/$<TARGET_FILE_BASE_NAME:${ZLIB_SHARED_PROJECT_NAME}>.pdb
DESTINATION bin
CONFIGURATIONS Debug OR RelWithDebInfo
Expand Down

0 comments on commit a0ce1d4

Please sign in to comment.