diff --git a/CMakeLists.txt b/CMakeLists.txt index ddee8c3..09eafcb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,10 @@ if (WIN32) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) endif() +if(LINUX) + #add_compile_definitions(-msse -mfpmath=sse) +endif() + # settings used across all formats include_directories(src) @@ -165,7 +169,27 @@ elseif(WIN32) COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}\\${CMAKE_BUILD_TYPE}\\${PROJECT_NAME}_plugin.dll" "%LOCALAPPDATA%\\Programs\\Common\\CLAP\\${PROJECT_NAME}.clap" ) endif() # MSVC -endif() +elseif(LINUX) + add_library(${PROJECT_NAME}_plugin MODULE + example/example.c + src/cplug_clap.c + src/cplug_vst3.c + ) + set_target_properties(${PROJECT_NAME}_plugin PROPERTIES + OUTPUT_NAME ${PROJECT_NAME}_plugin + ) + add_custom_command(TARGET ${PROJECT_NAME}_plugin POST_BUILD + COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.vst3" + + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.clap" "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.vst3" + + COMMAND ${CMAKE_COMMAND} -E echo "Installing ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.clap to ~/.clap/" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.clap" "~/.clap/${PROJECT_NAME}.clap" + + COMMAND ${CMAKE_COMMAND} -E echo "Installing ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.vst3 to ~/.vst3" + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${PROJECT_NAME}.vst3" "~/.vst3/${PROJECT_NAME}.vst3" + ) +endif() #LINUX # ███████╗████████╗ █████╗ ███╗ ██╗██████╗ █████╗ ██╗ ██████╗ ███╗ ██╗███████╗ diff --git a/example/example.c b/example/example.c index 5665466..b2e9725 100644 --- a/example/example.c +++ b/example/example.c @@ -17,6 +17,17 @@ unsigned int newMXCSR = oldMXCSR |= 0x8040; /* set DAZ and FZ bits */ \ _mm_setcsr(newMXCSR); /* write the new MXCSR setting to the MXCSR */ #define RESTORE_DENORMALS _mm_setcsr(oldMXCSR); +#elif defined(__linux__) +#ifdef __x86_64__ +#include +#include +#define DISABLE_DENORMALS \ + uint32_t oldMXCSR, newMXCSR; \ + __builtin_ia32_fxsave(&oldMXCSR); \ + newMXCSR = oldMXCSR |= 0x8040; \ + __builtin_ia32_fxrstor(&newMXCSR); +#define RESTORE_DENORMALS __builtin_ia32_fxrstor(&oldMXCSR); +#endif #else #include #if defined(__x86_64__) diff --git a/src/cplug_clap.c b/src/cplug_clap.c index 41e4431..7087a53 100644 --- a/src/cplug_clap.c +++ b/src/cplug_clap.c @@ -6,6 +6,11 @@ #include #include +// fixes something that's probably an issue with glibc-shipped headers +#ifndef static_assert +#define static_assert(cond, arg) _Static_assert(cond, arg) +#endif + typedef struct CLAPPlugin { clap_plugin_t clapPlugin; diff --git a/src/cplug_vst3.c b/src/cplug_vst3.c index afff859..1f89081 100644 --- a/src/cplug_vst3.c +++ b/src/cplug_vst3.c @@ -10,6 +10,10 @@ #include #include +#ifndef static_assert +#define static_assert(cond, arg) _Static_assert(cond, arg) +#endif + #define tuid_match(a, b) memcmp(a, b, sizeof(Steinberg_TUID)) == 0 #define CPLUG_ARRLEN(a) (sizeof(a) / sizeof(a[0])) @@ -2652,4 +2656,4 @@ bool VST3_EXIT(void) cplug_log("Bundle exit"); cplug_libraryUnload(); return true; -} \ No newline at end of file +} diff --git a/src/test_compile.cpp b/src/test_compile.cpp new file mode 100644 index 0000000..fdc2327 --- /dev/null +++ b/src/test_compile.cpp @@ -0,0 +1,14 @@ +// This fixes an issue caused by possibly glibc-shipped headers +#include +#ifndef char16_t +typedef int16_t char16_t; +#endif + +#include "example/config.h" +#include "src/cplug_clap.c" +#include "src/cplug_vst3.c" + +#ifdef _WIN32 +#include "src/cplug_standalone_win.c" +#include "example/example.c" +#endif