Fix libcds on MinGW
This commit is contained in:
@@ -151,6 +151,8 @@ INCLUDE_DIRECTORIES(
|
||||
${Qt5Xml_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/src/3rdparty/mingw-std-threads")
|
||||
|
||||
SET(QT_LIBRARIES
|
||||
Qt5::Core
|
||||
Qt5::Gui
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
INCLUDE(CheckCXXSourceCompiles)
|
||||
|
||||
IF(WIN32)
|
||||
SET(LMMS_BUILD_WIN32 1)
|
||||
ELSEIF(APPLE)
|
||||
@@ -86,3 +88,27 @@ IF(LMMS_BUILD_APPLE)
|
||||
STRING(REGEX REPLACE "\\.[0-9]*$" "" APPLE_OS_VER "${APPLE_OS_VER}")
|
||||
SET(CMAKE_MACOSX_RPATH 1)
|
||||
ENDIF()
|
||||
|
||||
# Detect MinGW
|
||||
IF(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(MINGW TRUE)
|
||||
ENDIF()
|
||||
|
||||
# Detect MINGW thread support
|
||||
IF(MINGW)
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
int main(int argc, const char* argv[]) {
|
||||
std::mutex m;
|
||||
std::this_thread::yield();
|
||||
return 0;
|
||||
}
|
||||
" HAS_STD_THREADS)
|
||||
IF(NOT HAS_STD_THREADS)
|
||||
SET(NEED_MINGW_THREADS_REPLACEMENT TRUE)
|
||||
ELSE()
|
||||
SET(NEED_MINGW_THREADS_REPLACEMENT FALSE)
|
||||
ENDIF()
|
||||
MESSAGE(NEED_MINGW_THREADS_REPLACEMENT ${NEED_MINGW_THREADS_REPLACEMENT})
|
||||
ENDIF()
|
||||
|
||||
@@ -5,13 +5,16 @@ set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
|
||||
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
|
||||
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
|
||||
set(MINGW_PREFIX /usr/${TOOLCHAIN_PREFIX})
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
|
||||
SET(ENV{PKG_CONFIG} /usr/bin/${TOOLCHAIN_PREFIX}-pkg-config)
|
||||
|
||||
IF(WIN64)
|
||||
SET(TOOLCHAIN_PREFIX32 ${CMAKE_SYSTEM_PROCESSOR32}-w64-mingw32)
|
||||
SET(CMAKE_C_COMPILER32 ${TOOLCHAIN_PREFIX32}-gcc)
|
||||
SET(CMAKE_CXX_COMPILER32 ${TOOLCHAIN_PREFIX32}-g++)
|
||||
set(MINGW_PREFIX32 /usr/${TOOLCHAIN_PREFIX32})
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/WinCrossCompile.cmake)
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "NiftyCounter.h"
|
||||
|
||||
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
|
||||
# include "mingw-std-threads/thread"
|
||||
# include "mingw-std-threads/mutex"
|
||||
#endif
|
||||
|
||||
namespace _cdslib
|
||||
{
|
||||
void init();
|
||||
|
||||
1
include/mingw-std-threads/mutex
Normal file
1
include/mingw-std-threads/mutex
Normal file
@@ -0,0 +1 @@
|
||||
#include "mingw.mutex.h"
|
||||
1
include/mingw-std-threads/thread
Normal file
1
include/mingw-std-threads/thread
Normal file
@@ -0,0 +1 @@
|
||||
#include "mingw.thread.h"
|
||||
@@ -9,6 +9,13 @@ IF(LMMS_BUILD_APPLE)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
ENDIF()
|
||||
|
||||
IF(MINGW_PREFIX)
|
||||
# There's a bug in some CMake or MinGW versions that passes -std=c++11 when
|
||||
# compiling C files (e.g. fmopl.c). Remove -Werror for plugins to work
|
||||
# around this.
|
||||
STRING(REPLACE "-Werror " "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${SAMPLERATE_INCLUDE_DIRS}
|
||||
"${CMAKE_BINARY_DIR}/src"
|
||||
|
||||
51
src/3rdparty/CMakeLists.txt
vendored
51
src/3rdparty/CMakeLists.txt
vendored
@@ -11,4 +11,53 @@ ENDIF()
|
||||
ADD_SUBDIRECTORY(rpmalloc)
|
||||
ADD_SUBDIRECTORY(weakjack)
|
||||
|
||||
ADD_SUBDIRECTORY(libcds)
|
||||
IF(WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
|
||||
SET(MINGW TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(MINGW)
|
||||
# Work around linking errors with MinGW
|
||||
SET(CDS_LIBRARY_TYPE SHARED)
|
||||
ELSE()
|
||||
SET(CDS_LIBRARY_TYPE STATIC)
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(cds ${CDS_LIBRARY_TYPE}
|
||||
libcds/src/init.cpp
|
||||
libcds/src/hp.cpp
|
||||
libcds/src/dhp.cpp
|
||||
libcds/src/urcu_gp.cpp
|
||||
libcds/src/urcu_sh.cpp
|
||||
libcds/src/thread_data.cpp
|
||||
libcds/src/topology_hpux.cpp
|
||||
libcds/src/topology_linux.cpp
|
||||
libcds/src/topology_osx.cpp
|
||||
libcds/src/dllmain.cpp
|
||||
)
|
||||
SET_TARGET_PROPERTIES(cds PROPERTIES
|
||||
CXX_STANDARD 11
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
)
|
||||
TARGET_INCLUDE_DIRECTORIES(cds
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/libcds"
|
||||
)
|
||||
|
||||
IF(NEED_MINGW_THREADS_REPLACEMENT)
|
||||
# Provide win32 threads implementation
|
||||
TARGET_INCLUDE_DIRECTORIES(cds BEFORE
|
||||
PRIVATE "${CMAKE_SOURCE_DIR}/include/mingw-std-threads"
|
||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/mingw-std-threads"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
IF(CDS_LIBRARY_TYPE STREQUAL "STATIC")
|
||||
TARGET_COMPILE_DEFINITIONS(cds
|
||||
PRIVATE CDS_BUILD_STATIC_LIB
|
||||
)
|
||||
ELSE()
|
||||
TARGET_COMPILE_DEFINITIONS(cds
|
||||
PRIVATE CDS_BUILD_LIB
|
||||
)
|
||||
# Install DLL
|
||||
install(TARGETS cds RUNTIME DESTINATION .)
|
||||
ENDIF()
|
||||
|
||||
@@ -168,7 +168,7 @@ SET(LMMS_REQUIRED_LIBS ${LMMS_REQUIRED_LIBS}
|
||||
${SNDFILE_LIBRARIES}
|
||||
${EXTRA_LIBRARIES}
|
||||
rpmalloc
|
||||
cds-s
|
||||
cds
|
||||
)
|
||||
|
||||
# Expose required libs for tests binary
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <cds/container/vyukov_mpmc_cycle_queue.h>
|
||||
#include "libcds.h"
|
||||
#include <cds/container/vyukov_mpmc_cycle_queue.h>
|
||||
|
||||
#include "Memory.h"
|
||||
|
||||
@@ -24,9 +24,9 @@ class _MemoryPool_Private : MmAllocator<char>
|
||||
using Alloc = MmAllocator<char>;
|
||||
public:
|
||||
_MemoryPool_Private(size_t size, size_t nmemb)
|
||||
: m_freelist(nmemb)
|
||||
, m_elementSize(size)
|
||||
: m_elementSize(size)
|
||||
, m_numElms(nmemb)
|
||||
, m_freelist(nmemb)
|
||||
{
|
||||
m_buffer = new char[m_elementSize * m_numElms];
|
||||
for (size_t i = 0; i < m_numElms; i++) {
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
{
|
||||
if (is_from_pool(ptr)) {
|
||||
bool pushed = m_freelist.push(reinterpret_cast<char*>(ptr));
|
||||
assert(pushed);
|
||||
assert(pushed); Q_UNUSED(pushed);
|
||||
} else {
|
||||
do_deallocate(ptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user