]> git.lizzy.rs Git - irrlicht.git/commitdiff
Move import/export macros into CMake
authornumzero <numzer0@yandex.ru>
Sun, 19 Feb 2023 21:16:55 +0000 (00:16 +0300)
committernumzero <numzer0@yandex.ru>
Wed, 22 Feb 2023 18:11:12 +0000 (21:11 +0300)
include/IrrCompileConfig.h
source/Irrlicht/CMakeLists.txt

index 7d3c4589d56805303b43ebf0c41b92c3fc9483c1..5a4f8984ffc64db47b902eb4d4638a49178d9464 100644 (file)
 #define _IRR_MATERIAL_MAX_TEXTURES_ 4\r
 \r
 \r
-#ifdef _IRR_WINDOWS_API_\r
-\r
-// To build Irrlicht as a static library, you must define _IRR_STATIC_LIB_ in both the\r
-// Irrlicht build, *and* in the user application, before #including <irrlicht.h>\r
-#ifndef _IRR_STATIC_LIB_\r
-#ifdef IRRLICHT_EXPORTS\r
-#define IRRLICHT_API __declspec(dllexport)\r
-#else\r
-#define IRRLICHT_API __declspec(dllimport)\r
-#endif // IRRLICHT_EXPORT\r
-#else\r
-#define IRRLICHT_API\r
-#endif // _IRR_STATIC_LIB_\r
-\r
-// Declare the calling convention.\r
-#if defined(_STDCALL_SUPPORTED)\r
+#ifdef _WIN32\r
 #define IRRCALLCONV __stdcall\r
 #else\r
-#define IRRCALLCONV __cdecl\r
-#endif // STDCALL_SUPPORTED\r
-\r
-#else // _IRR_WINDOWS_API_\r
+#define IRRCALLCONV\r
+#endif\r
 \r
-// Force symbol export in shared libraries built with gcc.\r
-#if defined(__GNUC__) && !defined(_IRR_STATIC_LIB_) && defined(IRRLICHT_EXPORTS)\r
-#define IRRLICHT_API __attribute__ ((visibility("default")))\r
-#else\r
+#ifndef IRRLICHT_API\r
 #define IRRLICHT_API\r
 #endif\r
 \r
-#define IRRCALLCONV\r
-\r
-#endif // _IRR_WINDOWS_API_\r
-\r
 \r
 #define _IRR_COMPILE_WITH_GUI_\r
 #define _IRR_COMPILE_WITH_LIBJPEG_\r
index 76228d1f2b6bc8317d428b4fbe7823e49c686f00..eeb1029a27c89cf3cf274b80df6ccaf256136da9 100644 (file)
@@ -4,7 +4,13 @@ option(USE_SDL2 "Use the SDL2 backend" FALSE)
 # Compiler flags
 
 add_definitions(-DIRRLICHT_EXPORTS)
-if(NOT BUILD_SHARED_LIBS)
+if(BUILD_SHARED_LIBS)
+       if(WIN32)
+               add_definitions("-DIRRLICHT_API=__declspec(dllexport)")
+       elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
+               add_definitions("-DIRRLICHT_API=__attribute__ ((visibility(\"default\")))")
+       endif()
+else()
        add_definitions(-D_IRR_STATIC_LIB_)
 endif()
 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -453,13 +459,12 @@ target_include_directories(IrrlichtMt
 
 target_link_libraries(IrrlichtMt PRIVATE ${link_libs})
 
-# Propagate static library flag to lib users, only needed for Windows
-if(NOT BUILD_SHARED_LIBS)
-       target_compile_definitions(IrrlichtMt INTERFACE _IRR_STATIC_LIB_)
-endif()
 if(WIN32)
        target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_)
 endif()
+if(WIN32 AND BUILD_SHARED_LIBS)
+       target_compile_definitions(IrrlichtMt INTERFACE IRRLICHT_API=__declspec(dllimport))
+endif()
 if(APPLE OR ANDROID OR EMSCRIPTEN)
        target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS)
 endif()