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

[SofaKernel] FIX: A few fix to compile on Mac OSX Xcode 9 and Linux gcc 7.3.0 #969

Merged
merged 7 commits into from
Mar 28, 2019
4 changes: 4 additions & 0 deletions SofaKernel/framework/sofa/core/objectmodel/BaseClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <sofa/core/objectmodel/BaseClass.h>
#include <sofa/helper/logging/Messaging.h>

#ifdef __GNUC__
#include <cxxabi.h>
#endif // __GNUC__

namespace sofa
{

Expand Down
2 changes: 2 additions & 0 deletions SofaKernel/framework/sofa/helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ if(SOFA-EXTERNAL_FFMPEG)

endif()
if(APPLE)
find_library(ICONV iconv)
fspadoni marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(${PROJECT_NAME} PUBLIC ${ICONV})
# on macOS, -framework CoreServices is needed for FileMonitor
list(APPEND SOFAFRAMEWORK_DEPENDENCY_LINK "-framework CoreServices")
endif()
Expand Down
5 changes: 4 additions & 1 deletion SofaKernel/framework/sofa/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ set(SOURCE_FILES
InitTasks.cpp
)


# is this a compiler/linker version specific problem?
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread" )
Copy link
Contributor

@tgaugry tgaugry Mar 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@fspadoni fspadoni Mar 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-pthread should be passed as linking options:
target_link_options(${PROJECT_NAME} PUBLIC "-pthread")
This doesn't work because the target_link_options is available only starting from CMake 3.13

endif()

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC SofaCore)
Expand Down
3 changes: 2 additions & 1 deletion SofaKernel/framework/sofa/simulation/Locks.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace sofa
public:

SpinLock()
:_flag()
{}

~SpinLock()
Expand Down Expand Up @@ -70,7 +71,7 @@ namespace sofa

private:

std::atomic_flag _flag = ATOMIC_FLAG_INIT;
std::atomic_flag _flag;

char _pad [CACHE_LINE - sizeof(std::atomic_flag)];
};
Expand Down