Skip to content

Commit ec3e907

Browse files
authored
Merge pull request #1342 from MehdiChinoune/mingw-fixes
Fix building on MinGW
2 parents 30ec1ab + 5a63a33 commit ec3e907

21 files changed

+52
-45
lines changed

cmake/FindBlosc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ list(APPEND _BLOSC_LIBRARYDIR_SEARCH_DIRS
192192

193193
set(_BLOSC_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
194194

195-
if(WIN32)
195+
if(MSVC)
196196
if(BLOSC_USE_STATIC_LIBS)
197197
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
198198
endif()

cmake/FindCppUnit.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ list(APPEND _CPPUNIT_LIBRARYDIR_SEARCH_DIRS
169169

170170
set(_CPPUNIT_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
171171

172-
if(WIN32)
172+
if(MSVC)
173173
if(CPPUNIT_USE_STATIC_LIBS)
174174
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
175175
else()

cmake/FindJemalloc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ list(APPEND _JEMALLOC_LIBRARYDIR_SEARCH_DIRS
114114

115115
set(_JEMALLOC_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
116116

117-
if(WIN32)
117+
if(MSVC)
118118
if(JEMALLOC_USE_STATIC_LIBS)
119119
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
120120
else()

cmake/FindLog4cplus.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ list(APPEND _LOG4CPLUS_LIBRARYDIR_SEARCH_DIRS
185185

186186
set(_LOG4CPLUS_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
187187

188-
if(WIN32)
188+
if(MSVC)
189189
if(LOG4CPLUS_USE_STATIC_LIBS)
190190
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
191191
endif()

cmake/FindOpenVDB.cmake

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ list(REMOVE_DUPLICATES OPENVDB_PYTHON_PATH_SUFFIXES)
357357
list(REMOVE_DUPLICATES OPENVDB_LIB_PATH_SUFFIXES)
358358

359359
# Static library setup
360-
if(WIN32)
360+
if(MSVC)
361361
if(OPENVDB_USE_STATIC_LIBS)
362362
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
363363
endif()
@@ -570,6 +570,10 @@ if(WIN32)
570570
list(APPEND OpenVDB_DEFINITIONS NOMINMAX)
571571
endif()
572572

573+
if(MINGW)
574+
list(APPEND OpenVDB_DEFINITIONS _USE_MATH_DEFINES)
575+
endif()
576+
573577
if(OpenVDB_ABI)
574578
# Newer version of OpenVDB defines this in version.h, but it is are also
575579
# provided here to maintain backwards compatibility with header include
@@ -655,8 +659,8 @@ if(OpenVDB_USES_IMATH_HALF)
655659
if(WIN32)
656660
# @note OPENVDB_OPENEXR_STATICLIB is old functionality and should be removed
657661
if(OPENEXR_USE_STATIC_LIBS OR
658-
(${ILMBASE_LIB_TYPE} STREQUAL STATIC_LIBRARY) OR
659-
(${IMATH_LIB_TYPE} STREQUAL STATIC_LIBRARY))
662+
("${ILMBASE_LIB_TYPE}" STREQUAL "STATIC_LIBRARY") OR
663+
("${IMATH_LIB_TYPE}" STREQUAL "STATIC_LIBRARY"))
660664
list(APPEND OpenVDB_DEFINITIONS OPENVDB_OPENEXR_STATICLIB)
661665
endif()
662666
endif()

cmake/FindTBB.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ if(NOT DEFINED TBB_DEBUG_SUFFIX)
231231
endif()
232232
set(_TBB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
233233

234-
if(WIN32)
234+
if(MSVC)
235235
if(TBB_USE_STATIC_LIBS)
236236
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
237237
endif()

openvdb/openvdb/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ endif()
187187
if(USE_BLOSC OR USE_ZLIB)
188188
if(USE_STATIC_DEPENDENCIES)
189189
set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
190-
if(WIN32)
190+
if(MSVC)
191191
set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
192192
else()
193193
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
@@ -613,6 +613,10 @@ endif()
613613
# Private defines (not inherited by dependent projects)
614614
list(APPEND OPENVDB_CORE_PRIVATE_DEFINES -DOPENVDB_PRIVATE)
615615

616+
if(MINGW)
617+
list(APPEND OPENVDB_CORE_PUBLIC_DEFINES -D_USE_MATH_DEFINES)
618+
endif()
619+
616620
if(WIN32)
617621
if(USE_IMATH_HALF)
618622
# @note OPENVDB_OPENEXR_STATICLIB is old functionality and should be removed

openvdb/openvdb/Platform.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,6 @@
214214
#ifdef OPENVDB_IMPORT
215215
#undef OPENVDB_IMPORT
216216
#endif
217-
#ifdef __GNUC__
218-
#define OPENVDB_EXPORT __attribute__((visibility("default")))
219-
#define OPENVDB_IMPORT __attribute__((visibility("default")))
220-
#endif
221217
#ifdef _WIN32
222218
#ifdef OPENVDB_DLL
223219
#define OPENVDB_EXPORT __declspec(dllexport)
@@ -226,6 +222,9 @@
226222
#define OPENVDB_EXPORT
227223
#define OPENVDB_IMPORT
228224
#endif
225+
#elif defined(__GNUC__)
226+
#define OPENVDB_EXPORT __attribute__((visibility("default")))
227+
#define OPENVDB_IMPORT __attribute__((visibility("default")))
229228
#endif
230229

231230
/// Helper macros for explicit template instantiation

openvdb/openvdb/io/Archive.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include <atomic>
3333

34-
#ifdef _MSC_VER
34+
#ifdef _WIN32
3535
#include <boost/interprocess/detail/os_file_functions.hpp> // open_existing_file(), close_file()
3636
extern "C" __declspec(dllimport) bool __stdcall GetFileTime(
3737
void* fh, void* ctime, void* atime, void* mtime);
@@ -459,7 +459,7 @@ class MappedFile::Impl
459459
mLastWriteTime = this->getLastWriteTime();
460460

461461
if (mAutoDelete) {
462-
#ifndef _MSC_VER
462+
#ifndef _WIN32
463463
// On Unix systems, unlink the file so that it gets deleted once it is closed.
464464
::unlink(mMap.get_name());
465465
#endif
@@ -489,7 +489,7 @@ class MappedFile::Impl
489489
Index64 result = 0;
490490
const char* filename = mMap.get_name();
491491

492-
#ifdef _MSC_VER
492+
#ifdef _WIN32
493493
// boost::interprocess::detail was renamed to boost::interprocess::ipcdetail in Boost 1.48.
494494
using namespace boost::interprocess::detail;
495495
using namespace boost::interprocess::ipcdetail;

openvdb/openvdb/io/Compression.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ struct HalfWriter</*IsReal=*/true, T> {
419419
writeData<HalfT>(os, reinterpret_cast<const HalfT*>(&halfData[0]), count, compression);
420420
}
421421
};
422-
#ifdef _MSC_VER
422+
#ifdef _WIN32
423423
/// Specialization to avoid double to float warnings in MSVC
424424
template<>
425425
struct HalfWriter</*IsReal=*/true, double> {
@@ -442,7 +442,7 @@ struct HalfWriter</*IsReal=*/true, double> {
442442
writeData<HalfT>(os, reinterpret_cast<const HalfT*>(&halfData[0]), count, compression);
443443
}
444444
};
445-
#endif // _MSC_VER
445+
#endif // _WIN32
446446

447447

448448
////////////////////////////////////////

0 commit comments

Comments
 (0)