Fix windows build errors by sandboxing new SendReply dependency

Deals with macro name clashes, and also better enacapsulates unfortunate 
dep on SC internals, as well as improving build times
nix
Owen Green 5 years ago
parent 0fc7272c38
commit 8b37813b43

@ -30,6 +30,22 @@ endif()
################################################################################
# Main project
project (flucoma-sc LANGUAGES CXX)
if(NOT MSVC)
add_compile_options(-fdiagnostics-color=always)
endif()
#set correct std lib linking for Windows (in CMake 3.15 this has a native function)
if(MSVC) #needs to be after project()
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)
@ -86,7 +102,36 @@ endif()
#needed for complaint-free static linking with GCC
if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options( HISSTools_FFT PUBLIC -fPIC )
ENDIF()
endif()
#sandbox regrettable dependency on SC internals for SendReply()
add_library(FLUID_SC_COPYREPLYADDR STATIC
"${CMAKE_SOURCE_DIR}/include/wrapper/CopyReplyAddress.cpp"
"${SC_PATH}/common/SC_Reply.cpp"
"${SC_PATH}/external_libraries/boost/libs/system/src/error_code.cpp"
)
target_include_directories(FLUID_SC_COPYREPLYADDR SYSTEM PRIVATE
"${SC_PATH}/include/plugin_interface"
"${SC_PATH}/include/common"
"${SC_PATH}/common"
"${SC_PATH}/external_libraries/boost"
)
set_target_properties(FLUID_SC_COPYREPLYADDR PROPERTIES
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(FLUID_SC_COPYREPLYADDR PUBLIC -fPIC )
endif()
if(APPLE)
target_compile_options(FLUID_SC_COPYREPLYADDR PRIVATE -stdlib=libc++)
endif()
target_compile_definitions(FLUID_SC_COPYREPLYADDR PRIVATE BOOST_ALL_NO_LIB BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE)
add_library(FLUID_SC_WRAPPER INTERFACE)
target_include_directories(FLUID_SC_WRAPPER
@ -100,6 +145,8 @@ target_sources(FLUID_SC_WRAPPER
"${CMAKE_CURRENT_SOURCE_DIR}/include/SCBufferAdaptor.hpp"
)
target_link_libraries(FLUID_SC_WRAPPER INTERFACE FLUID_SC_COPYREPLYADDR)
SUBDIRLIST(PROJECT_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src")
foreach (project_dir ${PROJECT_DIRS})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/${project_dir}/CMakeLists.txt")
@ -108,6 +155,8 @@ foreach (project_dir ${PROJECT_DIRS})
endif ()
endforeach ()
#install bits.
set(SC_INSTALL_PREFIX "." CACHE PATH "Prefix for assembling SC packages")

@ -0,0 +1,51 @@
#include "CopyReplyAddress.hpp"
#include <SC_Win32Utils.h>
#include <SC_ReplyImpl.hpp>
namespace fluid{
namespace client{
void* copyReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = (ReplyAddress*)ft->fRTAlloc(inWorld, sizeof(ReplyAddress));
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return;
ft->fRTFree(inWorld,(ReplyAddress*)inreply);
}
void* copyReplyAddress(void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = new ReplyAddress();
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(void* inreply)
{
if(! inreply) return;
delete (ReplyAddress*)inreply;
}
void SendReply(void* inReplyAddr, char* inBuf, int inSize) {
SendReply(static_cast<ReplyAddress*>(inReplyAddr),inBuf,inSize);
}
}
}

@ -1,46 +1,15 @@
#pragma once
#include <SC_ReplyImpl.hpp>
#include <SC_PlugIn.h>
namespace fluid{
namespace client{
void* copyReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = (ReplyAddress*)ft->fRTAlloc(inWorld, sizeof(ReplyAddress));
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply)
{
if(! inreply) return;
ft->fRTFree(inWorld,(ReplyAddress*)inreply);
}
void* copyReplyAddress(void* inreply)
{
if(! inreply) return nullptr;
ReplyAddress* reply = new ReplyAddress();
*reply = *(static_cast<ReplyAddress*>(inreply));
return reply;
}
void deleteReplyAddress(void* inreply)
{
if(! inreply) return;
delete (ReplyAddress*)inreply;
}
void* copyReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply);
void deleteReplyAddress(InterfaceTable* ft, World* inWorld, void* inreply);
void* copyReplyAddress(void* inreply);
void deleteReplyAddress(void* inreply);
void SendReply(void* inReplyAddr, char* inBuf, int inSize);
}

@ -2,6 +2,7 @@
#include "ArgsFromClient.hpp"
#include "ArgsToClient.hpp"
#include "CopyReplyAddress.hpp"
#include <scsynthsend.h>
namespace fluid {
@ -225,7 +226,7 @@ struct FluidSCMessaging{
ToOSCTypes<small_scpacket>::convert(packet, static_cast<T>(result));
if(replyAddr)
::SendReply(static_cast<ReplyAddress*>(replyAddr),packet.data(),static_cast<int>(packet.size()));
SendReply(replyAddr,packet.data(),static_cast<int>(packet.size()));
}
static void messageOutput(const std::string& s,index id, MessageResult<void>&, void* replyAddr)
@ -238,7 +239,7 @@ struct FluidSCMessaging{
packet.addi(static_cast<int>(id));
if(replyAddr)
::SendReply(static_cast<ReplyAddress*>(replyAddr),packet.data(),static_cast<int>(packet.size()));
SendReply(replyAddr,packet.data(),static_cast<int>(packet.size()));
}
template <typename... Ts>
@ -264,7 +265,7 @@ struct FluidSCMessaging{
ToOSCTypes<small_scpacket>::convert(packet, static_cast<T>(result));
if(replyAddr)
::SendReply(static_cast<ReplyAddress*>(replyAddr),packet.data(),static_cast<int>(packet.size()));
SendReply(replyAddr,packet.data(),static_cast<int>(packet.size()));
}
};

@ -1,15 +1,14 @@
#pragma once
#include "BufferFuncs.hpp"
#include "Meta.hpp"
#include "SCBufferAdaptor.hpp"
#include "CopyReplyAddress.hpp"
#include "Messaging.hpp"
#include "Meta.hpp"
#include "RealTimeBase.hpp"
#include "SCBufferAdaptor.hpp"
#include <clients/common/FluidBaseClient.hpp>
#include <data/FluidMeta.hpp>
#include <SC_PlugIn.hpp>
#include <SC_ReplyImpl.hpp>
#include <scsynthsend.h>
#include <map>
@ -143,7 +142,7 @@ namespace impl {
packet.addi(success);
packet.addi(static_cast<int>(mID));
::SendReply(static_cast<ReplyAddress*>(mReplyAddress),packet.data(), static_cast<int>(packet.size()));
SendReply(mReplyAddress,packet.data(), static_cast<int>(packet.size()));
}
}
// protected:

@ -7,22 +7,17 @@
target_compile_features(${PLUGIN} PRIVATE cxx_std_14)
if(MSVC)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()
if(MSVC)
target_compile_options(${PLUGIN} PRIVATE /W3)
else()
target_compile_options(${PLUGIN} PRIVATE
-Wall -Wextra -Wpedantic -Wreturn-type -Wconversion -Wno-c++11-narrowing
-Wall -Wextra -Wpedantic -Wreturn-type -Wconversion
)
#GCC doesn't have Wno-c++11-narrowing
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(${PLUGIN} PRIVATE -Wno-c++11-narrowing)
endif()
endif()
set_target_properties(${PLUGIN} PROPERTIES
@ -43,10 +38,8 @@ target_link_libraries(
${PLUGIN}
PRIVATE
FLUID_DECOMPOSITION
# FLUID_MANIP
FLUID_SC_WRAPPER
HISSTools_FFT
# FLUID_SC_COPYREPLYADDR
)
target_include_directories(
@ -64,11 +57,7 @@ file(GLOB_RECURSE FLUID_SC_HEADERS CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/includ
target_sources(
${PLUGIN} PUBLIC ${FLUID_MANIPULATION_HEADERS}
${FLUID_SC_HEADERS}
#bah. We need to know how big a ReplyAddress struct is, and so this nonsense:
"${SC_PATH}/common/SC_Reply.cpp"
"${SC_PATH}/external_libraries/boost/libs/system/src/error_code.cpp"
# $<TARGET_OBJECTS:FLUID_SC_COPYREPLYADDR>
${FLUID_SC_HEADERS}
)
target_include_directories(

Loading…
Cancel
Save