From 636f1acf0401e688434c780473697cf59da7cf47 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Mon, 16 Dec 2024 12:42:30 +0900 Subject: [PATCH] remove deprecated cmake statement --- Sofa/framework/Helper/CMakeLists.txt | 5 --- .../src/sofa/helper/system/PluginManager.cpp | 44 ++++++++++++++++--- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Sofa/framework/Helper/CMakeLists.txt b/Sofa/framework/Helper/CMakeLists.txt index f78ff2917ee..b1e84de9954 100644 --- a/Sofa/framework/Helper/CMakeLists.txt +++ b/Sofa/framework/Helper/CMakeLists.txt @@ -216,11 +216,6 @@ add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES}) if((CMAKE_SYSTEM_NAME STREQUAL Windows) AND SOFA_USE_DEPENDENCY_PACK) target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "$") endif() -# The default binary suffix for libraries/plugins is "_d" when using a debug build. -# since this is configuration specific it is a bit more convenient to put it as a debug compile definition for -# PluginManager.cpp, at the expense of being much less visible compare to having it in the generated -# SofaFramework/config.h -set_property(SOURCE ${SRC_ROOT}/system/PluginManager.cpp APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG "SOFA_LIBSUFFIX=_d" ) # DEPENDENCY LINKS AND INCLUDE DIRS target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Config ) diff --git a/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp b/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp index 2c60200c2bc..35ec52d97b1 100644 --- a/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp +++ b/Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp @@ -51,6 +51,37 @@ constexpr std::string_view GetSofaBuildConfigurationString() return SOFA_BUILD_CONFIGURATION_STR; } +enum class SofaBuildConfiguration +{ + Release, + RelWithDebInfo, + Debug, + MinSizeRel, + NonStandard +}; + +constexpr SofaBuildConfiguration GetSofaBuildConfiguration() +{ + if constexpr (GetSofaBuildConfigurationString() == "Release") + { + return SofaBuildConfiguration::Release; + } + if constexpr (GetSofaBuildConfigurationString() == "RelWithDebInfo") + { + return SofaBuildConfiguration::RelWithDebInfo; + } + if constexpr (GetSofaBuildConfigurationString() == "Debug") + { + return SofaBuildConfiguration::Debug; + } + if constexpr (GetSofaBuildConfigurationString() == "MinSizeRel") + { + return SofaBuildConfiguration::MinSizeRel; + } + + return SofaBuildConfiguration::NonStandard; +} + namespace sofa::helper::system { @@ -157,11 +188,14 @@ void PluginManager::writeToIniFile(const std::string& path) /// (depends on platform, version, debug/release build) std::string PluginManager::getDefaultSuffix() { -#ifdef SOFA_LIBSUFFIX - return sofa_tostring(SOFA_LIBSUFFIX); -#else - return std::string(); -#endif + if constexpr(GetSofaBuildConfiguration() == SofaBuildConfiguration::Debug) + { + return "_d"; + } + else + { + return ""; + } } PluginManager::PluginLoadStatus PluginManager::loadPluginByPath(const std::string& pluginPath, std::ostream* errlog)