diff --git a/CMakeLists.txt b/CMakeLists.txt index 127e288..a4d9140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,14 +247,6 @@ if(NOT CPPTRACE_BUILD_SHARED) target_compile_definitions(${target_name} PUBLIC CPPTRACE_STATIC_DEFINE) endif() -# generate header file with export macros prefixed with BASE_NAME -include(GenerateExportHeader) -generate_export_header( - ${target_name} - BASE_NAME cpptrace - EXPORT_FILE_NAME include/cpptrace/cpptrace_export.hpp -) - # ---- Library Properties ---- # Hide all symbols by default diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index 10f7af3..de84225 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -9,8 +9,33 @@ #include #include #include -// Generated by the build system. -#include + +#ifdef _WIN32 +#define CPPTRACE_EXPORT_ATTR __declspec(dllexport) +#define CPPTRACE_IMPORT_ATTR __declspec(dllimport) +#define CPPTRACE_NO_EXPORT_ATTR +#define CPPTRACE_DEPRECATED_ATTR __declspec(deprecated) +#else +#define CPPTRACE_EXPORT_ATTR __attribute__((visibility("default"))) +#define CPPTRACE_IMPORT_ATTR __attribute__((visibility("default"))) +#define CPPTRACE_NO_EXPORT_ATTR __attribute__((visibility("hidden"))) +#define CPPTRACE_DEPRECATE_ATTR __attribute__((__deprecated__)) +#endif + +#ifdef CPPTRACE_STATIC_DEFINE +# define CPPTRACE_EXPORT +# define CPPTRACE_NO_EXPORT +#else +# ifndef CPPTRACE_EXPORT +# ifdef cpptrace_lib_EXPORTS + /* We are building this library */ +# define CPPTRACE_EXPORT CPPTRACE_EXPORT_ATTR +# else + /* We are using this library */ +# define CPPTRACE_EXPORT CPPTRACE_IMPORT_ATTR +# endif +# endif +#endif #if __cplusplus >= 202002L #ifdef __has_include