Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Helper] XCode: run in Debug (and load debug plugins) #5168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Sofa/framework/Helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<INSTALL_INTERFACE:include/extlibs/WinDepPack>")
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 )
Expand Down
44 changes: 39 additions & 5 deletions Sofa/framework/Helper/src/sofa/helper/system/PluginManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down Expand Up @@ -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)
Expand Down
Loading