port to MSYS2/clang

This commit is contained in:
wmayer
2021-09-19 19:49:44 +02:00
parent 44272480f4
commit 8cbd92d874
29 changed files with 82 additions and 49 deletions

View File

@@ -62,17 +62,25 @@ macro(SetGlobalCompilerAndLinkerSettings)
endif(MSVC)
if(MINGW)
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12477
# Actually '-Wno-inline-dllimport' should work to suppress warnings of the form:
# inline function 'foo' is declared as dllimport: attribute ignored
# But it doesn't work with MinGW gcc 4.5.0 while using '-Wno-attributes' seems to
# do the trick.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mthreads -Wno-attributes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mthreads -Wno-attributes")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mthreads -Wl,--export-all-symbols")
# http://stackoverflow.com/questions/8375310/warning-auto-importing-has-been-activated-without-enable-auto-import-specifie
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
link_libraries(-lgdi32)
if(CMAKE_COMPILER_IS_CLANGXX)
# clang for MSYS doesn't support -mthreads
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-all-symbols")
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
else()
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12477
# Actually '-Wno-inline-dllimport' should work to suppress warnings of the form:
# inline function 'foo' is declared as dllimport: attribute ignored
# But it doesn't work with MinGW gcc 4.5.0 while using '-Wno-attributes' seems to
# do the trick.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-all-symbols")
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
# http://stackoverflow.com/questions/8375310/warning-auto-importing-has-been-activated-without-enable-auto-import-specifie
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++")
link_libraries(-lgdi32)
endif()
endif(MINGW)
endmacro(SetGlobalCompilerAndLinkerSettings)

View File

@@ -54,8 +54,8 @@ namespace KDTree
inline _Base_iterator(_Base_const_ptr const __N = NULL)
: _M_node(__N) {}
inline _Base_iterator(_Base_iterator const& __THAT)
: _M_node(__THAT._M_node) {}
//inline _Base_iterator(_Base_iterator const& __THAT)
// : _M_node(__THAT._M_node) {}
inline void
_M_increment()

View File

@@ -243,7 +243,7 @@ TARGET_LINK_LIBRARIES(DriverSTL ${SMESH_LIBS} Driver SMDS ${Boost_LIBRARIES})
SET_BIN_DIR(DriverSTL DriverSTL)
if(WIN32)
set_target_properties(DriverSTL PROPERTIES COMPILE_FLAGS "-DMESHDRIVERSTL_EXPORTS -DBASICS_EXPORT -DSMESHUtils_EXPORTS -DBASICS_EXPORTS")
set_target_properties(DriverSTL PROPERTIES COMPILE_FLAGS "-DMESHDRIVERSTL_EXPORTS -DSMESHUtils_EXPORTS -DBASICS_EXPORTS")
endif(WIN32)

View File

@@ -34,7 +34,7 @@
#else
// avoid name collision with std::byte in C++17
#define NOCRYPT
#define NOGDI
#define NOGDI NOGDI
#include <winsock2.h>
#include <windows.h>
#pragma comment(lib,"winmm.lib")

View File

@@ -126,14 +126,14 @@ public:
void destroy(X* obj)
{
long adrobj = (long) (obj);
intptr_t adrobj = (intptr_t) (obj);
for (size_t i = 0; i < _chunkList.size(); i++)
{
X* chunk = _chunkList[i];
long adrmin = (long) (chunk);
intptr_t adrmin = (intptr_t) (chunk);
if (adrobj < adrmin)
continue;
long adrmax = (long) (chunk + _chunkSize);
intptr_t adrmax = (intptr_t) (chunk + _chunkSize);
if (adrobj >= adrmax)
continue;
int rank = (adrobj - adrmin) / sizeof(X);

View File

@@ -36,7 +36,7 @@ class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position
public:
SMDS_SpacePosition(double x=0, double y=0, double z=0);
virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const;
virtual SMDS_TypeOfPosition GetTypeOfPosition() const;
static SMDS_PositionPtr originSpacePosition();
private:
static SMDS_SpacePosition* _originPosition;

View File

@@ -50,7 +50,7 @@ typedef void (*PVF)();
class SMESH_EXPORT Unexpect { //save / retrieve unexpected exceptions treatment
PVF old;
public :
#ifndef WNT
#ifndef _MSC_VER
// std::set_unexpected has been removed in C++17
Unexpect( PVF f )
{ /*old = std::set_unexpected(f);*/old = f; }
@@ -66,7 +66,7 @@ class SMESH_EXPORT Terminate {//save / retrieve terminate function
PVF old;
public :
#ifndef WNT
#ifndef _MSC_VER
Terminate( PVF f )
{ old = std::set_terminate(f); }
~Terminate() { std::set_terminate(old); }

View File

@@ -46,7 +46,7 @@
#include <list>
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning(disable:4251) // Warning DLL Interface ...
#pragma warning(disable:4290) // Warning Exception ...
#endif

View File

@@ -38,7 +38,7 @@ typedef void (*PVF)();
class UTILS_EXPORT Unexpect { //save / retrieve unexpected exceptions treatment
PVF old;
public :
#ifndef WIN32
#ifndef _MSC_VER
// std::set_unexpected has been removed in C++17
Unexpect( PVF f )
{ /*old = std::set_unexpected(f);*/old = f; }
@@ -54,7 +54,7 @@ class UTILS_EXPORT Terminate {//save / retrieve terminate function
PVF old;
public :
#ifndef WIN32
#ifndef _MSC_VER
Terminate( PVF f )
{ old = std::set_terminate(f); }
~Terminate() { std::set_terminate(old); }

View File

@@ -23,8 +23,10 @@
#include "DriverSTL_W_SMDS_Mesh.h"
#ifdef WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#endif
#include <Basics_Utils.hxx>

View File

@@ -141,7 +141,8 @@ void SMESH_File::close()
_pos = _end = 0;
_size = -1;
}
else if ( _file >= 0 )
//else if ( _file >= 0 )
else if ( _file != 0 )
{
#ifdef WIN32
if(_file != INVALID_HANDLE_VALUE) {

View File

@@ -102,11 +102,11 @@ namespace HERE = StdMeshers_ProjectionUtils;
namespace {
static SMESHDS_Mesh* theMeshDS[2] = { 0, 0 }; // used for debug only
inline long shapeIndex(const TopoDS_Shape& S)
inline intptr_t shapeIndex(const TopoDS_Shape& S)
{
if ( theMeshDS[0] && theMeshDS[1] )
return max(theMeshDS[0]->ShapeToIndex(S), theMeshDS[1]->ShapeToIndex(S) );
return long(S.TShape().operator->());
return intptr_t(S.TShape().operator->());
}
//================================================================================

View File

@@ -41,7 +41,11 @@ namespace Base {
// members
static std::vector<SequencerBase*> _instances; /**< A vector of all created instances */
static SequencerLauncher* _topLauncher; /**< The outermost launcher */
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
static QRecursiveMutex mutex; /**< A mutex-locker for the launcher */
#else
static QMutex mutex; /**< A mutex-locker for the launcher */
#endif
/** Sets a global sequencer object.
* Access to the last registered object is performed by @see Sequencer().
*/
@@ -67,7 +71,11 @@ namespace Base {
*/
std::vector<SequencerBase*> SequencerP::_instances;
SequencerLauncher* SequencerP::_topLauncher = 0;
#if QT_VERSION >= QT_VERSION_CHECK(5,14,0)
QRecursiveMutex SequencerP::mutex;
#else
QMutex SequencerP::mutex(QMutex::Recursive);
#endif
}
SequencerBase& SequencerBase::Instance ()

View File

@@ -26,7 +26,7 @@
#ifndef _PreComp_
# include <sstream>
# include <QDateTime>
# if defined(FC_OS_LINUX)
# if defined(FC_OS_LINUX) || defined(__MINGW32__)
# include <sys/time.h>
# endif
#endif
@@ -60,7 +60,7 @@ TimeInfo::~TimeInfo()
void TimeInfo::setCurrent(void)
{
#if defined (FC_OS_BSD) || defined(FC_OS_LINUX)
#if defined (FC_OS_BSD) || defined(FC_OS_LINUX) || defined(__MINGW32__)
struct timeval t;
gettimeofday(&t, NULL);
timebuffer.time = t.tv_sec;

View File

@@ -55,7 +55,7 @@
namespace Py
{
typedef Py_ssize_t sequence_index_type; // type of an index into a sequence
Py_ssize_t numeric_limits_max();
PYCXX_EXPORT Py_ssize_t numeric_limits_max();
// Forward declarations
class Object;

View File

@@ -454,7 +454,7 @@ public:
*
* @sa Command::_doCommand()
*/
#ifdef FC_OS_WIN32
#ifdef _MSC_VER
#define doCommand(_type,...) _doCommand(__FILE__,__LINE__,_type,##__VA_ARGS__)
#else
#define doCommand(...) _doCommand(__FILE__,__LINE__,__VA_ARGS__)

View File

@@ -165,7 +165,7 @@ private:
/**
* @brief The ViewProviderWeakPtrT class
*/
class AppExport ViewProviderWeakPtrT
class GuiExport ViewProviderWeakPtrT
{
public:
ViewProviderWeakPtrT(ViewProviderDocumentObject*);

View File

@@ -56,7 +56,7 @@
/** DllMain is called when DLL is loaded
*/
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH: {

View File

@@ -31,6 +31,7 @@
#if defined(__MINGW32__)
# include <GL/gl.h>
# include <GL/glu.h>
# include <GL/glext.h>
#elif defined (FC_OS_MACOSX)
# include <OpenGL/gl.h>

View File

@@ -30,8 +30,8 @@
namespace MeshCore {
template<> const float Math<float> ::PI = (float)(4.0*atan(1.0));
template<> const double Math<double>::PI = 4.0*atan(1.0);
template<> MeshExport const float Math<float> ::PI = (float)(4.0*atan(1.0));
template<> MeshExport const double Math<double>::PI = 4.0*atan(1.0);
float MeshDefinitions::_fMinPointDistance = float(MESH_MIN_PT_DIST);
float MeshDefinitions::_fMinPointDistanceP2 = _fMinPointDistance * _fMinPointDistance;

View File

@@ -1471,7 +1471,7 @@ void SoBrepFaceSet::VBO::render(SoGLRenderAction * action,
const cc_glglue * glue = cc_glglue_instance(action->getCacheContext());
PFNGLBINDBUFFERARBPROC glBindBufferARB = (PFNGLBINDBUFFERARBPROC) cc_glglue_getprocaddress(glue, "glBindBufferARB");
PFNGLMAPBUFFERARBPROC glMapBufferARB = (PFNGLMAPBUFFERARBPROC) cc_glglue_getprocaddress(glue, "glMapBufferARB");
//PFNGLMAPBUFFERARBPROC glMapBufferARB = (PFNGLMAPBUFFERARBPROC) cc_glglue_getprocaddress(glue, "glMapBufferARB");
PFNGLGENBUFFERSPROC glGenBuffersARB = (PFNGLGENBUFFERSPROC)cc_glglue_getprocaddress(glue, "glGenBuffersARB");
PFNGLDELETEBUFFERSARBPROC glDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC)cc_glglue_getprocaddress(glue, "glDeleteBuffersARB");
PFNGLBUFFERDATAARBPROC glBufferDataARB = (PFNGLBUFFERDATAARBPROC)cc_glglue_getprocaddress(glue, "glBufferDataARB");

View File

@@ -145,6 +145,15 @@ target_link_libraries(Path ${Path_LIBS})
if(NOT ${Boost_VERSION} LESS 107500)
set_target_properties(Path PROPERTIES CXX_STANDARD_REQUIRED ON)
set_target_properties(Path PROPERTIES CXX_STANDARD 14)
# Suppress -Wc++17-extensions when using OCCT 7.5 or newer
if (MINGW AND CMAKE_COMPILER_IS_CLANGXX)
unset(_flag_found CACHE)
check_cxx_compiler_flag("-Wno-c++17-extensions" _flag_found)
if (_flag_found)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++17-extensions")
endif()
endif()
endif()
if(FREECAD_USE_PCH)

View File

@@ -10,7 +10,7 @@
//
/////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning( disable : 4996 )
#ifndef WINVER
#define WINVER 0x501
@@ -772,7 +772,7 @@ inline bool FNEZ(double a, double tolerance = TIGHT_TOLERANCE) {return fabs(a) >
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning(disable:4522)
#endif
@@ -902,7 +902,7 @@ inline bool FNEZ(double a, double tolerance = TIGHT_TOLERANCE) {return fabs(a) >
PK_BODY_t ToPKlofted_thickened_body(Kurve &sec, double thickness);
#endif
};
#ifdef WIN32
#ifdef _MSC_VER
#pragma warning(default:4522)
#endif

View File

@@ -40,7 +40,7 @@
#include "PointsAlgos.h"
#include "PointsPy.h"
#ifdef _WIN32
#ifdef _MSC_VER
# include <ppl.h>
#endif
@@ -85,7 +85,7 @@ Data::Segment* PointKernel::getSubElement(const char* /*Type*/, unsigned long /*
void PointKernel::transformGeometry(const Base::Matrix4D &rclMat)
{
std::vector<value_type>& kernel = getBasicPoints();
#ifdef _WIN32
#ifdef _MSC_VER
// Win32-only at the moment since ppl.h is a Microsoft library. Points is not using Qt so we cannot use QtConcurrent
// We could also rewrite Points to leverage SIMD instructions
// Other option: openMP. But with VC2013 results in high CPU usage even after computation (busy-waits for >100ms)
@@ -103,7 +103,7 @@ Base::BoundBox3d PointKernel::getBoundBox(void)const
{
Base::BoundBox3d bnd;
#ifdef _WIN32
#ifdef _MSC_VER
// Thread-local bounding boxes
Concurrency::combinable<Base::BoundBox3d> bbs;
// Cannot use a const_point_iterator here as it is *not* a proper iterator (fails the for_each template)

View File

@@ -41,7 +41,7 @@
#include "PointsPy.h"
#include <QtConcurrentMap>
#ifdef _WIN32
#ifdef _MSC_VER
# include <ppl.h>
#endif
@@ -393,7 +393,7 @@ void PropertyNormalList::transformGeometry(const Base::Matrix4D &mat)
aboutToSetValue();
// Rotate the normal vectors
#ifdef _WIN32
#ifdef _MSC_VER
Concurrency::parallel_for_each(_lValueList.begin(), _lValueList.end(), [rot](Base::Vector3f& value) {
value = rot * value;
});

View File

@@ -131,6 +131,10 @@ if (_flag_found)
target_compile_options(Robot PRIVATE -Wno-deprecated-copy)
endif()
if(MINGW)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols")
endif()
SET_BIN_DIR(Robot Robot /Mod/Robot)
SET_PYTHON_PREFIX_SUFFIX(Robot)

View File

@@ -337,7 +337,7 @@ bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName
std::getline(inFile,line);
std::string nameTag = line.substr(0,1);
std::string patternName;
unsigned long int commaPos;
std::size_t commaPos;
if ((nameTag == ";") ||
(nameTag == " ") ||
(line.empty()) ) { //is cr/lf empty?
@@ -394,7 +394,7 @@ std::vector<std::string> PATLineSpec::getPatternList(std::string& parmFile)
std::string line;
std::getline(inFile,line);
std::string nameTag = line.substr(0,1); //dupl code here
unsigned long int commaPos;
std::size_t commaPos;
if (nameTag == "*") { //found a pattern
commaPos = line.find(',',1);
std::string patternName;

View File

@@ -208,7 +208,7 @@ std::string LineGroup::getGroupNamesFromFile(std::string FileName)
std::getline(inFile, line);
std::string nameTag = line.substr(0, 1);
std::string found;
unsigned long int commaPos;
std::size_t commaPos;
if (nameTag == "*") {
commaPos = line.find(',', 1);
if (commaPos != std::string::npos) {

View File

@@ -317,7 +317,7 @@ namespace boost
{
return (it.rep->get_data().attrib & _A_HIDDEN) != 0;
}
template <> bool get<user_read>(dir_it const &it)
template <> bool get<user_read>(dir_it const & /*it*/)
{
return true;
}