Created
December 28, 2016 01:25
-
-
Save NatWeiss/6a05bd05583c6528f050be172af42688 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_policy(SET CMP0017 NEW) | |
cmake_minimum_required(VERSION 2.8) | |
if (POLICY CMP0058) | |
# Ninja requires custom command byproducts to be explicit | |
cmake_policy(SET CMP0058 NEW) | |
endif() | |
# | |
# First set project name so cmake variables get set | |
# | |
set(APP_NAME Songbringer) | |
project (${APP_NAME}) | |
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWER) | |
set(APP_BIN_DIR "${CMAKE_SOURCE_DIR}/../../build/linux-${CMAKE_BUILD_TYPE_LOWER}/") | |
# | |
# Now include the platform definition module | |
# | |
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/") | |
include(Platform) | |
include(cotire) | |
# | |
# Determine bits | |
# | |
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}") | |
# | |
# Set cocos2d-x dirs | |
# | |
set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/../../lib/cocos2d/x) | |
if(BITS EQUAL 64) | |
set(LIB_DIR ${COCOS2D_ROOT}/lib/${CMAKE_BUILD_TYPE}-Linux/x86_64/) | |
else() | |
set(LIB_DIR ${COCOS2D_ROOT}/lib/${CMAKE_BUILD_TYPE}-Linux/i386/) | |
endif() | |
get_filename_component(COCOS2D_ROOT ${COCOS2D_ROOT} REALPATH) | |
get_filename_component(LIB_DIR ${LIB_DIR} REALPATH) | |
# | |
# Get gcc version | |
# | |
if (CMAKE_COMPILER_IS_GNUCC) | |
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) | |
string(STRIP "${GCC_VERSION}" GCC_VERSION) | |
endif() | |
# | |
# Compiler flags and preprocessor definitions | |
# | |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -Og -DCOCOS2D_DEBUG=1 -Wall") | |
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Og -DCOCOS2D_DEBUG=1 -Wall -Wno-unknown-pragmas -Wno-sign-compare") | |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -static-libgcc -L${CMAKE_SOURCE_DIR} -std=c99") | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -static-libgcc -L${CMAKE_SOURCE_DIR} -std=c++14 -Wno-deprecated-declarations -Wno-reorder") | |
if(CLANG) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") | |
endif() | |
if(LINUX) | |
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLINUX") | |
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DLINUX") | |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLINUX") | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX") | |
else() | |
message( FATAL_ERROR "Unsupported platform, CMake will exit" ) | |
endif() | |
if(CMAKE_BUILD_TYPE STREQUAL "Release") | |
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNDEBUG") | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG") | |
endif() | |
# Unused: CC_TARGET_OS_LINUX USE_FILE32API | |
# | |
# Instruct linker to use executable's directory for loading shared libraries. | |
# | |
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) | |
set(CMAKE_INSTALL_RPATH "$ORIGIN:/usr/local/lib") | |
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath,'$ORIGIN'") | |
# | |
# was: | |
# RPATH /home/nat/Songbringer/projects/linux:/home/nat/.rapidgame/3.9nojs/cocos2d/x/lib/Release-Linux/x86_64:/usr/local/lib | |
# | |
# now: | |
# RPATH $ORIGIN:/usr/local/lib | |
# | |
# | |
# GLEW: | |
# statically linking to libglew (download to ~/src, cd build, make -- or cmake ./cmake, make) | |
# using the same version that cocos2d-x built with (1.13) | |
#set(GLEW_USE_STATIC_BUILDS ON) | |
# | |
# PNG | |
# statically linking to libpng12.a still generates a dependency on libpng12.so (the way cocos2d-x is linked?) | |
# so leaving it as is for now | |
# | |
# Show configuration | |
# | |
get_directory_property( DirDefs COMPILE_DEFINITIONS ) | |
message(STATUS "PROJECT: ${APP_NAME}") | |
message(STATUS "SYSTEM: ${SYSTEM_STRING}") | |
message(STATUS "CONFIG: ${CMAKE_BUILD_TYPE}") | |
message(STATUS "BITS: ${BITS}") | |
message(STATUS "COCOS2D_ROOT: ${COCOS2D_ROOT}") | |
message(STATUS "LIB_DIR: ${LIB_DIR}") | |
message(STATUS "GCC_VERSION: ${GCC_VERSION}") | |
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | |
message(STATUS "FLAGS: ${CMAKE_CXX_FLAGS_DEBUG}") | |
else() | |
message(STATUS "FLAGS: ${CMAKE_CXX_FLAGS}") | |
endif() | |
# | |
# Find packages | |
# https://cmake.org/cmake/help/v3.0/manual/cmake-modules.7.html | |
# | |
find_package (Threads) | |
find_package (PNG) | |
find_package (OpenGL) | |
#find_package (GLEW) | |
find_package (X11) | |
find_package (ZLIB) | |
#find_package (GLUT) | |
find_package(PkgConfig REQUIRED) | |
pkg_search_module(FONTCONFIG REQUIRED fontconfig) | |
find_package (CURL) | |
# | |
# Project headers | |
# | |
include_directories( | |
../../src | |
../../src/steam | |
../../src/OIS/includes | |
../../src/fmod/linux/lowlevel/inc | |
../../src/fmod/linux/studio/inc | |
${COCOS2D_ROOT}/include | |
${COCOS2D_ROOT}/include/cocos | |
${COCOS2D_ROOT}/include/cocos/base | |
${COCOS2D_ROOT}/include/cocos/physics | |
${COCOS2D_ROOT}/include/cocos/math/kazmath | |
${COCOS2D_ROOT}/include/cocos/2d | |
${COCOS2D_ROOT}/include/cocos/gui | |
${COCOS2D_ROOT}/include/cocos/network | |
${COCOS2D_ROOT}/include/cocos/audio/include | |
${COCOS2D_ROOT}/include/cocos/editor-support | |
${COCOS2D_ROOT}/include/cocos/platform | |
${COCOS2D_ROOT}/include/extensions | |
${COCOS2D_ROOT}/include/external | |
${COCOS2D_ROOT}/include/external/chipmunk/include/chipmunk | |
${COCOS2D_ROOT}/include/bindings/auto | |
${COCOS2D_ROOT}/include/bindings/manual | |
${COCOS2D_ROOT}/include/bindings/manual/cocosbuilder | |
/usr/local/include/GLFW | |
/usr/include/GLFW | |
) | |
# ../../src/fmod/mac/studio/inc | |
# ../../src/fmod/mac/lowlevel/inc | |
# include_directories(${GLEW_INCLUDE_DIRS}) | |
# | |
# Game src | |
# | |
#file(GLOB GAME_SRC "../../src/*.cpp") | |
set(GAME_SRC | |
../../src/Anims.cpp | |
../../src/Area.cpp | |
../../src/AreaCreation.cpp | |
../../src/AreaPatterns.cpp | |
../../src/Blocks.cpp | |
../../src/Constants.cpp | |
../../src/Dungeon.cpp | |
../../src/Ent.cpp | |
../../src/EntityFu.cpp | |
../../src/Extensions.cpp | |
../../src/Flux.cpp | |
../../src/Game.cpp | |
../../src/GameScene.cpp | |
../../src/Shaders.cpp | |
../../src/Input.cpp | |
../../src/InputControllers.cpp | |
../../src/Kit.cpp | |
../../src/ValTree.cpp | |
../../src/Lens.cpp | |
../../src/Maze.cpp | |
../../src/Profile.cpp | |
../../src/Scenes.cpp | |
../../src/Steam.cpp | |
../../src/Tick.cpp | |
../../src/Interfaces.cpp | |
../../src/World.cpp | |
../../src/AIComponent.cpp | |
../../src/AttackComponent.cpp | |
../../src/CollisionComponent.cpp | |
../../src/DialogueComponent.cpp | |
../../src/DoorComponent.cpp | |
../../src/ExitComponent.cpp | |
../../src/GearComponent.cpp | |
../../src/HealthComponent.cpp | |
../../src/InputComponent.cpp | |
../../src/ItemComponent.cpp | |
../../src/LightComponent.cpp | |
../../src/MoveComponent.cpp | |
../../src/NameComponent.cpp | |
../../src/PositionComponent.cpp | |
../../src/ProfileComponent.cpp | |
../../src/ReflectionComponent.cpp | |
../../src/RenderComponent.cpp | |
../../src/SecretComponent.cpp | |
../../src/ShadowComponent.cpp | |
../../src/AISystem.cpp | |
../../src/AttackSystem.cpp | |
../../src/CollisionSystem.cpp | |
../../src/DoorSystem.cpp | |
../../src/ExitSystem.cpp | |
../../src/GearSystem.cpp | |
../../src/HealthSystem.cpp | |
../../src/InputSystem.cpp | |
../../src/LayerSystem.cpp | |
../../src/MoveSystem.cpp | |
../../src/MusicSystem.cpp | |
../../src/ProfileSystem.cpp | |
../../src/RenderSystem.cpp | |
../../src/SecretSystem.cpp | |
../../src/StorySystem.cpp | |
) | |
set(OTHER_SRC | |
../../src/OIS/src/OISEffect.cpp | |
../../src/OIS/src/OISException.cpp | |
../../src/OIS/src/OISForceFeedback.cpp | |
../../src/OIS/src/OISInputManager.cpp | |
../../src/OIS/src/OISJoyStick.cpp | |
../../src/OIS/src/OISObject.cpp | |
../../src/OIS/src/linux/EventHelpers.cpp | |
../../src/OIS/src/linux/LinuxForceFeedback.cpp | |
../../src/OIS/src/linux/LinuxInputManager.cpp | |
../../src/OIS/src/linux/LinuxJoyStickEvents.cpp | |
) | |
set(PLATFORM_SPECIFIC_SRC) | |
if(LINUX) | |
set(PLATFORM_SPECIFIC_SRC | |
main.cpp | |
KitServices.cpp | |
) | |
endif() | |
# | |
# Compile | |
# | |
add_executable(${APP_NAME} | |
${GAME_SRC} | |
${OTHER_SRC} | |
${PLATFORM_SPECIFIC_SRC} | |
) | |
set_target_properties(${APP_NAME} PROPERTIES | |
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}" | |
) | |
# use precompiled headers | |
set_target_properties(${APP_NAME} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "${CMAKE_SOURCE_DIR}/pch-linux.h") | |
set_target_properties(${APP_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) | |
cotire(${APP_NAME}) | |
# | |
# Link | |
# | |
#add_custom_command( | |
# TARGET ${APP_NAME} PRE_BUILD | |
# COMMAND ln -s /usr/lib/gcc/x86_64-linux-gnu/${GCC_VERSION}/libstdc++.a ${CMAKE_BINARY_DIR}/ | |
#) | |
target_link_libraries(${APP_NAME} | |
${LIB_DIR}/libcocos2d.a | |
${LIB_DIR}/libflatbuffers.a | |
${LIB_DIR}/libtinyxml2.a | |
${LIB_DIR}/libunzip.a | |
${LIB_DIR}/libxxhash.a | |
${LIB_DIR}/libchipmunk.a | |
${LIB_DIR}/libwebp.a | |
${LIB_DIR}/libfreetype.a | |
${CMAKE_BINARY_DIR}/libstdc++.a | |
${CMAKE_SOURCE_DIR}/libGLEW-1.13.a | |
${CMAKE_THREAD_LIBS_INIT} | |
${OPENGL_LIBRARIES} | |
${PNG_LIBRARIES} | |
${X11_LIBRARIES} | |
${ZLIB_LIBRARIES} | |
${FONTCONFIG_LIBRARIES} | |
${CURL_LIBRARIES} | |
) | |
# ${CMAKE_BINARY_DIR}/libstdc++.a | |
# ${GLEW_LIBRARIES} | |
# ${CMAKE_SOURCE_DIR}/libpng12.a | |
# ${LIB_DIR}/librecast.a | |
# ${LIB_DIR}/libbullet.a | |
# ${LIB_DIR}/libjpeg.a | |
# ${LIB_DIR}/libtiff.a | |
# ${LIB_DIR}/libwebp.a | |
#link_directories(${CMAKE_BINARY_DIR}) | |
target_link_libraries(${APP_NAME} | |
${CMAKE_SOURCE_DIR}/libsteam_api.so | |
${CMAKE_SOURCE_DIR}/libfmod.so.8 | |
${CMAKE_SOURCE_DIR}/libfmodstudio.so.8 | |
${CMAKE_SOURCE_DIR}/libglfw.so.3 | |
) | |
# ${CMAKE_SOURCE_DIR}/libGLEW.so.1.13 | |
# /usr/lib/x86_64-linux-gnu/libglfw.so | |
# /usr/local/lib/libglfw.so | |
# ${LIB_DIR}/libfmodex64.so | |
# | |
# Copy libraries | |
# | |
file(COPY ${CMAKE_SOURCE_DIR}/libsteam_api.so DESTINATION ${APP_BIN_DIR}) | |
file(COPY ${CMAKE_SOURCE_DIR}/libglfw.so.3 DESTINATION ${APP_BIN_DIR}) | |
file(COPY ${CMAKE_SOURCE_DIR}/libfmod.so.8 DESTINATION ${APP_BIN_DIR}) | |
file(COPY ${CMAKE_SOURCE_DIR}/libfmodstudio.so.8 DESTINATION ${APP_BIN_DIR}) | |
#file(COPY ${CMAKE_SOURCE_DIR}/libfmodex64.so DESTINATION ${APP_BIN_DIR}) | |
file(COPY ${CMAKE_SOURCE_DIR}/libpng12.so.0 DESTINATION ${APP_BIN_DIR}) | |
file(COPY ${CMAKE_SOURCE_DIR}/icon.png DESTINATION ${APP_BIN_DIR}) | |
file(COPY ${CMAKE_SOURCE_DIR}/steam_appid.txt DESTINATION ${APP_BIN_DIR}) | |
#if(CMAKE_BUILD_TYPE STREQUAL "Debug") | |
# ... | |
#else() | |
# ... | |
#endif() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment