| Description | Here's bunch of patches I've used to build spring 0.77b2 on FreeBSD. It would be good to merge them into the sourcetree, and I believe it will improve spring portability in general.
Summary of changes:
* TestCXXAcceptsVisibilityFlag.cmake has a test for whether gcc supports -fvisibility=hidden, but does not have test for -fvisibility=default. The latter is used as is in CMakeLists.txt, and this would fail on old gcc (in my case, legacy 6.x branch of FreeBSD which still uses gcc 3.4), so add support for VISIBILITY_DEFAULT to TestCXXAcceptsVisibilityFlag and fix CMakeLists.txt
* Add BEFORE keyword for spring internal include dirs in INCLUDE_DIRECTORIES here and there. Thus, build won't erroneously pick up some systemwide installed libraries (in by case that was luabind).
* Change malloc.h to stdlib.h, as the former is deprecated
* undef isnumber in rts/Lua/LuaUtils.h. Not sure why it is defined in my case though...
* Change library names to macros here and there. This way spring builds without need to specify additional library search paths (/usr/local/include in my case). cmake detects all libraries perfectly. |
|---|
| Attached Files |
-
spring.patch (5,432 bytes) 2008-10-10 12:34
--- CMakeLists.txt.orig 2008-10-09 23:25:29.000000000 +0400
+++ CMakeLists.txt 2008-10-09 23:24:50.000000000 +0400
@@ -55,6 +55,7 @@
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
FIND_PACKAGE(Boost 1.34.0 COMPONENTS thread regex REQUIRED)
+ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
endif (MINGW)
### Compiler flags and defines based on build type
--- rts/CMakeLists.txt.orig 2008-10-09 23:13:40.000000000 +0400
+++ rts/CMakeLists.txt 2008-10-09 23:16:17.000000000 +0400
@@ -42,11 +42,11 @@
FIND_PACKAGE(Freetype REQUIRED)
INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIR})
- LIST(APPEND spring_libraries openal GL GLU ${DEVIL_LIBRARIES} X11 Xcursor ${GLEW_LIBRARIES} ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY})
+ LIST(APPEND spring_libraries ${OPENAL_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} ${DEVIL_LIBRARIES} ${X11_X11_LIB} ${X11_Xcursor_LIB} ${GLEW_LIBRARIES} ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY})
ENDIF (MINGW)
### libraries needed on all platforms
-LIST(APPEND spring_libraries SDL vorbisfile vorbis ogg freetype)
+LIST(APPEND spring_libraries ${SDL_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY} ${FREETYPE_LIBRARIES})
### build all libraries in lib (has its own CMakeLists.txt)
ADD_SUBDIRECTORY(lib)
@@ -56,7 +56,7 @@
endif (USE_GML)
### include directories needed for compiling spring
-INCLUDE_DIRECTORIES(lib/lua/include lib/luabind)
+INCLUDE_DIRECTORIES(BEFORE lib/lua/include lib/luabind)
### all spring source directories
### each directorie which contains source has to be here
--- rts/Game/GameServer.cpp.orig 2008-10-05 04:39:05.000000000 +0400
+++ rts/Game/GameServer.cpp 2008-10-09 21:37:00.000000000 +0400
@@ -15,7 +15,7 @@
#if defined DEDICATED || defined DEBUG
#include <iostream>
#endif
-#include <malloc.h>
+#include <stdlib.h>
#include "mmgr.h"
--- rts/Lua/LuaUtils.h.orig 2008-07-16 02:42:48.000000000 +0400
+++ rts/Lua/LuaUtils.h 2008-10-09 21:41:37.000000000 +0400
@@ -14,6 +14,8 @@
#include "LuaDefs.h"
#include "Sim/Units/CommandAI/Command.h"
+#undef isnumber
+
class LuaUtils {
public:
static int CopyData(lua_State* dst, lua_State* src, int count);
--- rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake.orig 2008-09-18 23:31:26.000000000 +0400
+++ rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake 2008-10-10 01:22:32.000000000 +0400
@@ -19,6 +19,15 @@
SET(VISIBILITY_HIDDEN "")
ENDIF(HAS_VISIBILITY_HIDDEN AND NOT MINGW)
ENDIF(NOT DEFINED VISIBILITY_HIDDEN)
+
+IF(NOT DEFINED VISIBILITY_DEFAULT)
+ CHECK_CXX_ACCEPTS_FLAG(-fvisibility=default HAS_VISIBILITY_DEFAULT)
+ IF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
+ SET(VISIBILITY_DEFAULT "-fvisibility=default")
+ ELSE(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
+ SET(VISIBILITY_DEFAULT "")
+ ENDIF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
+ENDIF(NOT DEFINED VISIBILITY_DEFAULT)
IF(NOT DEFINED VISIBILITY_INLINES_HIDDEN)
CHECK_CXX_ACCEPTS_FLAG(-fvisibility-inlines-hidden HAS_VISIBILITY_INLINES_HIDDEN)
--- rts/lib/CMakeLists.txt.orig 2008-09-18 23:31:26.000000000 +0400
+++ rts/lib/CMakeLists.txt 2008-10-09 21:31:06.000000000 +0400
@@ -1,4 +1,4 @@
-INCLUDE_DIRECTORIES(streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
+INCLUDE_DIRECTORIES(BEFORE streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
ADD_DEFINITIONS(${PIC_FLAG}) # all libraries need to be position independent (gives compiler warnings on 64bit-linux
@@ -36,4 +36,4 @@
ENDIF (UNIX)
TARGET_LINK_LIBRARIES(minizip z)
-ADD_SUBDIRECTORY(streflop)
\ No newline at end of file
+ADD_SUBDIRECTORY(streflop)
--- tools/DedicatedServer/CMakeLists.txt.orig 2008-10-08 19:59:52.000000000 +0400
+++ tools/DedicatedServer/CMakeLists.txt 2008-10-10 01:23:52.000000000 +0400
@@ -50,12 +50,12 @@
../../rts/Lua/LuaUtils
../../rts/Map/MapParser
../../rts/Rendering/Textures/TAPalette)
-TARGET_LINK_LIBRARIES(springserver SDL hpiutil2 7zip minizip lua)
+TARGET_LINK_LIBRARIES(springserver ${SDL_LIBRARY} hpiutil2 7zip minizip lua)
if (MINGW)
TARGET_LINK_LIBRARIES (springserver ws2_32 boost_thread-mt boost_regex-mt)
else (MINGW)
TARGET_LINK_LIBRARIES (springserver ${Boost_REGEX_LIBRARY} ${Boost_THREAD_LIBRARY})
- ADD_DEFINITIONS (-fvisibility=default ) #overwrite hidden visibility
+ ADD_DEFINITIONS (${VISIBILITY_DEFAULT}) #overwrite hidden visibility
endif (MINGW)
ADD_EXECUTABLE(spring-dedicated main)
--- tools/unitsync/CMakeLists.txt.orig 2008-09-29 15:44:44.000000000 +0400
+++ tools/unitsync/CMakeLists.txt 2008-10-09 23:53:57.000000000 +0400
@@ -12,7 +12,7 @@
FIND_PACKAGE(GLEW REQUIRED)
- set (unitsync_libs ${GLEW_LIBRARIES} IL openal GL GLU)
+ set (unitsync_libs ${GLEW_LIBRARIES} ${DEVIL_IL_LIBRARY} ${OPENAL_LIBRARY} ${GL_gl_LIBRARY} ${GL_glu_LIBRARY})
list (APPEND unitsync_libs util) # sometimes this is needed (and I have no clue why)
FIND_PACKAGE(PythonLibs)
@@ -73,7 +73,7 @@
list(APPEND unitsync_files javabind)
endif (JAVA_FOUND)
ADD_LIBRARY(unitsync SHARED ${platformfiles} ${unitsync_files} ${fsfiles} unitsync LuaParserAPI Syncer SyncServer stdafx)
-TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua boost_regex-mt ILU SDL)
+TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua ${BOOST_regex_LIBRARY} ${DEVIL_ILU_LIBRARY} ${SDL_LIBRARY})
if (PYTHONLIBS_FOUND)
TARGET_LINK_LIBRARIES(unitsync ${PYTHON_LIBRARIES})
endif (PYTHONLIBS_FOUND)
-
spring.1.patch (1,540 bytes) 2008-10-12 15:58
Index: tools/unitsync/CMakeLists.txt
===================================================================
--- tools/unitsync/CMakeLists.txt (revision 6681)
+++ tools/unitsync/CMakeLists.txt (working copy)
@@ -70,7 +70,7 @@
list(APPEND unitsync_files javabind)
endif (JAVA_FOUND)
ADD_LIBRARY(unitsync SHARED ${platformfiles} ${unitsync_files} ${fsfiles} unitsync LuaParserAPI Syncer SyncServer stdafx)
-TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua boost_regex-mt ILU ${SDL_LIBRARY})
+TARGET_LINK_LIBRARIES(unitsync ${unitsync_libs} hpiutil2 7zip minizip lua ${Boost_regex_LIBRARY} ${IL_ILU_LIBRARY} ${SDL_LIBRARY})
if (PYTHONLIBS_FOUND)
TARGET_LINK_LIBRARIES(unitsync ${PYTHON_LIBRARIES})
endif (PYTHONLIBS_FOUND)
Index: rts/Lua/LuaUtils.h
===================================================================
--- rts/Lua/LuaUtils.h (revision 6681)
+++ rts/Lua/LuaUtils.h (working copy)
@@ -14,6 +14,10 @@
#include "LuaDefs.h"
#include "Sim/Units/CommandAI/Command.h"
+#ifdef isnumber
+#undef isnumber
+#endif
+
class LuaUtils {
public:
static int CopyData(lua_State* dst, lua_State* src, int count);
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 6681)
+++ CMakeLists.txt (working copy)
@@ -58,6 +58,7 @@
INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR})
FIND_PACKAGE(Boost 1.34.0 COMPONENTS thread regex REQUIRED)
+ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
endif (MINGW)
### Compiler flags and defines based on build type
-
spring.2.patch (2,302 bytes) 2008-10-15 17:16
Index: tools/DedicatedServer/CMakeLists.txt
===================================================================
--- tools/DedicatedServer/CMakeLists.txt (revision 6752)
+++ tools/DedicatedServer/CMakeLists.txt (working copy)
@@ -54,7 +54,7 @@
if (MINGW)
TARGET_LINK_LIBRARIES (springserver ws2_32)
else (MINGW)
- ADD_DEFINITIONS (-fvisibility=default ) #overwrite hidden visibility
+ ADD_DEFINITIONS (${VISIBILITY_DEFAULT}) #overwrite hidden visibility
endif (MINGW)
ADD_EXECUTABLE(spring-dedicated main)
Index: rts/Lua/LuaUtils.h
===================================================================
--- rts/Lua/LuaUtils.h (revision 6752)
+++ rts/Lua/LuaUtils.h (working copy)
@@ -14,6 +14,10 @@
#include "LuaDefs.h"
#include "Sim/Units/CommandAI/Command.h"
+#ifdef isnumber
+#undef isnumber
+#endif
+
class LuaUtils {
public:
static int CopyData(lua_State* dst, lua_State* src, int count);
Index: rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake
===================================================================
--- rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake (revision 6752)
+++ rts/build/cmake/TestCXXAcceptsVisibilityFlag.cmake (working copy)
@@ -19,6 +19,15 @@
SET(VISIBILITY_HIDDEN "")
ENDIF(HAS_VISIBILITY_HIDDEN AND NOT MINGW)
ENDIF(NOT DEFINED VISIBILITY_HIDDEN)
+
+IF(NOT DEFINED VISIBILITY_DEFAULT)
+ CHECK_CXX_ACCEPTS_FLAG(-fvisibility=default HAS_VISIBILITY_DEFAULT)
+ IF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
+ SET(VISIBILITY_DEFAULT "-fvisibility=default")
+ ELSE(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
+ SET(VISIBILITY_DEFAULT "")
+ ENDIF(HAS_VISIBILITY_DEFAULT AND NOT MINGW)
+ENDIF(NOT DEFINED VISIBILITY_DEFAULT)
IF(NOT DEFINED VISIBILITY_INLINES_HIDDEN)
CHECK_CXX_ACCEPTS_FLAG(-fvisibility-inlines-hidden HAS_VISIBILITY_INLINES_HIDDEN)
Index: rts/lib/CMakeLists.txt
===================================================================
--- rts/lib/CMakeLists.txt (revision 6752)
+++ rts/lib/CMakeLists.txt (working copy)
@@ -1,4 +1,4 @@
-INCLUDE_DIRECTORIES(streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
+INCLUDE_DIRECTORIES(BEFORE streflop lua/include luabind ${CMAKE_SOURCE_DIR}/rts/System)
ADD_DEFINITIONS(${PIC_FLAG}) # all libraries need to be position independent (gives compiler warnings on 64bit-linux
|
|---|