Skip to content
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
10 changes: 10 additions & 0 deletions Sofa/framework/Type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,23 @@ if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost (${BOOST_MIN_VERSION} or higher) is mandatory.")
endif()
endif()

sofa_find_package(Boost QUIET REQUIRED)

option(SOFA_USE_MIMALLOC "Use mimalloc to replace malloc (known to be more efficient, especially with MSVC)" OFF)
if(SOFA_USE_MIMALLOC)
sofa_find_package(mimalloc REQUIRED)
endif()

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})

target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Config)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::boost)

if(mimalloc_FOUND)
target_link_libraries(${PROJECT_NAME} PUBLIC mimalloc)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES FOLDER Sofa.Framework) # IDE folder

sofa_create_package_with_targets(
Expand Down
2 changes: 2 additions & 0 deletions Sofa/framework/Type/src/sofa/type/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#include <sofa/config.h>

#cmakedefine01 SOFA_TYPE_HAVE_MIMALLOC

#define SOFATYPE_VERSION @PROJECT_VERSION@

#ifdef SOFA_BUILD_SOFA_TYPE
Expand Down
8 changes: 8 additions & 0 deletions Sofa/framework/Type/src/sofa/type/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

#include <iostream>

#if SOFA_TYPE_HAVE_MIMALLOC == 1
#include <mimalloc.h>
#endif


namespace sofa::type
{

Expand All @@ -33,6 +38,9 @@ SOFA_TYPE_API void init()
{
if (!s_initialized)
{
#if SOFA_TYPE_HAVE_MIMALLOC == 1
mi_version();
#endif
s_initialized = true;
}
}
Expand Down
Loading