diff --git a/CMakeLists.txt b/CMakeLists.txt index eb471dc..7be5fea 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/include/wrapper/CopyReplyAddress.cpp b/include/wrapper/CopyReplyAddress.cpp new file mode 100644 index 0000000..0346b23 --- /dev/null +++ b/include/wrapper/CopyReplyAddress.cpp @@ -0,0 +1,51 @@ + +#include "CopyReplyAddress.hpp" +#include +#include + +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(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(inreply)); + + return reply; +} + +void deleteReplyAddress(void* inreply) +{ + if(! inreply) return; + delete (ReplyAddress*)inreply; +} + +void SendReply(void* inReplyAddr, char* inBuf, int inSize) { + SendReply(static_cast(inReplyAddr),inBuf,inSize); +} + + +} +} diff --git a/include/wrapper/CopyReplyAddress.hpp b/include/wrapper/CopyReplyAddress.hpp index 6506779..fcc6ba8 100644 --- a/include/wrapper/CopyReplyAddress.hpp +++ b/include/wrapper/CopyReplyAddress.hpp @@ -1,46 +1,15 @@ #pragma once -#include +#include 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(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(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); } diff --git a/include/wrapper/Messaging.hpp b/include/wrapper/Messaging.hpp index ed40cb1..cf7b4c3 100644 --- a/include/wrapper/Messaging.hpp +++ b/include/wrapper/Messaging.hpp @@ -2,6 +2,7 @@ #include "ArgsFromClient.hpp" #include "ArgsToClient.hpp" +#include "CopyReplyAddress.hpp" #include namespace fluid { @@ -225,7 +226,7 @@ struct FluidSCMessaging{ ToOSCTypes::convert(packet, static_cast(result)); if(replyAddr) - ::SendReply(static_cast(replyAddr),packet.data(),static_cast(packet.size())); + SendReply(replyAddr,packet.data(),static_cast(packet.size())); } static void messageOutput(const std::string& s,index id, MessageResult&, void* replyAddr) @@ -238,7 +239,7 @@ struct FluidSCMessaging{ packet.addi(static_cast(id)); if(replyAddr) - ::SendReply(static_cast(replyAddr),packet.data(),static_cast(packet.size())); + SendReply(replyAddr,packet.data(),static_cast(packet.size())); } template @@ -264,7 +265,7 @@ struct FluidSCMessaging{ ToOSCTypes::convert(packet, static_cast(result)); if(replyAddr) - ::SendReply(static_cast(replyAddr),packet.data(),static_cast(packet.size())); + SendReply(replyAddr,packet.data(),static_cast(packet.size())); } }; diff --git a/include/wrapper/NonRealtime.hpp b/include/wrapper/NonRealtime.hpp index 254f19b..7eaca7a 100644 --- a/include/wrapper/NonRealtime.hpp +++ b/include/wrapper/NonRealtime.hpp @@ -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 +#include #include -#include #include #include @@ -143,7 +142,7 @@ namespace impl { packet.addi(success); packet.addi(static_cast(mID)); - ::SendReply(static_cast(mReplyAddress),packet.data(), static_cast(packet.size())); + SendReply(mReplyAddress,packet.data(), static_cast(packet.size())); } } // protected: diff --git a/scripts/target_post.cmake b/scripts/target_post.cmake index 48da1e6..cdc0910 100644 --- a/scripts/target_post.cmake +++ b/scripts/target_post.cmake @@ -7,23 +7,18 @@ 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 ) -endif() + + #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 CXX_STANDARD 14 @@ -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" - # $ + ${FLUID_SC_HEADERS} ) target_include_directories(