From 2a5820948748566db5cbd831781422462d72fc7f Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Thu, 21 Apr 2016 17:40:42 +0200 Subject: [PATCH] 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) --- Sources/CMakeLists.txt | 33 +++++++++++++++++++++++++-------- Sources/build-linux32.sh | 2 +- Sources/build-mac.sh | 2 +- Sources/build-mac64.sh | 14 ++++++++++++++ 4 files changed, 41 insertions(+), 10 deletions(-) create mode 100755 Sources/build-mac64.sh diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index b9f8f79..0201dbb 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -21,6 +21,9 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") 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 # RAKE!: Find a way to use their custom built library if # 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-switch) add_compile_options(-Wno-format-security) + add_definitions(-Wno-logical-op-parentheses) + MESSAGE(WARNING, "re-enable -Wlogical-op-parentheses some day!") if(MACOSX) add_definitions(-DPLATFORM_UNIX=1) @@ -182,9 +187,8 @@ else() set(DEBUGSUFFIX "") endif() -# !!! FIXME: you currently need this, but I'd like to flip this to not use -# !!! FIXME: assembly language. And maybe delete the asm code too. -option(USE_I386_ASM "Use X86 ASM" TRUE) +# This should not be needed anymore, but might be faster on 32bit x86 +option(USE_I386_ASM "Use X86 ASM" FALSE) if (USE_I386_ASM) # You need the Netwide Assembler (NASM) to build this on Intel systems. @@ -198,8 +202,10 @@ if (USE_I386_ASM) else() set(ASMOBJFMT "elf") endif() + MESSAGE(STATUS "Using i386 assembler") else() add_definitions(-DUSE_PORTABLE_C=1) + MESSAGE(STATUS "Using portable C instead of ASM") endif() option(PANDORA "Compile for Pandora" FALSE) @@ -905,12 +911,23 @@ if(BUILD_DEDICATED_SERVER) endif() if(MACOSX) - find_library(COCOA_FRAMEWORK Cocoa) - 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 ${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) + target_link_libraries(ssam "${COCOA_FRAMEWORK}") + target_link_libraries(ssam "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") + endif() + if(BUILD_DEDICATED_SERVER) - 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 ${ZLIB_LIBRARIES}) + if(USE_SYSTEM_SDL2) + target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY}) + else() + target_link_libraries(SeriousSamDedicated "${COCOA_FRAMEWORK}") + target_link_libraries(SeriousSamDedicated "${CMAKE_CURRENT_SOURCE_DIR}/lib/macosx/libSDL2-2.0.0.dylib") + endif() endif() endif() diff --git a/Sources/build-linux32.sh b/Sources/build-linux32.sh index 467fb9f..4f44315 100755 --- a/Sources/build-linux32.sh +++ b/Sources/build-linux32.sh @@ -17,7 +17,7 @@ cd $_ #cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. # 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 diff --git a/Sources/build-mac.sh b/Sources/build-mac.sh index 3fd97e3..a0311cf 100755 --- a/Sources/build-mac.sh +++ b/Sources/build-mac.sh @@ -9,6 +9,6 @@ set -x rm -rf cmake-build mkdir $_ 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 diff --git a/Sources/build-mac64.sh b/Sources/build-mac64.sh new file mode 100755 index 0000000..52f295b --- /dev/null +++ b/Sources/build-mac64.sh @@ -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 +