Commit 059a8f21 authored by Martin Heistermann's avatar Martin Heistermann

Allow completely disabling deprecated APIs with CMake option OVM_ENABLE_DEPRECATED_APIS

At some point in the future, we should switch the default to OFF.
parent 418e5494
Pipeline #11126 passed with stage
in 8 minutes and 10 seconds
include (ACGCommon)
set(OVM_ENABLE_DEPRECATED_APIS ON CACHE BOOL "Support deprecated OpenVolumeMesh APIs")
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/Config/DeprecationConfig.hh.in"
"${CMAKE_CURRENT_BINARY_DIR}/Config/DeprecationConfig.hh"
)
include_directories (
..
${CMAKE_CURRENT_SOURCE_DIR}
......@@ -10,6 +17,7 @@ set (directories
.
OpenVolumeMesh/Attribs
OpenVolumeMesh/Core
OpenVolumeMesh/Config
OpenVolumeMesh/FileManager
OpenVolumeMesh/Geometry
OpenVolumeMesh/Mesh
......@@ -32,6 +40,11 @@ else ()
set_target_properties (OpenVolumeMesh PROPERTIES VERSION ${OPENVOLUMEMESH_VERSION_MAJOR}.${OPENVOLUMEMESH_VERSION_MINOR}
SOVERSION ${OPENVOLUMEMESH_VERSION_MAJOR}.${OPENVOLUMEMESH_VERSION_MINOR} )
endif ()
foreach(TARGET_NAME OpenVolumeMesh OpenVolumeMeshStatic)
if (TARGET ${TARGET_NAME})
target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/Config/")
endif()
endforeach(TARGET_NAME)
# Only install if the project name matches OpenVolumeMesh.
if (NOT APPLE AND ${PROJECT_NAME} MATCHES "OpenVolumeMesh")
......@@ -50,6 +63,10 @@ install(DIRECTORY .
PATTERN "Debian*" EXCLUDE)
endif ()
# install config files
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Config/DeprecationConfig.hh
DESTINATION include/OpenVolumeMesh/Config )
# Only build unittests and file converter
# if not built as external library
if(${PROJECT_NAME} MATCHES "OpenVolumeMesh")
......
#pragma once
#cmakedefine01 OVM_ENABLE_DEPRECATED_APIS
......@@ -81,8 +81,10 @@ public:
void idx(const int& _idx) { idx_ = _idx; }
#if OVM_ENABLE_DEPRECATED_APIS
OVM_DEPRECATED("use explicit .idx() instead")
inline operator int() const { return idx_; }
#endif
void reset() { idx_ = -1; }
......
......@@ -96,10 +96,12 @@ public:
const_iterator end() const { return ptr::shared_ptr<PropT>::get()->end(); }
iterator end() { return ptr::shared_ptr<PropT>::get()->end(); }
#if OVM_ENABLE_DEPRECATED_APIS
OVM_DEPRECATED("use handles to index properties")
reference operator[](size_t _idx) { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
OVM_DEPRECATED("use handles to index properties")
const_reference operator[](size_t _idx) const { return (*ptr::shared_ptr<PropT>::get())[_idx]; }
#endif
reference operator[](const EntityHandleT& _h) { return (*ptr::shared_ptr<PropT>::get())[_h.idx()]; }
const_reference operator[](const EntityHandleT& _h) const { return (*ptr::shared_ptr<PropT>::get())[_h.uidx()]; }
......
#pragma once
#include "DeprecationConfig.hh"
#if defined(__cplusplus) && (__cplusplus >= 201402L)
# define OVM_DEPRECATED(msg) [[deprecated(msg)]]
#elif defined(__GNUC__) || defined(__clang__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment