Consolidate import/export attribute definitions

This commit is contained in:
numzero 2023-03-06 17:32:03 +03:00
parent e484698ba2
commit b279810437

@ -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()