Pārlūkot izejas kodu

Attempt to fix shared library build using old CMake.

CMake version prior to 2.8.11 does not have LINK_LIBRARIES target property.
Yao Wei Tjong 姚伟忠 12 gadi atpakaļ
vecāks
revīzija
4d31d9b46f
1 mainītis faili ar 12 papildinājumiem un 1 dzēšanām
  1. 12 1
      Source/Engine/CMakeLists.txt

+ 12 - 1
Source/Engine/CMakeLists.txt

@@ -180,7 +180,15 @@ if (NOT XCODE AND NOT MSVC)
 endif ()
 # \todo This is a deprecated property in CMake version 2.8.12 - Remove below macros when CMake minimum version is 2.8.12
 set_target_properties (${TARGET_NAME} PROPERTIES LINK_INTERFACE_LIBRARIES "")
-if (NOT URHO3D_LIB_TYPE STREQUAL SHARED)
+if (URHO3D_LIB_TYPE STREQUAL SHARED)
+    if (CMAKE_MAJOR_VERSION STREQUAL 2 AND CMAKE_MINOR_VERSION STREQUAL 8)
+        string (COMPARE GREATER ${CMAKE_PATCH_VERSION} 11 OLD_CMAKE)
+    endif ()
+    if (OLD_CMAKE)
+        get_target_property (LINK_LIBRARIES ${TARGET_NAME} LINK_LIBRARIES)
+        target_link_libraries (${TARGET_NAME} LINK_PRIVATE ${LINK_LIBRARIES})
+    endif ()
+else ()
     set_target_properties (${TARGET_NAME} PROPERTIES LINK_LIBRARIES "")
 endif ()
 # \endtodo
@@ -223,6 +231,9 @@ if (URHO3D_LIB_TYPE STREQUAL SHARED)
     add_compiler_export_flags ()
     # Use PIC on platforms that support it (shared library type has this property set to true by default, so we only have to deal with those static ones that the shared library links against)
     set_target_properties (${STATIC_LIBRARY_TARGETS} PROPERTIES POSITION_INDEPENDENT_CODE true)
+    if (OLD_CMAKE)  # \todo Remove this when CMake minimum version is 2.8.9
+        set_property (TARGET ${STATIC_LIBRARY_TARGETS} APPEND PROPERTY COMPILE_FLAGS -fPIC)
+    endif ()
 endif ()
 
 # Define post build steps