From b27981043772b209d895cf0414e1213878a6354c Mon Sep 17 00:00:00 2001 From: numzero Date: Mon, 6 Mar 2023 17:32:03 +0300 Subject: [PATCH] Consolidate import/export attribute definitions --- source/Irrlicht/CMakeLists.txt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index cfd3bbe..4d2ec7e 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -6,13 +6,16 @@ option(USE_SDL2 "Use the SDL2 backend" FALSE) add_definitions(-DIRRLICHT_EXPORTS) if(BUILD_SHARED_LIBS) if(WIN32) - add_definitions("-DIRRLICHT_API=__declspec(dllexport)") + set(API_IMPORT "__declspec(dllimport)") + set(API_EXPORT "__declspec(dllexport)") elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$") - add_definitions("-DIRRLICHT_API=__attribute__ ((visibility(\"default\")))") + set(API_EXPORT "__attribute__ ((visibility(\"default\")))") # only necessary if default visibility is set to hidden endif() else() add_definitions(-D_IRR_STATIC_LIB_) endif() +add_definitions("-DIRRLICHT_API=${API_EXPORT}") + if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-D_DEBUG) endif() @@ -472,11 +475,9 @@ target_include_directories(IrrlichtMt target_link_libraries(IrrlichtMt PRIVATE ${link_libs}) 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)) + target_compile_definitions(IrrlichtMt INTERFACE _IRR_WINDOWS_API_) # used in _IRR_DEBUG_BREAK_IF definition in a public header endif() +target_compile_definitions(IrrlichtMt INTERFACE "IRRLICHT_API=${API_IMPORT}") if(APPLE OR ANDROID OR EMSCRIPTEN) target_compile_definitions(IrrlichtMt PUBLIC IRR_MOBILE_PATHS) endif()