From 063bfebb0e2c4eb85d07c8f410aa8515f0bcf079 Mon Sep 17 00:00:00 2001 From: hearga Date: Tue, 2 Sep 2025 09:49:05 -0400 Subject: [PATCH 1/6] Fix: vsg::Object cast() sometimes returns nullptr on macOS Sonoma arm64 Release builds --- include/vsg/io/Input.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/vsg/io/Input.h b/include/vsg/io/Input.h index 427021a6e8..0e11491a4e 100644 --- a/include/vsg/io/Input.h +++ b/include/vsg/io/Input.h @@ -219,7 +219,8 @@ namespace vsg { if (!matchPropertyName(propertyName)) return; - arg = read().cast(); + ref_ptr object = read(); + arg = ref_ptr(dynamic_cast(object.get())); } /// read a value of particular type From 0135bfd448e7f04de77eaa24bdf71a98849ed09d Mon Sep 17 00:00:00 2001 From: hearga Date: Tue, 2 Sep 2025 16:51:35 -0400 Subject: [PATCH 2/6] Explicit template instantiation resolves the different type_info hash IDs during casting --- include/vsg/core/Array.h | 1 + include/vsg/core/Export.h | 6 +++- include/vsg/io/Input.h | 3 +- src/vsg/CMakeLists.txt | 1 + src/vsg/core/Array.cpp | 60 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 src/vsg/core/Array.cpp diff --git a/include/vsg/core/Array.h b/include/vsg/core/Array.h index ebc3209a14..dcda6a7883 100644 --- a/include/vsg/core/Array.h +++ b/include/vsg/core/Array.h @@ -24,6 +24,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #define VSG_array(N, T) \ using N = Array; \ + extern template class VSG_DECLSPEC vsg::Array; \ template<> \ constexpr const char* type_name() noexcept { return "vsg::" #N; } \ template<> \ diff --git a/include/vsg/core/Export.h b/include/vsg/core/Export.h index 3e46bcc17e..c5b5941f9d 100644 --- a/include/vsg/core/Export.h +++ b/include/vsg/core/Export.h @@ -25,5 +25,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI # define VSG_DECLSPEC # endif #else -# define VSG_DECLSPEC +# if defined(VSG_SHARED_LIBRARY) || defined(VSG_EXPORTS) +# define VSG_DECLSPEC __attribute__((visibility("default"))) +# else +# define VSG_DECLSPEC +# endif #endif diff --git a/include/vsg/io/Input.h b/include/vsg/io/Input.h index 0e11491a4e..427021a6e8 100644 --- a/include/vsg/io/Input.h +++ b/include/vsg/io/Input.h @@ -219,8 +219,7 @@ namespace vsg { if (!matchPropertyName(propertyName)) return; - ref_ptr object = read(); - arg = ref_ptr(dynamic_cast(object.get())); + arg = read().cast(); } /// read a value of particular type diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 26e87199aa..3504ac4435 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -11,6 +11,7 @@ endif() set(SOURCES core/Allocator.cpp + core/Array.cpp core/IntrusiveAllocator.cpp core/Auxiliary.cpp core/ConstVisitor.cpp diff --git a/src/vsg/core/Array.cpp b/src/vsg/core/Array.cpp new file mode 100644 index 0000000000..e2f29025de --- /dev/null +++ b/src/vsg/core/Array.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace vsg +{ + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array>; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; + template class VSG_DECLSPEC vsg::Array; +} // namespace vsg \ No newline at end of file From 62a47b1de7043023edfaaf1e2b2c2d87446e32ca Mon Sep 17 00:00:00 2001 From: hearga Date: Tue, 2 Sep 2025 18:39:13 -0400 Subject: [PATCH 3/6] - Add explicit template instantiations for: - vsg::Array - vsg::Array - cast l.size() to uint32_t in assign() to match parameter type and avoid warnings - rename core/Array.cpp to core/ArrayInstantiations.cpp --- include/vsg/core/Array.h | 2 +- src/vsg/CMakeLists.txt | 2 +- src/vsg/core/Array.cpp | 60 -------------------------- src/vsg/core/ArrayInstantiations.cpp | 63 ++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 62 deletions(-) delete mode 100644 src/vsg/core/Array.cpp create mode 100644 src/vsg/core/ArrayInstantiations.cpp diff --git a/include/vsg/core/Array.h b/include/vsg/core/Array.h index dcda6a7883..70baf5dfcd 100644 --- a/include/vsg/core/Array.h +++ b/include/vsg/core/Array.h @@ -102,7 +102,7 @@ namespace vsg _data(nullptr), _size(0) { - assign(data, offset, stride, l.size()); + assign(data, offset, stride, static_cast(l.size())); iterator itr = begin(); for (const value_type& v : l) { (*itr++) = v; } diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 3504ac4435..17f3af4b45 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -11,7 +11,7 @@ endif() set(SOURCES core/Allocator.cpp - core/Array.cpp + core/ArrayInstantiations.cpp core/IntrusiveAllocator.cpp core/Auxiliary.cpp core/ConstVisitor.cpp diff --git a/src/vsg/core/Array.cpp b/src/vsg/core/Array.cpp deleted file mode 100644 index e2f29025de..0000000000 --- a/src/vsg/core/Array.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace vsg -{ - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array>; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; - template class VSG_DECLSPEC vsg::Array; -} // namespace vsg \ No newline at end of file diff --git a/src/vsg/core/ArrayInstantiations.cpp b/src/vsg/core/ArrayInstantiations.cpp new file mode 100644 index 0000000000..09d0c818ca --- /dev/null +++ b/src/vsg/core/ArrayInstantiations.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace vsg +{ + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array>; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; + template class VSG_DECLSPEC Array; +} // namespace vsg \ No newline at end of file From e7994c6cfb52194279ee5120526b55a8892c75bb Mon Sep 17 00:00:00 2001 From: hearga Date: Tue, 9 Sep 2025 10:02:12 -0400 Subject: [PATCH 4/6] export Array for stable typeid; optional keep a dynamic_cast escape hatch when desired; drop explicit instantiations - CMake: * BUILD_SHARED_LIBS=OFF (static, Clang) -> by default define VSG_EXPORTS to export Array; if VSG_USE_DYNAMIC_CAST is requested, define VSG_USE_DYNAMIC_CAST instead to switch cast() to dynamic_cast. - Remove ArrayInstantiations.cpp: explicit template instantiations are no longer needed. --- include/vsg/core/Array.h | 3 +- include/vsg/core/Object.h | 22 ++++++++-- src/vsg/CMakeLists.txt | 9 +++- src/vsg/core/ArrayInstantiations.cpp | 63 ---------------------------- 4 files changed, 27 insertions(+), 70 deletions(-) delete mode 100644 src/vsg/core/ArrayInstantiations.cpp diff --git a/include/vsg/core/Array.h b/include/vsg/core/Array.h index 70baf5dfcd..54cf113673 100644 --- a/include/vsg/core/Array.h +++ b/include/vsg/core/Array.h @@ -24,7 +24,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #define VSG_array(N, T) \ using N = Array; \ - extern template class VSG_DECLSPEC vsg::Array; \ template<> \ constexpr const char* type_name() noexcept { return "vsg::" #N; } \ template<> \ @@ -34,7 +33,7 @@ namespace vsg { template - class Array : public Data + class VSG_DECLSPEC Array : public Data { public: using value_type = T; diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index fce17f532b..1bbc1280ee 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -22,6 +22,12 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include +#ifdef VSG_USE_DYNAMIC_CAST + #define VSG_CAST_DYNAMIC +#else + #undef VSG_CAST_DYNAMIC +#endif + namespace vsg { @@ -85,11 +91,19 @@ namespace vsg virtual const std::type_info& type_info() const noexcept { return typeid(Object); } virtual bool is_compatible(const std::type_info& type) const noexcept { return typeid(Object) == type; } - template - T* cast() { return is_compatible(typeid(T)) ? static_cast(this) : nullptr; } + #ifdef VSG_CAST_DYNAMIC + template + T* cast() { return dynamic_cast(this); } - template - const T* cast() const { return is_compatible(typeid(T)) ? static_cast(this) : nullptr; } + template + const T* cast() const { return dynamic_cast(this); } + #else + template + T* cast() { return is_compatible(typeid(T)) ? static_cast(this) : nullptr; } + + template + const T* cast() const { return is_compatible(typeid(T)) ? static_cast(this) : nullptr; } + #endif /// clone this object using CopyOp's duplicates map to decide whether to clone or to return the original object. /// The default clone(CopyOp&) implementation simply returns ref_ptr<> to this object rather attempt to clone. diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 17f3af4b45..1a8fa27ff0 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -11,7 +11,6 @@ endif() set(SOURCES core/Allocator.cpp - core/ArrayInstantiations.cpp core/IntrusiveAllocator.cpp core/Auxiliary.cpp core/ConstVisitor.cpp @@ -427,6 +426,14 @@ target_link_libraries(vsg ${LIBRARIES}) if (BUILD_SHARED_LIBS) target_compile_definitions(vsg INTERFACE VSG_SHARED_LIBRARY) +else() + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if (VSG_USE_DYNAMIC_CAST) + target_compile_definitions(vsg PRIVATE VSG_USE_DYNAMIC_CAST) + else () + target_compile_definitions(vsg PRIVATE VSG_EXPORTS) + endif () + endif() endif() # install headers diff --git a/src/vsg/core/ArrayInstantiations.cpp b/src/vsg/core/ArrayInstantiations.cpp deleted file mode 100644 index 09d0c818ca..0000000000 --- a/src/vsg/core/ArrayInstantiations.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace vsg -{ - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array>; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; - template class VSG_DECLSPEC Array; -} // namespace vsg \ No newline at end of file From b7d2c30c0bf0d283c37e0a142a36bc1527bff564 Mon Sep 17 00:00:00 2001 From: hearga Date: Tue, 9 Sep 2025 11:05:37 -0400 Subject: [PATCH 5/6] retrigger checks From 4bd274f4e096980e3c1b67ad178848009c009dd5 Mon Sep 17 00:00:00 2001 From: hearga Date: Mon, 24 Nov 2025 10:36:01 -0500 Subject: [PATCH 6/6] Apply VSG_DECLSPEC to Array2D, Array3D, and Value; move VSG_USE_DYNAMIC_CAST to version.h.in --- CMakeLists.txt | 2 ++ include/vsg/core/Array.h | 2 +- include/vsg/core/Array2D.h | 2 +- include/vsg/core/Array3D.h | 2 +- include/vsg/core/Object.h | 8 +------- include/vsg/core/Value.h | 2 +- src/vsg/CMakeLists.txt | 12 ++++-------- src/vsg/core/Version.h.in | 3 +++ 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62940f9835..e1c1106eff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,8 @@ if (VSG_SUPPORTS_Windowing) endif() endif() +set(VSG_USE_DYNAMIC_CAST 0 CACHE STRING "Use dynamic_cast in vsg::Object::cast(), 0 for off, 1 for enabled." ) + # this line needs to be after the call to setup_build_vars() configure_file("${VSG_SOURCE_DIR}/src/vsg/core/Version.h.in" "${VSG_VERSION_HEADER}") diff --git a/include/vsg/core/Array.h b/include/vsg/core/Array.h index 54cf113673..0ea11486d8 100644 --- a/include/vsg/core/Array.h +++ b/include/vsg/core/Array.h @@ -101,7 +101,7 @@ namespace vsg _data(nullptr), _size(0) { - assign(data, offset, stride, static_cast(l.size())); + assign(data, offset, stride, l.size()); iterator itr = begin(); for (const value_type& v : l) { (*itr++) = v; } diff --git a/include/vsg/core/Array2D.h b/include/vsg/core/Array2D.h index 999b423e32..47cdadb7d9 100644 --- a/include/vsg/core/Array2D.h +++ b/include/vsg/core/Array2D.h @@ -31,7 +31,7 @@ namespace vsg { template - class Array2D : public Data + class VSG_DECLSPEC Array2D : public Data { public: using value_type = T; diff --git a/include/vsg/core/Array3D.h b/include/vsg/core/Array3D.h index 033bf9d84c..510727ab7e 100644 --- a/include/vsg/core/Array3D.h +++ b/include/vsg/core/Array3D.h @@ -30,7 +30,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { template - class Array3D : public Data + class VSG_DECLSPEC Array3D : public Data { public: using value_type = T; diff --git a/include/vsg/core/Object.h b/include/vsg/core/Object.h index 1bbc1280ee..2088eaa262 100644 --- a/include/vsg/core/Object.h +++ b/include/vsg/core/Object.h @@ -22,12 +22,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI #include #include -#ifdef VSG_USE_DYNAMIC_CAST - #define VSG_CAST_DYNAMIC -#else - #undef VSG_CAST_DYNAMIC -#endif - namespace vsg { @@ -91,7 +85,7 @@ namespace vsg virtual const std::type_info& type_info() const noexcept { return typeid(Object); } virtual bool is_compatible(const std::type_info& type) const noexcept { return typeid(Object) == type; } - #ifdef VSG_CAST_DYNAMIC + #if VSG_USE_DYNAMIC_CAST == 1 template T* cast() { return dynamic_cast(this); } diff --git a/include/vsg/core/Value.h b/include/vsg/core/Value.h index c813bd456c..4aab22ec89 100644 --- a/include/vsg/core/Value.h +++ b/include/vsg/core/Value.h @@ -36,7 +36,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace vsg { template - class Value : public Data + class VSG_DECLSPEC Value : public Data { public: using value_type = T; diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 1a8fa27ff0..1d90a0c217 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -426,14 +426,10 @@ target_link_libraries(vsg ${LIBRARIES}) if (BUILD_SHARED_LIBS) target_compile_definitions(vsg INTERFACE VSG_SHARED_LIBRARY) -else() - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if (VSG_USE_DYNAMIC_CAST) - target_compile_definitions(vsg PRIVATE VSG_USE_DYNAMIC_CAST) - else () - target_compile_definitions(vsg PRIVATE VSG_EXPORTS) - endif () - endif() +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT VSG_USE_DYNAMIC_CAST) + # Static build, Clang, and we are not using dynamic_cast: + # export Array/Value/etc. to stabilize typeid. + target_compile_definitions(vsg PRIVATE VSG_EXPORTS) endif() # install headers diff --git a/src/vsg/core/Version.h.in b/src/vsg/core/Version.h.in index 1926da8292..2fdf97735b 100644 --- a/src/vsg/core/Version.h.in +++ b/src/vsg/core/Version.h.in @@ -45,6 +45,9 @@ extern "C" /// Native Windowing support provided with vsg::Window::create(windowTraits) enabled when 1, disabled when 0 #define VSG_SUPPORTS_Windowing @VSG_SUPPORTS_Windowing@ + /// Define VSG_USE_DYNAMIC_CAST to avoid typeid(T) comparisons in vsg::Object::cast() + #define VSG_USE_DYNAMIC_CAST @VSG_USE_DYNAMIC_CAST@ + struct VsgVersion { unsigned int major;