160 lines
4.1 KiB
CMake
160 lines
4.1 KiB
CMake
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
|
project(CloonelJump CXX)
|
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/include")
|
|
|
|
include(TargetArch)
|
|
include(CTest)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wconversion")
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -Wconversion -DWITH_DEBUG_VISUALS -O0")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wextra -pedantic -Wconversion -O3")
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
|
|
|
|
target_architecture(TARGET_ARCH)
|
|
message (STATUS "Target architecture: ${TARGET_ARCH}")
|
|
|
|
option(WITH_BUILTIN_PHYSFS "Force using the version of PhysFS accompanying the code even if a system library is available" OFF)
|
|
option(FORCE_OPENGLES "Try to chose the openGL ES renderer if available. Enable this on Raspberry Pi" OFF)
|
|
option(RASPBERRY_PI "Compile for Raspberry Pi" OFF)
|
|
|
|
if (TARGET_ARCH MATCHES "^x86_64$")
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse3")
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse3")
|
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -msse3")
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -msse3")
|
|
endif (TARGET_ARCH MATCHES "^x86_64$")
|
|
|
|
if (FORCE_OPENGLES OR RASPBERRY_PI)
|
|
add_definitions(-DFORCE_OPENGLES)
|
|
if (RASPBERRY_PI)
|
|
add_definitions(-DRASPBERRY_PI)
|
|
endif(RASPBERRY_PI)
|
|
endif (FORCE_OPENGLES OR RASPBERRY_PI)
|
|
|
|
include(FindPkgConfig)
|
|
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
|
|
|
|
find_package(PNG REQUIRED)
|
|
find_package(Boost 1.55.0 REQUIRED)
|
|
if (NOT WITH_BUILTIN_PHYSFS)
|
|
find_package(PhysFS 2.0.3)
|
|
endif()
|
|
|
|
if (PHYSFS_FOUND)
|
|
message(STATUS "Using system's PhysFS, set WITH_BUILTIN_PHYSFS to on to override this")
|
|
else(PHYSFS_FOUND)
|
|
message(STATUS "Using internal PhysFS")
|
|
set(PHYSFS_INCLUDE_DIR "lib/physfs-2.0.3")
|
|
set(PHYSFS_LIBRARY "physfs")
|
|
endif(PHYSFS_FOUND)
|
|
|
|
add_definitions(
|
|
${PNG_DEFINITIONS}
|
|
# -DWITH_VERBOSE_OBS_MANAGER
|
|
-DWITH_VERBOSE_COLLIDER
|
|
)
|
|
|
|
if (RASPBERRY_PI)
|
|
message(STATUS "Will build for Raspberry Pi")
|
|
include_directories(SYSTEM
|
|
/opt/vc/include
|
|
/opt/vc/include/interface/vcos/pthreads
|
|
/opt/vc/include/interface/vmcs_host/linux
|
|
)
|
|
link_directories(
|
|
/opt/vc/lib
|
|
)
|
|
endif (RASPBERRY_PI)
|
|
|
|
include_directories(SYSTEM
|
|
${SDL2_INCLUDE_DIR}
|
|
${PNG_INCLUDE_DIRS}
|
|
${Boost_INCLUDE_DIRS}
|
|
lib/tree-3.1/src
|
|
)
|
|
include_directories(
|
|
src
|
|
src/movers
|
|
include
|
|
"${PROJECT_BINARY_DIR}"
|
|
${PHYSFS_INCLUDE_DIR}
|
|
lib/vectorwrapper/include
|
|
)
|
|
|
|
configure_file(
|
|
"${PROJECT_SOURCE_DIR}/src/${PROJECT_NAME}Config.h.in"
|
|
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h"
|
|
)
|
|
|
|
if (NOT PHYSFS_FOUND)
|
|
add_subdirectory(lib/physfs-2.0.3)
|
|
endif(NOT PHYSFS_FOUND)
|
|
|
|
add_executable(${PROJECT_NAME}
|
|
src/main.cpp
|
|
src/texture.cpp
|
|
src/sdlerror.cpp
|
|
src/sdlmain.cpp
|
|
src/gamebase.cpp
|
|
src/character.cpp
|
|
src/placeable.cpp
|
|
src/physicsfswrapper.cpp
|
|
src/gameplayscene.cpp
|
|
src/movers/mover.cpp
|
|
src/movers/moveroneshot.cpp
|
|
src/movers/moversine.cpp
|
|
src/gameplaysceneclassic.cpp
|
|
src/movers/moverrelative.cpp
|
|
src/inputbag.cpp
|
|
src/movers/moverleftright.cpp
|
|
src/tiledwallpaper.cpp
|
|
src/drawable.cpp
|
|
src/sizeratio.cpp
|
|
src/sizenotifiable.cpp
|
|
src/horzcollisionbar.cpp
|
|
src/platform.cpp
|
|
src/vectormath.cpp
|
|
src/platformspawner.cpp
|
|
src/movers/moverworld.cpp
|
|
src/line.cpp
|
|
src/collider.cpp
|
|
src/platformset.cpp
|
|
src/drawableline.cpp
|
|
)
|
|
|
|
target_link_libraries(${PROJECT_NAME}
|
|
${SDL2_LIBRARIES}
|
|
${PHYSFS_LIBRARY}
|
|
${PNG_LIBRARIES}
|
|
)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}
|
|
PRIVATE VWR_STATIC_CAST_RESULTS
|
|
PRIVATE VWR_SIZE_TYPE=uint32_t
|
|
)
|
|
|
|
if (RASPBERRY_PI)
|
|
target_link_libraries(${PROJECT_NAME}
|
|
bcm_host
|
|
)
|
|
endif(RASPBERRY_PI)
|
|
|
|
if (BUILD_TESTING)
|
|
add_subdirectory(test/unit)
|
|
endif()
|
|
target_compile_features(${PROJECT_NAME}
|
|
PRIVATE cxx_nullptr
|
|
PRIVATE cxx_range_for
|
|
PRIVATE cxx_lambdas
|
|
PRIVATE cxx_decltype_auto
|
|
PRIVATE cxx_defaulted_functions
|
|
PRIVATE cxx_deleted_functions
|
|
PRIVATE cxx_auto_type
|
|
PRIVATE cxx_decltype_incomplete_return_types
|
|
PRIVATE cxx_defaulted_move_initializers
|
|
PRIVATE cxx_noexcept
|
|
PRIVATE cxx_rvalue_references
|
|
PRIVATE cxx_delegating_constructors
|
|
)
|