2016-10-31 19:47:47 +00:00
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
2016-11-11 20:18:39 +00:00
project(CloonelJumpProject CXX)
2014-01-09 23:04:39 +00:00
2014-08-25 15:32:48 +00:00
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/include")
include(TargetArch)
2016-11-11 19:37:35 +00:00
include(CTest)
2016-11-11 20:18:39 +00:00
include(FindPkgConfig)
include(CMakeDependentOption)
find_package(PNG REQUIRED)
find_package(Boost 1.55.0 REQUIRED)
find_package(PhysFS 2.0.3)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
2014-08-25 15:32:48 +00:00
2016-10-31 19:47:47 +00:00
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")
2014-08-25 15:32:48 +00:00
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
2016-11-11 20:18:39 +00:00
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CLOONEL_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
2014-08-25 15:32:48 +00:00
target_architecture(TARGET_ARCH)
message (STATUS "Target architecture: ${TARGET_ARCH}")
2014-01-09 23:04:39 +00:00
2016-11-11 20:18:39 +00:00
cmake_dependent_option(WITH_BUILTIN_PHYSFS "Force using the version of PhysFS accompanying the code even if a system library is available" OFF "PHYSFS_FOUND" ON)
2014-08-06 15:44:28 +00:00
option(FORCE_OPENGLES "Try to chose the openGL ES renderer if available. Enable this on Raspberry Pi" OFF)
2014-08-06 19:04:57 +00:00
option(RASPBERRY_PI "Compile for Raspberry Pi" OFF)
2014-08-06 15:44:28 +00:00
2014-08-25 15:32:48 +00:00
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$")
2014-08-06 19:04:57 +00:00
if (FORCE_OPENGLES OR RASPBERRY_PI)
2016-11-11 20:18:39 +00:00
target_add_definitions(${PROJECT_NAME} INTERFACE -DFORCE_OPENGLES)
2014-08-06 19:04:57 +00:00
if (RASPBERRY_PI)
2016-11-11 20:18:39 +00:00
target_add_definitions(${PROJECT_NAME} INTERFACE -DRASPBERRY_PI)
2014-08-06 19:04:57 +00:00
endif(RASPBERRY_PI)
endif (FORCE_OPENGLES OR RASPBERRY_PI)
2014-08-04 16:57:14 +00:00
2016-11-11 20:18:39 +00:00
if (WITH_BUILTIN_PHYSFS)
2014-08-04 16:57:14 +00:00
message(STATUS "Using internal PhysFS")
set(PHYSFS_INCLUDE_DIR "lib/physfs-2.0.3")
set(PHYSFS_LIBRARY "physfs")
2016-11-11 20:18:39 +00:00
else(WITH_BUILTIN_PHYSFS)
message(STATUS "Using system's PhysFS, set WITH_BUILTIN_PHYSFS to on to override this")
endif(WITH_BUILTIN_PHYSFS)
2014-02-21 20:28:34 +00:00
2014-08-06 19:04:57 +00:00
if (RASPBERRY_PI)
message(STATUS "Will build for Raspberry Pi")
include_directories(SYSTEM
/opt/vc/include
2014-08-07 09:29:04 +00:00
/opt/vc/include/interface/vcos/pthreads
/opt/vc/include/interface/vmcs_host/linux
2014-08-06 19:04:57 +00:00
)
link_directories(
/opt/vc/lib
)
endif (RASPBERRY_PI)
2016-11-11 20:18:39 +00:00
add_library(${PROJECT_NAME} INTERFACE)
2014-01-09 23:04:39 +00:00
2016-11-11 20:18:39 +00:00
target_include_directories(${PROJECT_NAME} SYSTEM
INTERFACE ${Boost_INCLUDE_DIRS}
2014-01-09 23:04:39 +00:00
)
2016-11-11 20:18:39 +00:00
target_include_directories(${PROJECT_NAME}
INTERFACE "${PROJECT_BINARY_DIR}"
INTERFACE lib/vectorwrapper/include
INTERFACE lib/tree-3.1/src
2014-01-09 23:04:39 +00:00
)
2016-11-11 20:18:39 +00:00
target_compile_definitions(${PROJECT_NAME}
INTERFACE VWR_STATIC_CAST_RESULTS
INTERFACE VWR_SIZE_TYPE=uint32_t
INTERFACE ${PNG_DEFINITIONS}
2014-01-09 23:04:39 +00:00
)
2014-08-06 19:04:57 +00:00
2016-11-11 20:18:39 +00:00
configure_file(
"${PROJECT_SOURCE_DIR}/src/${PROJECT_NAME}Config.h.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.h"
2016-11-02 17:25:40 +00:00
)
2014-08-06 19:04:57 +00:00
if (RASPBERRY_PI)
target_link_libraries(${PROJECT_NAME}
bcm_host
)
endif(RASPBERRY_PI)
2016-10-31 19:47:47 +00:00
2016-11-11 20:18:39 +00:00
if (NOT PHYSFS_FOUND)
add_subdirectory(lib/physfs-2.0.3)
endif(NOT PHYSFS_FOUND)
add_subdirectory(src/jumping)
add_subdirectory(src/clooneljump)
2016-11-11 19:37:35 +00:00
if (BUILD_TESTING)
add_subdirectory(test/unit)
endif()