mirror of
https://github.com/boostorg/cmake.git
synced 2026-01-19 04:02:15 +00:00
Merge pull request #89 from k3DW/natvis
Install extra/ directory, and configure .natvis files on Windows
This commit is contained in:
@@ -125,6 +125,11 @@ or `cmake-gui`:
|
||||
Directory in which to install the compiled libraries. Can be relative to
|
||||
`CMAKE_INSTALL_PREFIX`. Default `lib`.
|
||||
|
||||
* [`CMAKE_INSTALL_DATADIR`](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html)
|
||||
|
||||
Directory in which to install the data files (e.g. debugger visualizers).
|
||||
Can be relative to `CMAKE_INSTALL_PREFIX`. Default `share`.
|
||||
|
||||
* `BOOST_INSTALL_CMAKEDIR`
|
||||
|
||||
Directory in which to install the CMake configuration files. Default `lib/cmake`.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Copyright 2019-2023 Peter Dimov
|
||||
# Copyright 2025 Braden Ganetsky
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
@@ -214,12 +215,44 @@ function(__boost_install_update_include_directory lib incdir prop)
|
||||
|
||||
endfunction()
|
||||
|
||||
function(__boost_install_update_natvis lib extradir extrainstalldir)
|
||||
|
||||
if(NOT TARGET "${lib}" OR NOT lib MATCHES "^boost_(.*)$")
|
||||
return()
|
||||
endif()
|
||||
|
||||
get_target_property(sources ${lib} INTERFACE_SOURCES)
|
||||
if(NOT sources)
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(src IN LISTS sources)
|
||||
|
||||
get_filename_component(dir "${src}" DIRECTORY)
|
||||
get_filename_component(extension "${src}" EXT)
|
||||
|
||||
if("${dir}" STREQUAL "${extradir}" AND "${extension}" STREQUAL ".natvis")
|
||||
|
||||
get_target_property(modified_sources ${lib} INTERFACE_SOURCES)
|
||||
list(REMOVE_ITEM modified_sources "${src}")
|
||||
set_target_properties(${lib} PROPERTIES INTERFACE_SOURCES "${modified_sources}")
|
||||
|
||||
# Add this .natvis file to the INTERFACE_SOURCES target property, prefixed properly.
|
||||
get_filename_component(natvis_file "${src}" NAME)
|
||||
target_sources("${lib}" INTERFACE $<BUILD_INTERFACE:${src}> $<INSTALL_INTERFACE:${extrainstalldir}/${natvis_file}>)
|
||||
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
||||
|
||||
# Installs a single target
|
||||
# boost_install_target(TARGET target VERSION version [HEADER_DIRECTORY directory])
|
||||
# boost_install_target(TARGET target VERSION version [HEADER_DIRECTORY directory] [EXTRA_DIRECTORY directory] [EXTRA_INSTALL_DIRECTORY directory])
|
||||
|
||||
function(boost_install_target)
|
||||
|
||||
cmake_parse_arguments(_ "" "TARGET;VERSION;HEADER_DIRECTORY" "" ${ARGN})
|
||||
cmake_parse_arguments(_ "" "TARGET;VERSION;HEADER_DIRECTORY;EXTRA_DIRECTORY;EXTRA_INSTALL_DIRECTORY" "" ${ARGN})
|
||||
|
||||
if(NOT __TARGET)
|
||||
|
||||
@@ -287,6 +320,13 @@ function(boost_install_target)
|
||||
|
||||
endif()
|
||||
|
||||
if((NOT __EXTRA_DIRECTORY AND __EXTRA_INSTALL_DIRECTORY) OR (__EXTRA_DIRECTORY AND NOT __EXTRA_INSTALL_DIRECTORY))
|
||||
|
||||
message(SEND_ERROR "boost_install_target: both or neither of EXTRA_DIRECTORY and EXTRA_INSTALL_DIRECTORY must be given.")
|
||||
return()
|
||||
|
||||
endif()
|
||||
|
||||
set(CONFIG_INSTALL_DIR "${BOOST_INSTALL_CMAKEDIR}/${LIB}-${__VERSION}")
|
||||
|
||||
if(TYPE STREQUAL "SHARED_LIBRARY")
|
||||
@@ -316,6 +356,10 @@ function(boost_install_target)
|
||||
if(TYPE STREQUAL "STATIC_LIBRARY" AND NOT CMAKE_VERSION VERSION_LESS 3.15)
|
||||
install(FILES "$<TARGET_FILE_DIR:${LIB}>/$<TARGET_FILE_PREFIX:${LIB}>$<TARGET_FILE_BASE_NAME:${LIB}>.pdb" DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
|
||||
endif()
|
||||
|
||||
if(__EXTRA_DIRECTORY AND __EXTRA_INSTALL_DIRECTORY)
|
||||
__boost_install_update_natvis(${LIB} ${__EXTRA_DIRECTORY} ${__EXTRA_INSTALL_DIRECTORY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(EXPORT ${LIB}-targets DESTINATION "${CONFIG_INSTALL_DIR}" NAMESPACE Boost:: FILE ${LIB}-targets.cmake)
|
||||
@@ -510,11 +554,11 @@ function(boost_install_target)
|
||||
|
||||
endfunction()
|
||||
|
||||
# boost_install([VERSION version] [TARGETS targets...] [HEADER_DIRECTORY directory])
|
||||
# boost_install([VERSION version] [TARGETS targets...] [HEADER_DIRECTORY directory] [EXTRA_DIRECTORY directory])
|
||||
|
||||
function(boost_install)
|
||||
|
||||
cmake_parse_arguments(_ "" "VERSION;HEADER_DIRECTORY" "TARGETS" ${ARGN})
|
||||
cmake_parse_arguments(_ "" "VERSION;HEADER_DIRECTORY;EXTRA_DIRECTORY" "TARGETS" ${ARGN})
|
||||
|
||||
if(NOT __VERSION)
|
||||
|
||||
@@ -545,9 +589,21 @@ function(boost_install)
|
||||
|
||||
endif()
|
||||
|
||||
if(__EXTRA_DIRECTORY AND NOT BOOST_SKIP_INSTALL_RULES AND NOT CMAKE_SKIP_INSTALL_RULES)
|
||||
|
||||
# Extract the library name from the path, one component up from the extra directory
|
||||
get_filename_component(libname "${__EXTRA_DIRECTORY}" DIRECTORY)
|
||||
get_filename_component(libname "${libname}" NAME)
|
||||
|
||||
get_filename_component(__EXTRA_DIRECTORY "${__EXTRA_DIRECTORY}" ABSOLUTE)
|
||||
set(extrainstalldir "${CMAKE_INSTALL_DATADIR}/boost-${__VERSION}/${libname}")
|
||||
install(DIRECTORY "${__EXTRA_DIRECTORY}/" DESTINATION "${extrainstalldir}")
|
||||
|
||||
endif()
|
||||
|
||||
foreach(target IN LISTS __TARGETS)
|
||||
|
||||
boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY})
|
||||
boost_install_target(TARGET ${target} VERSION ${__VERSION} HEADER_DIRECTORY ${__HEADER_DIRECTORY} EXTRA_DIRECTORY ${__EXTRA_DIRECTORY} EXTRA_INSTALL_DIRECTORY ${extrainstalldir})
|
||||
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -191,10 +191,15 @@ function(__boost_auto_install __boost_lib)
|
||||
|
||||
set(incdir "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/include")
|
||||
|
||||
set(extradir "${BOOST_SUPERPROJECT_SOURCE_DIR}/libs/${__boost_lib}/extra")
|
||||
if(NOT EXISTS "${extradir}")
|
||||
set(extradir "")
|
||||
endif()
|
||||
|
||||
if("${__boost_lib_incdir}" STREQUAL "${incdir}" OR "${__boost_lib_incdir}" STREQUAL "$<BUILD_INTERFACE:${incdir}>")
|
||||
|
||||
boost_message(DEBUG "Enabling installation for '${__boost_lib}'")
|
||||
boost_install(TARGETS "boost_${__boost_lib_target}" VERSION "${BOOST_SUPERPROJECT_VERSION}" HEADER_DIRECTORY "${incdir}")
|
||||
boost_install(TARGETS "boost_${__boost_lib_target}" VERSION "${BOOST_SUPERPROJECT_VERSION}" HEADER_DIRECTORY "${incdir}" EXTRA_DIRECTORY "${extradir}")
|
||||
|
||||
else()
|
||||
boost_message(DEBUG "Not enabling installation for '${__boost_lib}'; interface include directory '${__boost_lib_incdir}' does not equal '${incdir}' or '$<BUILD_INTERFACE:${incdir}>'")
|
||||
|
||||
Reference in New Issue
Block a user