Refactor cmake file so the main part of the code is a lib.
This commit is contained in:
parent
7f49ef36d6
commit
0a3897f60a
83 changed files with 111 additions and 98 deletions
135
CMakeLists.txt
135
CMakeLists.txt
|
@ -1,21 +1,31 @@
|
|||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
project(CloonelJump CXX)
|
||||
project(CloonelJumpProject CXX)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/include")
|
||||
|
||||
include(TargetArch)
|
||||
include(CTest)
|
||||
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)
|
||||
|
||||
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")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CLOONEL_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
|
@ -27,34 +37,19 @@ if (TARGET_ARCH MATCHES "^x86_64$")
|
|||
endif (TARGET_ARCH MATCHES "^x86_64$")
|
||||
|
||||
if (FORCE_OPENGLES OR RASPBERRY_PI)
|
||||
add_definitions(-DFORCE_OPENGLES)
|
||||
target_add_definitions(${PROJECT_NAME} INTERFACE -DFORCE_OPENGLES)
|
||||
if (RASPBERRY_PI)
|
||||
add_definitions(-DRASPBERRY_PI)
|
||||
target_add_definitions(${PROJECT_NAME} INTERFACE -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)
|
||||
if (WITH_BUILTIN_PHYSFS)
|
||||
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
|
||||
)
|
||||
else(WITH_BUILTIN_PHYSFS)
|
||||
message(STATUS "Using system's PhysFS, set WITH_BUILTIN_PHYSFS to on to override this")
|
||||
endif(WITH_BUILTIN_PHYSFS)
|
||||
|
||||
if (RASPBERRY_PI)
|
||||
message(STATUS "Will build for Raspberry Pi")
|
||||
|
@ -68,19 +63,22 @@ if (RASPBERRY_PI)
|
|||
)
|
||||
endif (RASPBERRY_PI)
|
||||
|
||||
include_directories(SYSTEM
|
||||
${SDL2_INCLUDE_DIR}
|
||||
${PNG_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
lib/tree-3.1/src
|
||||
add_library(${PROJECT_NAME} INTERFACE)
|
||||
|
||||
target_include_directories(${PROJECT_NAME} SYSTEM
|
||||
INTERFACE ${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
include_directories(
|
||||
src
|
||||
src/movers
|
||||
include
|
||||
"${PROJECT_BINARY_DIR}"
|
||||
${PHYSFS_INCLUDE_DIR}
|
||||
lib/vectorwrapper/include
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
INTERFACE "${PROJECT_BINARY_DIR}"
|
||||
INTERFACE lib/vectorwrapper/include
|
||||
INTERFACE lib/tree-3.1/src
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
INTERFACE VWR_STATIC_CAST_RESULTS
|
||||
INTERFACE VWR_SIZE_TYPE=uint32_t
|
||||
INTERFACE ${PNG_DEFINITIONS}
|
||||
)
|
||||
|
||||
configure_file(
|
||||
|
@ -88,73 +86,18 @@ configure_file(
|
|||
"${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 (NOT PHYSFS_FOUND)
|
||||
add_subdirectory(lib/physfs-2.0.3)
|
||||
endif(NOT PHYSFS_FOUND)
|
||||
|
||||
add_subdirectory(src/jumping)
|
||||
add_subdirectory(src/clooneljump)
|
||||
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
|
||||
)
|
||||
|
|
13
src/clooneljump/CMakeLists.txt
Normal file
13
src/clooneljump/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
project(clooneljump CXX)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
main.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE jumping
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${CLOONEL_SRC_DIR}/src/jumping
|
||||
)
|
|
@ -17,7 +17,7 @@
|
|||
along with CloonelJump. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "CloonelJumpConfig.h"
|
||||
#include "CloonelJumpProjectConfig.h"
|
||||
#include "sdlmain.hpp"
|
||||
#include "physicsfswrapper.hpp"
|
||||
#include "gameplaysceneclassic.hpp"
|
52
src/jumping/CMakeLists.txt
Normal file
52
src/jumping/CMakeLists.txt
Normal file
|
@ -0,0 +1,52 @@
|
|||
project(jumping CXX)
|
||||
|
||||
add_library(${PROJECT_NAME}
|
||||
texture.cpp
|
||||
sdlerror.cpp
|
||||
sdlmain.cpp
|
||||
gamebase.cpp
|
||||
character.cpp
|
||||
placeable.cpp
|
||||
physicsfswrapper.cpp
|
||||
gameplayscene.cpp
|
||||
movers/mover.cpp
|
||||
movers/moveroneshot.cpp
|
||||
movers/moversine.cpp
|
||||
gameplaysceneclassic.cpp
|
||||
movers/moverrelative.cpp
|
||||
inputbag.cpp
|
||||
movers/moverleftright.cpp
|
||||
tiledwallpaper.cpp
|
||||
drawable.cpp
|
||||
sizeratio.cpp
|
||||
sizenotifiable.cpp
|
||||
horzcollisionbar.cpp
|
||||
platform.cpp
|
||||
vectormath.cpp
|
||||
platformspawner.cpp
|
||||
movers/moverworld.cpp
|
||||
line.cpp
|
||||
collider.cpp
|
||||
platformset.cpp
|
||||
drawableline.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE ${SDL2_LIBRARIES}
|
||||
PRIVATE ${PHYSFS_LIBRARY}
|
||||
PRIVATE ${PNG_LIBRARIES}
|
||||
PUBLIC CloonelJumpProject
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${SDL2_INCLUDE_DIR}
|
||||
PRIVATE ${PNG_INCLUDE_DIRS}
|
||||
PRIVATE .
|
||||
PRIVATE movers
|
||||
PRIVATE ${PHYSFS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME}
|
||||
# INTERFACE WITH_VERBOSE_OBS_MANAGER
|
||||
INTERFACE WITH_VERBOSE_COLLIDER
|
||||
)
|
|
@ -5,7 +5,12 @@ add_executable(${PROJECT_NAME}
|
|||
)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${CMAKE_SOURCE_DIR}/lib/catch/single_include
|
||||
PRIVATE ${CLOONEL_SRC_DIR}/lib/catch/single_include
|
||||
PRIVATE ${CLOONEL_SRC_DIR}/src/jumping
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE jumping
|
||||
)
|
||||
|
||||
add_test(
|
||||
|
|
Loading…
Reference in a new issue