Clean up cmake for abi namespace.

Add doc for new option in build.md
Change add_definitions -> vtk_module_definitions
Move configurable header to Common/Core
HTGUnlimitedGradien
Ryan Krattiger 2 months ago
parent 64b2d687c3
commit 6fb3fddec1
  1. 16
      CMake/vtkModule.cmake
  2. 6
      CMake/vtkModuleTesting.cmake
  3. 16
      Common/Core/CMakeLists.txt
  4. 0
      Common/Core/vtkABINamespace.h.in
  5. 4
      Documentation/dev/build.md
  6. 5
      Wrapping/Tools/CMakeLists.txt

@ -3569,15 +3569,6 @@ function (vtk_module_add_module name)
"The ${_vtk_build_module} module has no source files.")
endif ()
set(_vtk_add_module_has_cxx FALSE)
foreach (source IN LISTS _vtk_add_module_SOURCES)
get_filename_component(source_ext "${source}" EXT)
if (source_ext MATCHES "cxx$")
set(_vtk_add_module_has_cxx TRUE)
break()
endif ()
endforeach ()
get_property(_vtk_add_module_third_party GLOBAL
PROPERTY "_vtk_module_${_vtk_build_module}_third_party")
@ -3956,15 +3947,12 @@ function (vtk_module_add_module name)
"INTERFACE_vtk_module_implementable" 1)
endif ()
# Include the ABI Namespace macros if this is a module with C++ sources
if (_vtk_add_module_has_cxx)
# Include the ABI Namespace macros
string(APPEND _vtk_add_module_module_content
# Include the ABI Namespace macros header
string(APPEND _vtk_add_module_module_content
"
/* Include ABI Namespace */
#include \"vtkABINamespace.h\"
")
endif ()
if (_vtk_add_module_implementable OR _vtk_add_module_implements)
set_property(TARGET "${_vtk_add_module_real_target}"

@ -752,7 +752,8 @@ function (vtk_add_test_mangling module)
cmake_parse_arguments("vtk_mangling_test" "" "" "EXEMPTIONS" ${ARGN})
if (VTK_ABI_NAMESPACE_NAME)
get_property(vtk_abi_namespace_name GLOBAL PROPERTY _vtk_abi_namespace_name)
if (vtk_abi_namespace_name STREQUAL "")
_vtk_module_real_target(_vtk_test_target "${module}")
get_property(has_sources TARGET ${_vtk_test_target} PROPERTY SOURCES)
get_property(has_test GLOBAL PROPERTY "${module}_HAS_MANGLING_TEST" SET)
@ -767,7 +768,8 @@ function (vtk_add_test_mangling module)
"--files"
"$<TARGET_OBJECTS:${_vtk_test_target}>"
"--prefix"
"${VTK_ABI_NAMESPACE_NAME}"
# TODO: This is not included in vtk-config.
"${vtk_abi_namespace_name}"
"--exemptions"
"${vtk_mangling_test_EXEMPTIONS}")
endif ()

@ -3,26 +3,28 @@ cmake_dependent_option(VTK_USE_64BIT_TIMESTAMPS "Build VTK with 64 bit timestamp
"NOT CMAKE_SIZEOF_VOID_P GREATER 4" ON)
mark_as_advanced(VTK_USE_64BIT_TIMESTAMPS)
# Mangle VTK symbols
# Option to mangle VTK symbols
set(VTK_ABI_NAMESPACE_NAME
"<DEFAULT>"
CACHE STRING "Inline namespace name for mangling VTK symbols.")
mark_as_advanced(VTK_ABI_NAMESPACE_NAME)
if (VTK_ABI_NAMESPACE_NAME STREQUAL "<DEFAULT>")
# The default is to not have an ABI namespace.
# This is consistent with the existing practice.
set(VTK_ABI_NAMESPACE_NAME "")
endif ()
mark_as_advanced(VTK_ABI_NAMESPACE_NAME)
if (VTK_ABI_NAMESPACE_NAME)
set_property(GLOBAL PROPERTY _vtk_abi_namespace_name "${VTK_ABI_NAMESPACE_NAME}")
if (VTK_ABI_NAMESPACE_NAME STREQUAL "")
set(VTK_ABI_NAMESPACE_BEGIN "")
set(VTK_ABI_NAMESPACE_END "")
else ()
message(STATUS "VTK ABI namespace: ${VTK_ABI_NAMESPACE_NAME}")
set(VTK_ABI_NAMESPACE_BEGIN "inline namespace ${VTK_ABI_NAMESPACE_NAME} {")
set(VTK_ABI_NAMESPACE_END "}")
else ()
set(VTK_ABI_NAMESPACE_BEGIN "")
set(VTK_ABI_NAMESPACE_END "")
endif ()
configure_file(
"${vtk_cmake_dir}/vtkABINamespace.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/vtkABINamespace.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/vtkABINamespace.h"
@ONLY)

@ -218,6 +218,10 @@ Less common, but variables which may be of interest to some:
More advanced options:
* `VTK_ABI_NAMESPACE_NAME` (default `<DEFAULT>` aka `""`): If set, VTK will
wrap all VTK public symbols in an
`inline namespace <VTK_ABI_NAMESPACE_NAME>` to allow runtime co-habitation
with different VTK versions.
* `VTK_BUILD_DOCUMENTATION` (default `OFF`): If set, VTK will build its API
documentation using Doxygen.
* `VTK_BUILD_ALL_MODULES` (default `OFF`): If set, VTK will enable all

@ -40,12 +40,13 @@ set_property(SOURCE vtkParseMain.c
PROPERTY
COMPILE_DEFINITIONS "VTK_PARSE_VERSION=\"${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}\"")
add_definitions(-DVTK_NO_ABI_NAMESPACE)
vtk_module_add_module("${ns}::WrappingTools"
SOURCES ${sources}
HEADERS ${headers})
vtk_module_definitions("${ns}::WrappingTools"
PUBLIC VTK_NO_ABI_NAMESPACE)
if (NOT TARGET "${ns}::WrapHierarchy")
vtk_module_add_executable(WrapHierarchy
DEVELOPMENT

Loading…
Cancel
Save