From f2b53c82eb410816271afd4c3847e45e3f9aa495 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 8 May 2021 07:05:33 -0400 Subject: [PATCH] Move definition of AUDACITY_DLL_API into src/CMakeLists.txt --- include/audacity/Types.h | 56 ----------------------------- src/Audacity.h | 31 ---------------- src/CMakeLists.txt | 5 +++ src/widgets/FileDialog/FileDialog.h | 4 --- 4 files changed, 5 insertions(+), 91 deletions(-) diff --git a/include/audacity/Types.h b/include/audacity/Types.h index 9547b1915..06d60f016 100644 --- a/include/audacity/Types.h +++ b/include/audacity/Types.h @@ -790,60 +790,4 @@ using EffectFamilySymbol = ComponentInterfaceSymbol; // the API is complete. -#if !defined(AUDACITY_DLL_API) - // This was copied from "Audacity.h" so these headers wouldn't have - // to include it. - - /* Magic for dynamic library import and export. This is unfortunately - * compiler-specific because there isn't a standard way to do it. Currently it - * works with the Visual Studio compiler for windows, and for GCC 4+. Anything - * else gets all symbols made public, which gets messy */ - /* The Visual Studio implementation */ - #ifdef _MSC_VER - #ifndef AUDACITY_DLL_API - #ifdef BUILDING_AUDACITY - #define AUDACITY_DLL_API _declspec(dllexport) - #else - #ifdef _DLL - #define AUDACITY_DLL_API _declspec(dllimport) - #else - #define AUDACITY_DLL_API - #endif - #endif - #endif - #endif //_MSC_VER - - /* The GCC-elf implementation */ - #ifdef HAVE_VISIBILITY // this is provided by the configure script, is only - // enabled for suitable GCC versions - /* The incantation is a bit weird here because it uses ELF symbol stuff. If we - * make a symbol "default" it makes it visible (for import or export). Making it - * "hidden" means it is invisible outside the shared object. */ - #ifndef AUDACITY_DLL_API - #ifdef BUILDING_AUDACITY - #define AUDACITY_DLL_API __attribute__((visibility("default"))) - #else - #define AUDACITY_DLL_API __attribute__((visibility("default"))) - #endif - #endif - #endif - - /* The GCC-win32 implementation */ - // bizzarely, GCC-for-win32 supports Visual Studio style symbol visibility, so - // we use that if building on Cygwin - #if defined __CYGWIN__ && defined __GNUC__ - #ifndef AUDACITY_DLL_API - #ifdef BUILDING_AUDACITY - #define AUDACITY_DLL_API _declspec(dllexport) - #else - #ifdef _DLL - #define AUDACITY_DLL_API _declspec(dllimport) - #else - #define AUDACITY_DLL_API - #endif - #endif - #endif - #endif -#endif - #endif // __AUDACITY_TYPES_H__ diff --git a/src/Audacity.h b/src/Audacity.h index e042a0cec..598d81106 100644 --- a/src/Audacity.h +++ b/src/Audacity.h @@ -113,37 +113,6 @@ class wxWindow; #include "configwin.h" #endif -/* The dynamic library import and export for Microsoft Windows. - * Supported by Visual Studio and for GCC 4+ */ -#if defined _WIN32 || (defined __CYGWIN__ && defined __GNUC__) - #ifndef AUDACITY_DLL_API - #ifdef BUILDING_AUDACITY - #define AUDACITY_DLL_API __declspec(dllexport) - #else - #ifdef _DLL - #define AUDACITY_DLL_API __declspec(dllimport) - #else - #define AUDACITY_DLL_API - #endif - #endif - #endif -#endif //_WIN32 || (__CYGWIN__ && __GNUC__) - -/* The GCC-elf implementation */ -#ifdef HAVE_VISIBILITY // this is provided by the configure script, is only -// enabled for suitable GCC versions -/* The incantation is a bit weird here because it uses ELF symbol stuff. If we - * make a symbol "default" it makes it visible (for import or export). Making it - * "hidden" means it is invisible outside the shared object. */ - #ifndef AUDACITY_DLL_API - #ifdef BUILDING_AUDACITY - #define AUDACITY_DLL_API __attribute__((visibility("default"))) - #else - #define AUDACITY_DLL_API __attribute__((visibility("default"))) - #endif - #endif -#endif - // This renames a good use of this C++ keyword that we don't need to review when hunting for leaks. #define PROHIBITED = delete diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 409b34aed..6334f84ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1293,6 +1293,11 @@ source_group( ${_INTDIR}/CMakeFiles/Audacity.dir/cmake_pch.hxx ) +# Define AUDACITY_DLL_API +import_symbol_define( import_symbol AUDACITY_DLL ) +export_symbol_define( export_symbol AUDACITY_DLL ) +list( APPEND DEFINES PRIVATE "${export_symbol}" INTERFACE "${import_symbol}" ) + target_sources( ${TARGET} PRIVATE ${HEADERS} ${SOURCES} ${RESOURCES} ${MAC_RESOURCES} ${WIN_RESOURCES} ) target_compile_definitions( ${TARGET} PRIVATE ${DEFINES} ) target_compile_options( ${TARGET} PRIVATE ${OPTIONS} ) diff --git a/src/widgets/FileDialog/FileDialog.h b/src/widgets/FileDialog/FileDialog.h index 0f32d3148..892a13f4c 100644 --- a/src/widgets/FileDialog/FileDialog.h +++ b/src/widgets/FileDialog/FileDialog.h @@ -19,10 +19,6 @@ custom controls. #include // to inherit -#ifndef AUDACITY_DLL_API -#define AUDACITY_DLL_API -#endif - class AUDACITY_DLL_API FileDialogBase : public wxFileDialogBase { public: