Move everything into a shared lib so unit test can access stuff.

This commit is contained in:
King_DuckZ 2017-02-09 18:11:09 +00:00
parent e2d307da52
commit 47aa9f2948
55 changed files with 86 additions and 81 deletions

View file

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.2)
project(mycurry CXX)
project(mycurry_toplevel CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/include")
@ -7,12 +7,6 @@ include(TargetArch)
include(FindPkgConfig)
include(CTest)
set(common_gcc_flags "-Wall -Wextra -pedantic -Wconversion -ffast-math")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${common_gcc_flags} -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${common_gcc_flags}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${common_gcc_flags} -O0")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${common_gcc_flags}")
option(CURRY_FORCE_OPENGLES "Try to chose the openGL ES renderer if available. Enable this on Raspberry Pi" OFF)
option(CURRY_RASPBERRY_PI "Compile for Raspberry Pi" OFF)
@ -35,9 +29,6 @@ if (CURRY_FORCE_OPENGLES OR CURRY_RASPBERRY_PI)
endif(CURRY_RASPBERRY_PI)
endif (CURRY_FORCE_OPENGLES OR CURRY_RASPBERRY_PI)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
find_package(PNG REQUIRED)
find_package(Boost 1.55.0 REQUIRED)
if (CURRY_RASPBERRY_PI)
@ -52,78 +43,23 @@ if (CURRY_RASPBERRY_PI)
)
endif (CURRY_RASPBERRY_PI)
add_executable(${PROJECT_NAME}
src/csvloader.cpp
src/main.cpp
src/sdlmain.cpp
src/ingamescene.cpp
src/sizenotifiable.cpp
src/sizeratio.cpp
src/gamescenebase.cpp
src/worldgrid.cpp
src/worldviewport.cpp
src/inputbag.cpp
src/tileiterator.cpp
src/texture.cpp
src/movingobject.cpp
src/character.cpp
src/rect_to_sdl.cpp
src/worldsizenotifiable.cpp
src/worlditems.cpp
src/moveable.cpp
src/fsgn.cpp
src/grid_raytrace.cpp
)
target_include_directories(${PROJECT_NAME} SYSTEM
PRIVATE ${SDL2_INCLUDE_DIR}
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
PRIVATE ${PNG_INCLUDE_DIRS}
PRIVATE ${Boost_INCLUDE_DIRS}
PRIVATE lib/tree-2.81/src
)
target_include_directories(${PROJECT_NAME}
PRIVATE src
PRIVATE lib/vectorwrapper/include
PRIVATE lib/DeathHandler
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE ${SDL2_LIBRARIES}
PRIVATE ${SDL2IMAGE_LIBRARIES}
PRIVATE ${PNG_LIBRARIES}
)
if (CURRY_RASPBERRY_PI)
target_link_libraries(${PROJECT_NAME}
PRIVATE bcm_host
)
endif(CURRY_RASPBERRY_PI)
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_defaulted_move_initializers
PRIVATE cxx_noexcept
PRIVATE cxx_rvalue_references
)
configure_file(src/${PROJECT_NAME}Config.h.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.h)
target_compile_definitions(${PROJECT_NAME}
PRIVATE ${PNG_DEFINITIONS}
PRIVATE VWR_WITH_IMPLICIT_CONVERSIONS=1
PRIVATE VWR_EXTRA_ACCESSORS
)
set(common_gcc_flags -Wall -Wextra -pedantic -Wconversion -ffast-math)
configure_file(src/${PROJECT_NAME}Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.h)
add_library(${PROJECT_NAME} INTERFACE)
target_compile_options(${PROJECT_NAME} INTERFACE ${common_gcc_flags})
add_subdirectory(src/gamelib)
add_subdirectory(src/standalone)
if (BUILD_TESTING)
set(CATCH_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/Catch")
set(MYCURRY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
add_subdirectory(test/unit)
endif()

View file

@ -0,0 +1,54 @@
project(mycurry_gamelib CXX)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
PKG_SEARCH_MODULE(SDL2IMAGE REQUIRED SDL2_image>=2.0.0)
find_package(PNG REQUIRED)
add_library(${PROJECT_NAME}
csvloader.cpp
sdlmain.cpp
ingamescene.cpp
sizenotifiable.cpp
sizeratio.cpp
gamescenebase.cpp
worldgrid.cpp
worldviewport.cpp
inputbag.cpp
tileiterator.cpp
texture.cpp
movingobject.cpp
character.cpp
rect_to_sdl.cpp
worldsizenotifiable.cpp
worlditems.cpp
moveable.cpp
fsgn.cpp
grid_raytrace.cpp
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
target_include_directories(${PROJECT_NAME} SYSTEM
PRIVATE ${SDL2_INCLUDE_DIR}
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
PRIVATE ${PNG_INCLUDE_DIRS}
PRIVATE ${Boost_INCLUDE_DIRS}
PRIVATE ${CMAKE_SOURCE_DIR}/lib/tree-2.81/src
)
target_include_directories(${PROJECT_NAME}
PUBLIC ${CMAKE_SOURCE_DIR}/lib/vectorwrapper/include
PRIVATE ${CMAKE_BINARY_DIR}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE ${SDL2_LIBRARIES}
PRIVATE ${SDL2IMAGE_LIBRARIES}
PRIVATE ${PNG_LIBRARIES}
PUBLIC mycurry_toplevel
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE ${PNG_DEFINITIONS}
PUBLIC VWR_WITH_IMPLICIT_CONVERSIONS=1
PUBLIC VWR_EXTRA_ACCESSORS
)

View file

@ -19,7 +19,7 @@
#include "ingamescene.hpp"
#include "sdlmain.hpp"
#include "mycurryConfig.h"
#include "mycurry_toplevelConfig.h"
#include "key.hpp"
#include "inputbag.hpp"
#include "movingobject.hpp"

View file

@ -0,0 +1,17 @@
project(mycurry CXX)
add_executable(${PROJECT_NAME}
main.cpp
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
target_include_directories(${PROJECT_NAME}
PRIVATE "${CMAKE_SOURCE_DIR}/src/gamelib"
PRIVATE ${CMAKE_BINARY_DIR}
PRIVATE ${CMAKE_SOURCE_DIR}/lib/DeathHandler
)
target_link_libraries(${PROJECT_NAME}
PRIVATE mycurry_gamelib
)

View file

@ -1,15 +1,11 @@
project(mycurry_unit_test CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_executable(${PROJECT_NAME}
main.cpp
${MYCURRY_SOURCE_DIR}/grid_raytrace.cpp
grid_raytrace.cpp
${MYCURRY_SOURCE_DIR}/worldgrid.cpp
${MYCURRY_SOURCE_DIR}/fsgn.cpp
)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
target_compile_definitions(${PROJECT_NAME}
PRIVATE VWR_WITH_IMPLICIT_CONVERSIONS=1
@ -18,7 +14,7 @@ target_compile_definitions(${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PRIVATE ${CATCH_SOURCE_DIR}/single_include
PRIVATE ${MYCURRY_SOURCE_DIR}
PRIVATE ${CMAKE_SOURCE_DIR}/src/gamelib
PRIVATE ${CMAKE_SOURCE_DIR}/lib/vectorwrapper/include
PRIVATE ${CMAKE_SOURCE_DIR}/lib/tree-2.81/src
)
@ -29,4 +25,6 @@ add_test(
COMMAND ${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME}
PRIVATE mycurry_gamelib
)