Some cmake fixes, fixing OSX build (incl 64bit) + disable i386ASM by default

OSX build was a bit broken, it needs to be linked against zlib.
Furthermore it now uses the systems libSDL2 framework, unless you use
-DUSE_SYSTEM_SDL2=FALSE

i386 ASM is now disabled by default, we have plain C fallbacks for
everything that seems to work well enough (and if not they need more
testing which is likely to happen this way)
This commit is contained in:
Daniel Gibson 2016-04-21 17:40:42 +02:00
parent 64e6b915b7
commit 2a58209487
4 changed files with 41 additions and 10 deletions

View File

@ -21,6 +21,9 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
# ssam expects the libs to be in Debug/
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Debug)
# Use systemwide SDL2 or custom build # Use systemwide SDL2 or custom build
# RAKE!: Find a way to use their custom built library if # RAKE!: Find a way to use their custom built library if
# they want to use that instead or if their system only # they want to use that instead or if their system only
@ -110,6 +113,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-sign-compare) add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-switch) add_compile_options(-Wno-switch)
add_compile_options(-Wno-format-security) add_compile_options(-Wno-format-security)
add_definitions(-Wno-logical-op-parentheses)
MESSAGE(WARNING, "re-enable -Wlogical-op-parentheses some day!")
if(MACOSX) if(MACOSX)
add_definitions(-DPLATFORM_UNIX=1) add_definitions(-DPLATFORM_UNIX=1)
@ -182,9 +187,8 @@ else()
set(DEBUGSUFFIX "") set(DEBUGSUFFIX "")
endif() endif()
# !!! FIXME: you currently need this, but I'd like to flip this to not use # This should not be needed anymore, but might be faster on 32bit x86
# !!! FIXME: assembly language. And maybe delete the asm code too. option(USE_I386_ASM "Use X86 ASM" FALSE)
option(USE_I386_ASM "Use X86 ASM" TRUE)
if (USE_I386_ASM) if (USE_I386_ASM)
# You need the Netwide Assembler (NASM) to build this on Intel systems. # You need the Netwide Assembler (NASM) to build this on Intel systems.
@ -198,8 +202,10 @@ if (USE_I386_ASM)
else() else()
set(ASMOBJFMT "elf") set(ASMOBJFMT "elf")
endif() endif()
MESSAGE(STATUS "Using i386 assembler")
else() else()
add_definitions(-DUSE_PORTABLE_C=1) add_definitions(-DUSE_PORTABLE_C=1)
MESSAGE(STATUS "Using portable C instead of ASM")
endif() endif()
option(PANDORA "Compile for Pandora" FALSE) option(PANDORA "Compile for Pandora" FALSE)
@ -905,13 +911,24 @@ if(BUILD_DEDICATED_SERVER)
endif() endif()
if(MACOSX) if(MACOSX)
target_link_libraries(ssam ${ZLIB_LIBRARIES})
if(USE_SYSTEM_SDL2) # use sdl2 framework on system
target_link_libraries(ssam ${SDL2_LIBRARY})
else() # use local libsdl2
find_library(COCOA_FRAMEWORK Cocoa) find_library(COCOA_FRAMEWORK Cocoa)
target_link_libraries(ssam "${COCOA_FRAMEWORK}") target_link_libraries(ssam "${COCOA_FRAMEWORK}")
target_link_libraries(ssam "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") target_link_libraries(ssam "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib")
endif()
if(BUILD_DEDICATED_SERVER) if(BUILD_DEDICATED_SERVER)
target_link_libraries(SeriousSamDedicated ${ZLIB_LIBRARIES})
if(USE_SYSTEM_SDL2)
target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY})
else()
target_link_libraries(SeriousSamDedicated "${COCOA_FRAMEWORK}") target_link_libraries(SeriousSamDedicated "${COCOA_FRAMEWORK}")
target_link_libraries(SeriousSamDedicated "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") target_link_libraries(SeriousSamDedicated "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib")
endif() endif()
endif()
endif() endif()
if(LINUX) if(LINUX)

View File

@ -17,7 +17,7 @@ cd $_
#cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. #cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE ..
# Right now we force x86, though... # Right now we force x86, though...
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_ASM=TRUE ..
make -j$NCPU make -j$NCPU

View File

@ -9,6 +9,6 @@ set -x
rm -rf cmake-build rm -rf cmake-build
mkdir $_ mkdir $_
cd $_ cd $_
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 .. cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 -DUSE_I386_ASM=TRUE -DUSE_SYSTEM_SDL2=FALSE ..
make -j$NCPU make -j$NCPU

14
Sources/build-mac64.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
NCPU=`sysctl -n hw.ncpu`
echo "Will build with 'make -j$NCPU' ... please edit this script if incorrect."
set -e
set -x
rm -rf cmake-build
mkdir $_
cd $_
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 -DUSE_I386_ASM=FALSE ..
make -j$NCPU