Merge pull request #11276 from alalek:install_pdb

pull/11294/head
Alexander Alekhin 7 years ago
commit 333973b846
  1. 2
      3rdparty/protobuf/CMakeLists.txt
  2. 51
      cmake/OpenCVUtils.cmake

@ -142,6 +142,8 @@ set_target_properties(libprotobuf
FOLDER "3rdparty" FOLDER "3rdparty"
OUTPUT_NAME libprotobuf OUTPUT_NAME libprotobuf
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
COMPILE_PDB_NAME libprotobuf
COMPILE_PDB_NAME_DEBUG "libprotobuf${OPENCV_DEBUG_POSTFIX}"
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH} ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
) )

@ -1027,14 +1027,17 @@ function(ocv_install_target)
set(${__package}_TARGETS "${${__package}_TARGETS}" CACHE INTERNAL "List of ${__package} targets") set(${__package}_TARGETS "${${__package}_TARGETS}" CACHE INTERNAL "List of ${__package} targets")
endif() endif()
if(MSVS) if(MSVC)
if(NOT INSTALL_IGNORE_PDB AND if(INSTALL_PDB AND (NOT INSTALL_IGNORE_PDB))
(INSTALL_PDB OR
(INSTALL_CREATE_DISTRIB AND NOT BUILD_SHARED_LIBS)
))
set(__target "${ARGV0}") set(__target "${ARGV0}")
set(isArchive 0) set(__location_key "ARCHIVE") # static libs
get_target_property(__target_type ${__target} TYPE)
if("${__target_type}" STREQUAL "SHARED_LIBRARY")
set(__location_key "RUNTIME") # shared libs (.DLL)
endif()
set(processDst 0)
set(isDst 0) set(isDst 0)
unset(__dst) unset(__dst)
foreach(e ${ARGN}) foreach(e ${ARGN})
@ -1042,34 +1045,36 @@ function(ocv_install_target)
set(__dst "${e}") set(__dst "${e}")
break() break()
endif() endif()
if(isArchive EQUAL 1 AND e STREQUAL "DESTINATION") if(processDst EQUAL 1 AND e STREQUAL "DESTINATION")
set(isDst 1) set(isDst 1)
endif() endif()
if(e STREQUAL "ARCHIVE") if(e STREQUAL "${__location_key}")
set(isArchive 1) set(processDst 1)
else() else()
set(isArchive 0) set(processDst 0)
endif() endif()
endforeach() endforeach()
# message(STATUS "Process ${__target} dst=${__dst}...") # message(STATUS "Process ${__target} dst=${__dst}...")
if(DEFINED __dst) if(DEFINED __dst)
# If CMake version is >=3.1.0 or <2.8.12. if(NOT CMAKE_VERSION VERSION_LESS 3.1.0)
if(NOT CMAKE_VERSION VERSION_LESS 3.1.0 OR CMAKE_VERSION VERSION_LESS 2.8.12) set(__pdb_install_component "pdb")
get_target_property(fname ${__target} LOCATION_DEBUG) if(DEFINED INSTALL_PDB_COMPONENT AND INSTALL_PDB_COMPONENT)
if(fname MATCHES "\\.lib$") set(__pdb_install_component "${INSTALL_PDB_COMPONENT}")
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}")
install(FILES "${fname}" DESTINATION "${__dst}" CONFIGURATIONS Debug OPTIONAL)
endif() endif()
# message(STATUS "Adding PDB file installation rule: target=${__target} dst=${__dst} component=${__pdb_install_component}")
get_target_property(fname ${__target} LOCATION_RELEASE) if("${__target_type}" STREQUAL "SHARED_LIBRARY")
if(fname MATCHES "\\.lib$") install(FILES "$<TARGET_PDB_FILE:${__target}>" DESTINATION "${__dst}" COMPONENT ${__pdb_install_component} OPTIONAL)
string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}") else()
install(FILES "${fname}" DESTINATION "${__dst}" CONFIGURATIONS Release OPTIONAL) # There is no generator expression similar to TARGET_PDB_FILE and TARGET_PDB_FILE can't be used: https://gitlab.kitware.com/cmake/cmake/issues/16932
# However we still want .pdb files like: 'lib/Debug/opencv_core341d.pdb' or '3rdparty/lib/zlibd.pdb'
install(FILES "$<TARGET_PROPERTY:${__target},ARCHIVE_OUTPUT_DIRECTORY>/$<CONFIG>/$<IF:$<BOOL:$<TARGET_PROPERTY:${__target},COMPILE_PDB_NAME_DEBUG>>,$<TARGET_PROPERTY:${__target},COMPILE_PDB_NAME_DEBUG>,$<TARGET_PROPERTY:${__target},COMPILE_PDB_NAME>>.pdb"
DESTINATION "${__dst}" CONFIGURATIONS Debug COMPONENT ${__pdb_install_component} OPTIONAL)
install(FILES "$<TARGET_PROPERTY:${__target},ARCHIVE_OUTPUT_DIRECTORY>/$<CONFIG>/$<IF:$<BOOL:$<TARGET_PROPERTY:${__target},COMPILE_PDB_NAME_RELEASE>>,$<TARGET_PROPERTY:${__target},COMPILE_PDB_NAME_RELEASE>,$<TARGET_PROPERTY:${__target},COMPILE_PDB_NAME>>.pdb"
DESTINATION "${__dst}" CONFIGURATIONS Release COMPONENT ${__pdb_install_component} OPTIONAL)
endif() endif()
else() else()
# CMake 2.8.12 broke PDB support for STATIC libraries from MSVS, fix was introduced in CMake 3.1.0. message(WARNING "PDB files installation is not supported (need CMake >= 3.1.0)")
message(WARNING "PDB's are not supported from this version of CMake, use CMake version later then 3.1.0 or before 2.8.12.")
endif() endif()
endif() endif()
endif() endif()

Loading…
Cancel
Save