diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 38dbbac..5d803f0 100644 --- a/source/Irrlicht/CMakeLists.txt +++ b/source/Irrlicht/CMakeLists.txt @@ -1,11 +1,16 @@ -add_definitions(-DIRRLICHT_EXPORTS=1) +option(BUILD_SHARED_LIBS "Build shared library" TRUE) + +# Compiler flags + +add_definitions(-DIRRLICHT_EXPORTS) +if(NOT BUILD_SHARED_LIBS) + add_definitions(-D_IRR_STATIC_LIB_) +endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-D_DEBUG) endif() set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) -# Compiler flags - if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_CXX_FLAGS_DEBUG "-g") @@ -388,8 +393,6 @@ add_library(IRRGUIOBJ OBJECT # Library -option(BUILD_SHARED_LIBS "Build shared library" TRUE) - add_library(IrrlichtMt) foreach(object_lib IRRMESHOBJ IRROBJ IRRPARTICLEOBJ IRRANIMOBJ IRRVIDEOOBJ IRRSWRENDEROBJ @@ -414,6 +417,11 @@ 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() + set_target_properties(IrrlichtMt PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}