fix engine library compilation on linux/amd64
authorsheepluva
Sun, 06 Feb 2011 11:34:52 +0100
changeset 4928 6ebbca960503
parent 4927 95d1c90a626b
child 4929 3dca560e6510
fix engine library compilation on linux/amd64
hedgewars/CMakeLists.txt
--- a/hedgewars/CMakeLists.txt	Sun Feb 06 10:36:01 2011 +0100
+++ b/hedgewars/CMakeLists.txt	Sun Feb 06 11:34:52 2011 +0100
@@ -93,10 +93,19 @@
     message(STATUS "Engine will be built as library (experimental)")
     set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas)
     set(engine_sources ${hwengine_project} PascalExports.pas ${engine_sources})
-    set(pascal_compiler_flags_cmn "-dHWLIBRARY" "-k-no_order_inits" "-fPIC" ${pascal_compiler_flags_cmn})
+    set(pascal_compiler_flags_cmn "-dHWLIBRARY" ${pascal_compiler_flags_cmn})
+
+    # create position independent code, only required for x68_64 builds, similar to -fPIC
+    if(CMAKE_SIZEOF_VOID_P MATCHES "8")
+        set(pascal_compiler_flags_cmn "-Cg" ${pascal_compiler_flags_cmn})
+    endif(CMAKE_SIZEOF_VOID_P MATCHES "8")
+
+    # due to compiling/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail
+    if(APPLE AND current_macosx_version MATCHES "10.6")
+        set(pascal_compiler_flags_cmn "-k-no_order_inits" ${pascal_compiler_flags_cmn})
+    endif(APPLE AND current_macosx_version MATCHES "10.6")
 endif(BUILD_ENGINE_LIBRARY)
 
-
 find_program(fpc_executable ${fpc_tryexe})
 
 if(fpc_executable)