Fix compilation with MinGW versions without threads support
Older versions of MinGW don't provide std::mutex or std::thread
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -28,3 +28,6 @@
|
||||
[submodule "src/3rdparty/weakjack/weakjack"]
|
||||
path = src/3rdparty/weakjack/weakjack
|
||||
url = https://github.com/x42/weakjack.git
|
||||
[submodule "src/3rdparty/mingw-std-threads"]
|
||||
path = src/3rdparty/mingw-std-threads
|
||||
url = https://github.com/meganz/mingw-std-threads.git
|
||||
|
||||
@@ -37,4 +37,4 @@ fi
|
||||
CMAKE_OPTS="-DCMAKE_PREFIX_PATH=$MINGW $CMAKE_OPTS"
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" -DCMAKE_MODULE_PATH="$DIR/../cmake/modules/" $CMAKE_OPTS
|
||||
cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" $CMAKE_OPTS
|
||||
|
||||
@@ -59,7 +59,12 @@
|
||||
#define USE_WS_PREFIX
|
||||
#include <windows.h>
|
||||
|
||||
#include <mutex>
|
||||
#ifdef USE_MINGW_THREADS_REPLACEMENT
|
||||
# include <mingw.mutex.h>
|
||||
#else
|
||||
# include <mutex>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
@@ -4,9 +4,11 @@ project(RemoteVstPlugin
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
include(CheckCXXPreprocessor)
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
CHECK_CXX_DEFINE(IS_WIN "_WIN32")
|
||||
CHECK_CXX_DEFINE(IS_WIN64 "_WIN64")
|
||||
CHECK_CXX_DEFINE(IS_MINGW "__MINGW32__")
|
||||
|
||||
if(NOT IS_WIN)
|
||||
message(FATAL_ERROR "Toolchain used does not target windows.")
|
||||
@@ -35,6 +37,25 @@ if(WIN32)
|
||||
target_link_libraries(${EXE_NAME} Qt5::Core)
|
||||
endif()
|
||||
|
||||
if(IS_MINGW)
|
||||
SET(CMAKE_REQUIRED_FLAGS "-std=c++11")
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <mutex>
|
||||
int main(int argc, const char* argv[]) {
|
||||
std::mutex m;
|
||||
return 0;
|
||||
}
|
||||
" HAS_STD_MUTEX)
|
||||
|
||||
if(NOT HAS_STD_MUTEX)
|
||||
target_include_directories(${EXE_NAME} PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/src/3rdparty/mingw-std-threads")
|
||||
target_compile_definitions(${EXE_NAME} PRIVATE
|
||||
-DUSE_MINGW_THREADS_REPLACEMENT)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(STRIP)
|
||||
ADD_CUSTOM_COMMAND(TARGET RemoteVstPlugin32 POST_BUILD COMMAND "${STRIP}" "$<TARGET_FILE:RemoteVstPlugin32>")
|
||||
ENDIF()
|
||||
|
||||
1
src/3rdparty/mingw-std-threads
vendored
Submodule
1
src/3rdparty/mingw-std-threads
vendored
Submodule
Submodule src/3rdparty/mingw-std-threads added at 10665829da
Reference in New Issue
Block a user