diff --git a/CMakeLists.txt b/CMakeLists.txt index 5443b6144..922249b27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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}/$/$.pdb DESTINATION bin CONFIGURATIONS Debug OR RelWithDebInfo