From 836a4abc43b81583c3668bc68bc873d983b5ed67 Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Fri, 15 Apr 2016 17:01:30 -0400 Subject: [PATCH 1/8] CMakeLists.txt: Redid the section on c/cxx flags to sepereate them so you can have c++ only flags along with c only flags fore their respective .c/.cpp builds without conflict. --- Sources/CMakeLists.txt | 202 ++++++++++++++++++++++++++++------------- 1 file changed, 138 insertions(+), 64 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 974f325..5c1b70e 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -7,7 +7,18 @@ project(SeriousEngine) # Use system SDL2 is on by default option(USE_SYSTEM_SDL2 "Use system wide sdl2 libraries/includes" On) +# fallback for cmake versions without add_compile_options # RAKE! Borrowed from dhewm3 project +if(NOT COMMAND add_compile_options) + function(add_compile_options) + foreach(arg ${ARGN}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${arg}" PARENT_SCOPE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}" PARENT_SCOPE) + endforeach() + endfunction() +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) @@ -49,74 +60,138 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") SET(DEBUG TRUE) endif() -add_definitions(-D_REENTRANT=1) -add_definitions(-D_MT=1) +## ** RAKE! start compiler specific flags section ** +## ** RAKE! Borrowed from dhewm3 project, need to ** +## ** RAKE! clean up for SeriousEngine use. Also ** +## ** RAKE! need to make this pandora safe. ** +# compiler specific flags +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + add_compile_options(-Wall) + add_compile_options(-pipe) + add_compile_options(-fPIC) + add_compile_options(-march=native) + add_definitions(-D_REENTRANT=1) + add_definitions(-D_MT=1) + + ## Add your custom C and CXX flags here. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + + ## For C flags + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0") + set(CMAKE_C_FLAGS_DEBUGALL "${CMAKE_C_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0") + set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0 -fno-omit-frame-pointer") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + + ## For C++ flags + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0") + set(CMAKE_CXX_FLAGS_DEBUGALL "${CMAKE_CXX_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0") + set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0 -fno-omit-frame-pointer") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with the profiling? + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + + + add_compile_options(-fno-strict-aliasing) + + CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility) + if(NOT cxx_has_fvisibility) + message(FATAL_ERROR "Compiler does not support -fvisibility") + endif() + #add_compile_options(-fvisibility=hidden) ## RAKE! This causes some issues with undefined symbols. + + CHECK_CXX_COMPILER_FLAG("-Woverloaded-virtual" cxx_has_Woverload_virtual) + if(cxx_has_Woverload_virtual) + add_compile_options(-Woverloaded-virtual) + endif() + + # TODO fix these warnings + add_compile_options(-Wno-sign-compare) + add_compile_options(-Wno-switch) + add_compile_options(-Wno-format-security) + + if(MACOSX) + add_definitions(-DMACOS_X=1) + + add_compile_options(-arch x86_64 -mmacosx-version-min=10.6) + set(ldflags "${ldflags} -arch x86_64 -mmacosx-version-min=10.6") + + set(sys_libs ${sys_libs} "-framework Carbon -framework Cocoa -framework IOKit") + add_definitions(-DPLATFORM_UNIX=1) + add_definitions(-DPLATFORM_MACOSX=1) + add_definitions(-DPRAGMA_ONCE=1) + elseif(WINDOWS) + set(ldflags "${ldflags} -static-libgcc -static-libstdc++") + add_definitions(-DPLATFORM_WIN32=1) + add_definitions(-DPRAGMA_ONCE=1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE=1) + elseif(LINUX) + set(sys_libs ${sys_libs} dl) + set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) + add_definitions(-DPLATFORM_UNIX=1) + add_definitions(-D_FILE_OFFSET_BITS=64) + add_definitions(-D_LARGEFILE_SOURCE=1) + add_definitions(-DPRAGMA_ONCE=1) + elseif(FREEBSD) + set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) + add_definitions(-DPLATFORM_UNIX=1) + add_definitions(-DPLATFORM_FREEBSD=1) + add_definitions(-D_FILE_OFFSET_BITS=64) + add_definitions(-D_LARGEFILE_SOURCE=1) + add_definitions(-DPRAGMA_ONCE=1) + include_directories("/usr/local/include") + endif() + + if(MACOSX OR LINUX) + add_compile_options(-pthread) + add_compile_options(-pipe -fsigned-char) + endif() + + if(CMAKE_COMPILER_IS_GNUCC) + # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. + add_compile_options(-Wno-invalid-offsetof) + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. + add_compile_options(-Wno-unused-value) + add_compile_options(-Wno-switch) + add_compile_options(-Wno-tautological-undefined-compare) + add_compile_options(-Wno-c++11-compat-deprecated-writable-strings) + add_definitions(-Wno-logical-op-parentheses) + MESSAGE(WARNING "reenable -Wlogical-op-parentheses some day!") + endif() + +elseif(MSVC) + add_compile_options(/W4) + add_compile_options(/wd4100) # unreferenced formal parameter + add_compile_options(/wd4127) # conditional expression is constant + add_compile_options(/wd4244) # possible loss of data + add_compile_options(/wd4245) # signed/unsigned mismatch + add_compile_options(/wd4267) # possible loss of data + add_compile_options(/wd4714) # 'function' marked as __forceinline not inlined + add_compile_options(/wd4996) # 'function': was declared deprecated + add_compile_options(/wd4068) # unknown pragma + add_definitions(-D_ALLOW_KEYWORD_MACROS) # because of the "#define private public" and "#define protected public" in TypeInfo.cpp + set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG /Od /Zi /MDd") + set(CMAKE_C_FLAGS_RELEASE "/Ox /Oy /MD") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Ox /Oy /Zi /MD") + set(CMAKE_C_FLAGS_MINSIZEREL "/Ox /Oy /Os /MD") +else() + message(FATAL_ERROR "Unsupported compiler") +endif() + +## ** RAKE! end compiler specific flags section ** if(DEBUG) - add_definitions(-DDEBUG=1) - add_definitions(-D_DEBUG=1) set(DEBUGSUFFIX "D") else() - add_definitions(-DNDEBUG=1) - add_definitions(-D_NDEBUG=1) set(DEBUGSUFFIX "") endif() -if(WINDOWS) - add_definitions(-DPLATFORM_WIN32=1) - add_definitions(-DPRAGMA_ONCE=1) - add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE=1) -endif() - -if(LINUX) - set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) - add_definitions(-DPLATFORM_UNIX=1) - add_definitions(-D_FILE_OFFSET_BITS=64) - add_definitions(-D_LARGEFILE_SOURCE=1) - add_definitions(-DPRAGMA_ONCE=1) -endif() - -if(FREEBSD) - set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) - add_definitions(-DPLATFORM_UNIX=1) - add_definitions(-DPLATFORM_FREEBSD=1) - add_definitions(-D_FILE_OFFSET_BITS=64) - add_definitions(-D_LARGEFILE_SOURCE=1) - add_definitions(-DPRAGMA_ONCE=1) - include_directories("/usr/local/include") -endif() - -if(MACOSX) - add_definitions(-DPLATFORM_UNIX=1) - add_definitions(-DPLATFORM_MACOSX=1) - add_definitions(-DPRAGMA_ONCE=1) -endif() - -if(LINUX OR MACOSX) - if(DEBUG) - add_definitions(-O0 -ggdb3) - endif(DEBUG) - add_definitions(-pthread) - add_definitions(-pipe -fsigned-char) - #CXXFLAGS += -fexceptions -frtti -endif() - -if(CMAKE_COMPILER_IS_GNUCC) - # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. - add_definitions(-Wno-invalid-offsetof) -endif() - -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # !!! FIXME: turn a bunch of these off, this is just for now. I hope. --ryan. - add_definitions(-Wno-unused-value) - add_definitions(-Wno-switch) - add_definitions(-Wno-tautological-undefined-compare) - add_definitions(-Wno-c++11-compat-deprecated-writable-strings) - add_definitions(-Wno-logical-op-parentheses) - MESSAGE(WARNING "reenable -Wlogical-op-parentheses some day!") -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) @@ -847,12 +922,11 @@ if(LINUX) set_target_properties(ssam PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") target_link_libraries(ssam "m") target_link_libraries(ssam "dl") + target_link_libraries(ssam ${SDL2_LIBRARY}) if(PANDORA) - target_link_libraries(ssam "rt") - target_link_libraries(ssam ${SDL2_LIBRARY}) # RAKE!: I don't know if this will work yet. + target_link_libraries(ssam "rt") endif() target_link_libraries(ssam "pthread") - target_link_libraries(ssam ${SDL2_LIBRARY}) if(BUILD_DEDICATED_SERVER) set_target_properties(SeriousSamDedicated PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") target_link_libraries(SeriousSamDedicated "m") From 86b487df9e849c0295156dc61008ec12b1e8026a Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Fri, 15 Apr 2016 22:54:34 -0400 Subject: [PATCH 2/8] CMakelists.txt: Removed my attempt at making Engine a static lib again. plus other small cmake fixes --- Sources/CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 5c1b70e..6d97ed6 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -20,9 +20,6 @@ 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 @@ -66,6 +63,8 @@ endif() ## ** RAKE! need to make this pandora safe. ** # compiler specific flags if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + # This section and the like are for flags/defines that can be shared between + # c and c++ compile options add_compile_options(-Wall) add_compile_options(-pipe) add_compile_options(-fPIC) @@ -90,7 +89,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS_DEBUGALL "${CMAKE_CXX_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0 -fno-omit-frame-pointer") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with the profiling? + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with RelWithDebInfo? set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") @@ -922,11 +921,11 @@ if(LINUX) set_target_properties(ssam PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") target_link_libraries(ssam "m") target_link_libraries(ssam "dl") + target_link_libraries(ssam "pthread") target_link_libraries(ssam ${SDL2_LIBRARY}) if(PANDORA) target_link_libraries(ssam "rt") endif() - target_link_libraries(ssam "pthread") if(BUILD_DEDICATED_SERVER) set_target_properties(SeriousSamDedicated PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") target_link_libraries(SeriousSamDedicated "m") From ec1448c4d46fce4615a1450208411d554097a8f6 Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Mon, 18 Apr 2016 21:36:28 -0400 Subject: [PATCH 3/8] build-linux32.sh: Renamed build-linux.sh build script to show which arch it is compiling build-linux64.sh: for use build native 64bit linux binaries. --- Sources/{build-linux.sh => build-linux32.sh} | 0 Sources/build-linux64.sh | 23 ++++++++++++++++++++ 2 files changed, 23 insertions(+) rename Sources/{build-linux.sh => build-linux32.sh} (100%) create mode 100755 Sources/build-linux64.sh diff --git a/Sources/build-linux.sh b/Sources/build-linux32.sh similarity index 100% rename from Sources/build-linux.sh rename to Sources/build-linux32.sh diff --git a/Sources/build-linux64.sh b/Sources/build-linux64.sh new file mode 100755 index 0000000..d81e4dd --- /dev/null +++ b/Sources/build-linux64.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l` +let NCPU=$NCPU+2 +echo "Will build with 'make -j$NCPU' ... please edit this script if incorrect." + +set -e +set -x + +rm -rf cmake-build +mkdir $_ +cd $_ +#cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. +#ninja + +# This is the eventual path for amd64. +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 .. + +make -j$NCPU + From b7c49d4e514b889b1a67a3f84ecf0ed09d8fbfe7 Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Mon, 18 Apr 2016 21:46:10 -0400 Subject: [PATCH 4/8] CMakeLists.txt: Some cleanup and removing redundent lines from the CMakeLists.txt file. --- Sources/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 6d97ed6..c76c43a 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -23,7 +23,8 @@ include(CheckCXXCompilerFlag) # 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 -# allows for a setup like this. +# allows for a setup like this. Maybe use a SDL2_DIR var or +# some thing set in the system enviroment. if(NOT USE_SYSTEM_SDL2) include_directories(${CMAKE_SOURCE_DIR}/External/SDL2) else() @@ -164,7 +165,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") MESSAGE(WARNING "reenable -Wlogical-op-parentheses some day!") endif() -elseif(MSVC) +elseif(MSVC) # RAKE! I don't know if this will build with MSVC add_compile_options(/W4) add_compile_options(/wd4100) # unreferenced formal parameter add_compile_options(/wd4127) # conditional expression is constant @@ -174,8 +175,7 @@ elseif(MSVC) add_compile_options(/wd4714) # 'function' marked as __forceinline not inlined add_compile_options(/wd4996) # 'function': was declared deprecated add_compile_options(/wd4068) # unknown pragma - add_definitions(-D_ALLOW_KEYWORD_MACROS) # because of the "#define private public" and "#define protected public" in TypeInfo.cpp - set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG /Od /Zi /MDd") + set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG /Od /Zi /MDd") set(CMAKE_C_FLAGS_RELEASE "/Ox /Oy /MD") set(CMAKE_C_FLAGS_RELWITHDEBINFO "/Ox /Oy /Zi /MD") set(CMAKE_C_FLAGS_MINSIZEREL "/Ox /Oy /Os /MD") From 90a614b03c1b962b6b71f8fdb657ab0deb86ad77 Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Tue, 19 Apr 2016 04:25:38 -0400 Subject: [PATCH 5/8] CMakeLists.txt: Added an install section and fixed permissions issues with libraries. --- Sources/CMakeLists.txt | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index c76c43a..118692a 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -36,6 +36,13 @@ else() endif() endif() +# RAKE! Where to install the binaries. +if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "") # Only works for linux ATM. + set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../") # set install path to project root directory since + # since one wasn't set during config + set(LOCAL_INSTALL TRUE) +endif() + # Set up some sanity stuff... if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME MATCHES "GNU|kFreeBSD") SET(LINUX TRUE) @@ -952,5 +959,35 @@ if(TFE) set_target_properties(ssam PROPERTIES OUTPUT_NAME "ssam-tfe") endif() -# end of CMakeLists.txt ... +# RAKE! Install Section. +if(DEBUG) # RAKE! Will this work with TFE? + install(TARGETS ssam ${SHADERSLIB} ${GAMEMPLIB} ${ENTITIESMPLIB} + RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/Bin" + LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/Bin/Debug" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + if(BUILD_DEDICATED_SERVER) + install(TARGETS SeriousSamDedicated + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/Bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + endif() +else() + install(TARGETS ssam ${SHADERSLIB} ${GAMEMPLIB} ${ENTITIESMPLIB} + RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/Bin" + LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/Bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + if(BUILD_DEDICATED_SERVER) + install(TARGETS SeriousSamDedicated + RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/Bin" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + endif() +endif() +# RAKE! If CMAKE_INSTALL_PREFIX was set during config then its not a local install +# and SE1_10.gro needs to be installed to Games root dir. +if(NOT LOCAL_INSTALL) + install(FILES ${CMAKE_SOURCE_DIR}/../SE1_10.gro + DESTINATION ${CMAKE_INSTALL_PREFIX} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +endif() + +# end of CMakeLists.txt ... From 895921d8c16698651c56e5ffe8a998e9911d949c Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Tue, 19 Apr 2016 04:27:12 -0400 Subject: [PATCH 6/8] ModExt.txt: Created a link(don't know if this will work) to ModEXT.txt since the linux version looks for ModExt.txt and not ModEXT.txt --- ModExt.txt | 1 + 1 file changed, 1 insertion(+) create mode 120000 ModExt.txt diff --git a/ModExt.txt b/ModExt.txt new file mode 120000 index 0000000..a5e8d63 --- /dev/null +++ b/ModExt.txt @@ -0,0 +1 @@ +ModEXT.txt \ No newline at end of file From 380bade7c0fd814a17e5fcd60815cfb5d28a6ee8 Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Tue, 19 Apr 2016 04:43:59 -0400 Subject: [PATCH 7/8] CMakeLists.txt: BMS, Added a small explanation about the default CMAKE_INSTALL_PREFIX --- Sources/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 118692a..5031d80 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -37,7 +37,8 @@ else() endif() # RAKE! Where to install the binaries. -if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "") # Only works for linux ATM. +if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "") # Only works for linux since I don't + # know what default is for windows/macos/freebsd. set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../") # set install path to project root directory since # since one wasn't set during config set(LOCAL_INSTALL TRUE) From 9477af7bfaca268205e9153dea18bb4e362d38fb Mon Sep 17 00:00:00 2001 From: Salamanderrake Date: Tue, 19 Apr 2016 18:16:45 -0400 Subject: [PATCH 8/8] CMakeLists.txt: Applied some changes Ryan wanted with the c/cxx flags. --- Sources/CMakeLists.txt | 103 +++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 55 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 5031d80..b9f8f79 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -5,7 +5,8 @@ project(SeriousEngine) #cmake_policy(SET CMP0042 NEW) # Use system SDL2 is on by default -option(USE_SYSTEM_SDL2 "Use system wide sdl2 libraries/includes" On) +option(USE_SYSTEM_SDL2 "Use systems sdl2 development files" On) +option(USE_SYSTEM_ZLIB "Use systems zlib development files" On) # fallback for cmake versions without add_compile_options # RAKE! Borrowed from dhewm3 project if(NOT COMMAND add_compile_options) @@ -32,7 +33,16 @@ else() if(SDL2_FOUND) include_directories(${SDL2_INCLUDE_DIR}) else() - message(FATAL_ERROR "Error USE_SYSTEM_SDL2 is set but neccessary developer files not found") + message(FATAL_ERROR "Error USE_SYSTEM_SDL2 is set but neccessary developer files are missing") + endif() +endif() + +if(USE_SYSTEM_ZLIB) + find_package(ZLIB REQUIRED) + if(ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIRS}) + else() + message(FATAL_ERROR "Error! USE_SYSTEM_ZLIB is set but neccessary developer files are missing") endif() endif() @@ -78,42 +88,23 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-pipe) add_compile_options(-fPIC) add_compile_options(-march=native) + add_compile_options(-fno-strict-aliasing) add_definitions(-D_REENTRANT=1) add_definitions(-D_MT=1) - ## Add your custom C and CXX flags here. - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + ## Add your custom C and CXX flags on the command line aka -DCMAKE_C_FLAGS=-std=c98 or -DCMAKE_CXX_FLAGS=-std=c++11 ## For C flags - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0") - set(CMAKE_C_FLAGS_DEBUGALL "${CMAKE_C_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0") - set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0 -fno-omit-frame-pointer") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") - set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") - set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -fno-unsafe-math-optimizations") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations") + set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations") ## For C++ flags - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0") - set(CMAKE_CXX_FLAGS_DEBUGALL "${CMAKE_CXX_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0") - set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS} -g -ggdb3 -D_DEBUG=1 -DDEBUG=1 -O0 -fno-omit-frame-pointer") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") - set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with RelWithDebInfo? - set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -ffast-math -fno-unsafe-math-optimizations -fomit-frame-pointer") - - - add_compile_options(-fno-strict-aliasing) - - CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" cxx_has_fvisibility) - if(NOT cxx_has_fvisibility) - message(FATAL_ERROR "Compiler does not support -fvisibility") - endif() - #add_compile_options(-fvisibility=hidden) ## RAKE! This causes some issues with undefined symbols. - - CHECK_CXX_COMPILER_FLAG("-Woverloaded-virtual" cxx_has_Woverload_virtual) - if(cxx_has_Woverload_virtual) - add_compile_options(-Woverloaded-virtual) - endif() + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -D_DEBUG=1 -DDEBUG=1 -O0") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -O3 -fno-unsafe-math-optimizations") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -g -O3 -fno-unsafe-math-optimizations") ## RAKE! Does -DNDEBUG=1 and -D_NDEBUG=1 mess with RelWithDebInfo? + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG=1 -D_NDEBUG=1 -Os -fno-unsafe-math-optimizations") # TODO fix these warnings add_compile_options(-Wno-sign-compare) @@ -121,23 +112,15 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_compile_options(-Wno-format-security) if(MACOSX) - add_definitions(-DMACOS_X=1) - - add_compile_options(-arch x86_64 -mmacosx-version-min=10.6) - set(ldflags "${ldflags} -arch x86_64 -mmacosx-version-min=10.6") - - set(sys_libs ${sys_libs} "-framework Carbon -framework Cocoa -framework IOKit") add_definitions(-DPLATFORM_UNIX=1) add_definitions(-DPLATFORM_MACOSX=1) add_definitions(-DPRAGMA_ONCE=1) elseif(WINDOWS) - set(ldflags "${ldflags} -static-libgcc -static-libstdc++") add_definitions(-DPLATFORM_WIN32=1) add_definitions(-DPRAGMA_ONCE=1) - add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE=1) + add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE=1) elseif(LINUX) - set(sys_libs ${sys_libs} dl) set(CMAKE_SKIP_RPATH ON CACHE BOOL "Skip RPATH" FORCE) add_definitions(-DPLATFORM_UNIX=1) add_definitions(-D_FILE_OFFSET_BITS=64) @@ -153,9 +136,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") include_directories("/usr/local/include") endif() - if(MACOSX OR LINUX) + if(MACOSX OR LINUX OR FREEBSD) add_compile_options(-pthread) - add_compile_options(-pipe -fsigned-char) + add_compile_options(-fsigned-char) endif() if(CMAKE_COMPILER_IS_GNUCC) @@ -691,6 +674,23 @@ else() #Engine/Base/Win32/Win32Synchronization.cpp # Windows only. endif() +set(ZLIB_SRCS "") +if(NOT USE_SYSTEM_ZLIB) + set(ZLIB_SRCS + Engine/zlib/inflate.c + Engine/zlib/adler32.c + Engine/zlib/infblock.c + Engine/zlib/inffast.c + Engine/zlib/inftrees.c + Engine/zlib/trees.c + Engine/zlib/compress.c + Engine/zlib/zutil.c + Engine/zlib/deflate.c + Engine/zlib/infcodes.c + Engine/zlib/infutil.c + Engine/zlib/uncompr.c) +endif() + set(ENGINE_SRCS ${ENGINE_ENTITIES_CPP} Engine/Engine.cpp @@ -870,19 +870,8 @@ set(ENGINE_SRCS Engine/World/World.cpp Engine/World/WorldCollisionGrid.cpp Engine/World/WorldEditingProfile.cpp - Engine/zlib/inflate.c - Engine/zlib/adler32.c - Engine/zlib/infblock.c - Engine/zlib/inffast.c - Engine/zlib/inftrees.c - Engine/zlib/trees.c - Engine/zlib/compress.c - Engine/zlib/zutil.c - Engine/zlib/deflate.c - Engine/zlib/infcodes.c - Engine/zlib/infutil.c - Engine/zlib/uncompr.c ${ADDITIONAL_ENGINE_SRCS} + ${ZLIB_SRCS} ) add_executable(ssam @@ -931,6 +920,7 @@ if(LINUX) target_link_libraries(ssam "dl") target_link_libraries(ssam "pthread") target_link_libraries(ssam ${SDL2_LIBRARY}) + target_link_libraries(ssam ${ZLIB_LIBRARIES}) if(PANDORA) target_link_libraries(ssam "rt") endif() @@ -940,6 +930,7 @@ if(LINUX) target_link_libraries(SeriousSamDedicated "dl") target_link_libraries(SeriousSamDedicated "pthread") target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY}) + target_link_libraries(SeriousSamDedicated ${ZLIB_LIBRARIES}) endif() endif() @@ -948,11 +939,13 @@ if(FREEBSD) target_link_libraries(ssam "m") target_link_libraries(ssam "pthread") target_link_libraries(ssam ${SDL2_LIBRARY}) + target_link_libraries(ssam ${ZLIB_LIBRARIES}) if(BUILD_DEDICATED_SERVER) set_target_properties(SeriousSamDedicated PROPERTIES LINK_FLAGS "-Wl,-rpath,$ORIGIN") target_link_libraries(SeriousSamDedicated "m") target_link_libraries(SeriousSamDedicated "pthread") target_link_libraries(SeriousSamDedicated ${SDL2_LIBRARY}) + target_link_libraries(SeriousSamDedicated ${ZLIB_LIBRARIES}) endif() endif()