From 22c3219ff01a6a5618f69edb383827609a1eacee Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 16 Jul 2021 23:11:59 +0200 Subject: [PATCH] Set correct flags for static builds this is only really relevant on Windows --- source/Irrlicht/CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/source/Irrlicht/CMakeLists.txt b/source/Irrlicht/CMakeLists.txt index 38dbbacf..5d803f0d 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}