Browse Source

Excluded Assimp objects from static and shared library. Fixed kNet to solve the multiple definition issue when build shared library.

Wei Tjong Yao 12 years ago
parent
commit
1e5f08ae7b
3 changed files with 38 additions and 16 deletions
  1. 2 0
      ThirdParty/FreeType/CMakeLists.txt
  2. 5 4
      ThirdParty/kNet/CMakeLists.txt
  3. 31 12
      Urho3D/lib/CMakeLists.txt

+ 2 - 0
ThirdParty/FreeType/CMakeLists.txt

@@ -26,6 +26,8 @@ set (SOURCE_FILES
     src/base/ftwinfnt.c
     src/bdf/bdf.c
     src/cache/ftccache.c
+    src/cache/ftcmanag.c
+    src/cache/ftcmru.c
     src/cff/cff.c
     src/cid/type1cid.c
     src/gzip/ftgzip.c

+ 5 - 4
ThirdParty/kNet/CMakeLists.txt

@@ -1,4 +1,4 @@
-# Copyright 2010 Jukka Jylänki
+# Copyright 2010 Jukka Jyl�nki
 
 #  Licensed under the Apache License, Version 2.0 (the "License");
 #  you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-# Modified by Lasse Oorni for Urho3D
+# Modified by Lasse Oorni and Yao Wei Tjong for Urho3D
 
 file(GLOB kNetSourceFiles ./src/*.cpp)
 file(GLOB kNetHeaderFiles ./include/*.h ./include/kNet/*.h ./include/kNet/*.inl)
@@ -22,7 +22,7 @@ if (WIN32)
    file(GLOB kNetWin32HeaderFiles ./include/kNet/win32/*.h)
 
    if (USE_BOOST)
-      list(REMOVE_ITEM kNetWin32SourceFiles ${PROJECT_SOURCE_DIR}/./src/win32/W32Thread.cpp)
+      list(REMOVE_ITEM kNetWin32SourceFiles ${CMAKE_CURRENT_SOURCE_DIR}/./src/win32/W32Thread.cpp)
    endif()
 
    set(kNetSourceFiles ${kNetSourceFiles} ${kNetWin32SourceFiles})
@@ -35,11 +35,12 @@ if (WIN32)
    set(kNetLinkLibraries ${kNetLinkLibraries} ws2_32.lib)
 
 elseif (UNIX)
+   list (REMOVE_ITEM kNetSourceFiles ${CMAKE_CURRENT_SOURCE_DIR}/./src/Clock.cpp)
    file(GLOB kNetUnixSourceFiles ./src/unix/*.cpp)
    file(GLOB kNetUnixHeaderFiles ./include/*.h ./include/kNet/*.h ./include/kNet/unix/*.h)
 
    if (USE_BOOST)
-      list(REMOVE_ITEM kNetUnixSourceFiles ${PROJECT_SOURCE_DIR}/./src/unix/UnixThread.cpp)
+      list(REMOVE_ITEM kNetUnixSourceFiles ${CMAKE_CURRENT_SOURCE_DIR}/./src/unix/UnixThread.cpp)
    elseif (NOT ANDROID)
       set(kNetLinkLibraries ${kNetLinkLibraries} pthread)
    endif()

+ 31 - 12
Urho3D/lib/CMakeLists.txt

@@ -27,14 +27,14 @@ if (ENABLE_LIBRARY MATCHES "SHARED|shared")
 endif ()
 
 # Define generated source files
-if (MSVC)
+if (WIN32)
     add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
         COMMAND for /F %%v in ('svnversion -n ${PROJECT_SOURCE_DIR}') do echo const char* revision="%%v"\; >${CMAKE_CURRENT_BINARY_DIR}/svnversion.h DEPENDS Urho3D
-        COMMENT "Generate subversion revision number")
+        COMMENT "Generating subversion revision number")
 else ()
     add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/svnversion.h
         COMMAND for v in `svnversion -n ${PROJECT_SOURCE_DIR}`\; do echo 'const char* revision="'$$v'"\;' >${CMAKE_CURRENT_BINARY_DIR}/svnversion.h\; done DEPENDS Urho3D
-        COMMENT "Generate subversion revision number")
+        COMMENT "Generating subversion revision number")
 endif ()
 
 # Define source files
@@ -49,13 +49,32 @@ set (INCLUDE_DIRS_ONLY ${CMAKE_CURRENT_BINARY_DIR})
 setup_library ()
 adjust_library_name ()
 
-# Archive all the objects into this target
-if (MSVC)
-# todo: lib.exe /OUT:Urho3D.lib lib1.lib lib2.lib
-elseif (APPLE)
-# todo: find ../.. -type f -regex [\./]*Engine.*\\.o -o -regex [\./]*ThirdParty.*\\.o -o -regex [\./]*Extras/LuaScript.*\\.o 
+# This is a CMake hack, please FIXME if there is a better way
+# WARNING!!! The custom command below will pick up remnant objects from previous/other build in the build directory
+if (LIB_TYPE STREQUAL SHARED)
+    # Link all the objects into this target
+    if (MSVC)
+    # todo
+    elseif (APPLE)
+    # todo 
+    else ()
+        add_custom_command (TARGET ${TARGET_NAME} PRE_BUILD COMMAND
+            [ CMakeFiles/Urho3D_lib.dir/link.txt -nt CMakeFiles/Urho3D_lib.dir/link-all-objects.txt ] &&
+            sed -z 's/\\n//g' CMakeFiles/Urho3D_lib.dir/link.txt >CMakeFiles/Urho3D_lib.dir/link-all-objects.txt &&
+            find ../.. -type f -regextype posix-egrep -regex [\\./]*\\\(Engine\\|ThirdParty\\|Extras/LuaScript\\\).*\\.o -a \\\( ! -regex [\\./]*ThirdParty/Assimp.*\\.o \\\) |xargs >>CMakeFiles/Urho3D_lib.dir/link-all-objects.txt &&
+            cp -p CMakeFiles/Urho3D_lib.dir/link-all-objects.txt CMakeFiles/Urho3D_lib.dir/link.txt || exit 0
+            COMMENT "Adjusting linker source to include all objects")
+    endif ()
 else ()
-    add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
-        COMMAND ${CMAKE_AR} r ${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} `find ../.. -type f -regextype posix-egrep -regex [\\./]*\\\(Engine\\|ThirdParty\\|Extras/LuaScript\\\).*\\.o`
-        COMMAND ${CMAKE_RANLIB} ${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
-endif ()
+    # Archive all the objects into this target
+    if (MSVC)
+    # todo: lib.exe /OUT:Urho3D.lib lib1.lib lib2.lib
+    elseif (APPLE)
+    # todo: find ../.. -type f -regex [\./]*Engine.*\\.o -o -regex [\./]*ThirdParty.*\\.o -o -regex [\./]*Extras/LuaScript.*\\.o
+    else ()
+        add_custom_command (TARGET ${TARGET_NAME} POST_BUILD
+            COMMAND ${CMAKE_AR} r ${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} `find ../.. -type f -regextype posix-egrep -regex [\\./]*\\\(Engine\\|ThirdParty\\|Extras/LuaScript\\\).*\\.o -a \\\( ! -regex [\\./]*ThirdParty/Assimp.*\\.o \\\)`
+            COMMAND ${CMAKE_RANLIB} ${CMAKE_STATIC_LIBRARY_PREFIX}${LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
+            COMMENT "Archiving all objects")
+    endif ()
+endif ()