Last active
October 10, 2015 15:00
-
-
Save pzychotic/3ef04b2fd5372e56148d to your computer and use it in GitHub Desktop.
CMake PDB install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# global project settings | |
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin ) | |
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib ) | |
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib ) | |
set( CMAKE_PDB_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin ) | |
###### | |
macro( InstallTarget TARGET_NAME ) | |
# escaped the ${BUILD_TYPE} so it will be passed unexpanded to | |
# cmake_install.cmake which CMake generates for every project and calls | |
# from VS with $(Configuration) assigned to ${BUILD_TYPE} | |
set( CONFIG "\${BUILD_TYPE}" ) | |
# starting with CMake v3.4, generator expressions can be used in more | |
# places like 'install( FILES )', so we don't need hacks like above | |
set( CONFIG "$<CONFIG>" ) | |
# install library and executable binaries | |
install( TARGETS ${TARGET_NAME} | |
RUNTIME DESTINATION bin/${CONFIG} | |
LIBRARY DESTINATION lib/${CONFIG} | |
ARCHIVE DESTINATION lib/${CONFIG} | |
) | |
# this property is initialized with the global set CMAKE_PDB_OUTPUT_DIRECTORY | |
get_target_property( PDBPATH ${TARGET_NAME} PDB_OUTPUT_DIRECTORY ) | |
set( PDBPATH "${PDBPATH}/${CONFIG}/${TARGET_NAME}.pdb" ) | |
install( FILES ${PDBPATH} DESTINATION bin/${CONFIG} ) | |
endmacro() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment