diff --git a/CMakeLists.txt b/CMakeLists.txt index f98758e..5939a5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/src/gamelib/CMakeLists.txt b/src/gamelib/CMakeLists.txt new file mode 100644 index 0000000..ecd2670 --- /dev/null +++ b/src/gamelib/CMakeLists.txt @@ -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 +) diff --git a/src/character.cpp b/src/gamelib/character.cpp similarity index 100% rename from src/character.cpp rename to src/gamelib/character.cpp diff --git a/src/character.hpp b/src/gamelib/character.hpp similarity index 100% rename from src/character.hpp rename to src/gamelib/character.hpp diff --git a/src/compatibility.h b/src/gamelib/compatibility.h similarity index 100% rename from src/compatibility.h rename to src/gamelib/compatibility.h diff --git a/src/constrained_position.hpp b/src/gamelib/constrained_position.hpp similarity index 100% rename from src/constrained_position.hpp rename to src/gamelib/constrained_position.hpp diff --git a/src/constrained_value.hpp b/src/gamelib/constrained_value.hpp similarity index 100% rename from src/constrained_value.hpp rename to src/gamelib/constrained_value.hpp diff --git a/src/csvloader.cpp b/src/gamelib/csvloader.cpp similarity index 100% rename from src/csvloader.cpp rename to src/gamelib/csvloader.cpp diff --git a/src/csvloader.hpp b/src/gamelib/csvloader.hpp similarity index 100% rename from src/csvloader.hpp rename to src/gamelib/csvloader.hpp diff --git a/src/fsgn.cpp b/src/gamelib/fsgn.cpp similarity index 100% rename from src/fsgn.cpp rename to src/gamelib/fsgn.cpp diff --git a/src/fsgn.hpp b/src/gamelib/fsgn.hpp similarity index 100% rename from src/fsgn.hpp rename to src/gamelib/fsgn.hpp diff --git a/src/gameactions.hpp b/src/gamelib/gameactions.hpp similarity index 100% rename from src/gameactions.hpp rename to src/gamelib/gameactions.hpp diff --git a/src/gamescenebase.cpp b/src/gamelib/gamescenebase.cpp similarity index 100% rename from src/gamescenebase.cpp rename to src/gamelib/gamescenebase.cpp diff --git a/src/gamescenebase.hpp b/src/gamelib/gamescenebase.hpp similarity index 100% rename from src/gamescenebase.hpp rename to src/gamelib/gamescenebase.hpp diff --git a/src/grid_raytrace.cpp b/src/gamelib/grid_raytrace.cpp similarity index 100% rename from src/grid_raytrace.cpp rename to src/gamelib/grid_raytrace.cpp diff --git a/src/grid_raytrace.hpp b/src/gamelib/grid_raytrace.hpp similarity index 100% rename from src/grid_raytrace.hpp rename to src/gamelib/grid_raytrace.hpp diff --git a/src/ingamescene.cpp b/src/gamelib/ingamescene.cpp similarity index 99% rename from src/ingamescene.cpp rename to src/gamelib/ingamescene.cpp index e08062e..8af1069 100644 --- a/src/ingamescene.cpp +++ b/src/gamelib/ingamescene.cpp @@ -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" diff --git a/src/ingamescene.hpp b/src/gamelib/ingamescene.hpp similarity index 100% rename from src/ingamescene.hpp rename to src/gamelib/ingamescene.hpp diff --git a/src/inputbag.cpp b/src/gamelib/inputbag.cpp similarity index 100% rename from src/inputbag.cpp rename to src/gamelib/inputbag.cpp diff --git a/src/inputbag.hpp b/src/gamelib/inputbag.hpp similarity index 100% rename from src/inputbag.hpp rename to src/gamelib/inputbag.hpp diff --git a/src/inputdevicetype.hpp b/src/gamelib/inputdevicetype.hpp similarity index 100% rename from src/inputdevicetype.hpp rename to src/gamelib/inputdevicetype.hpp diff --git a/src/key.hpp b/src/gamelib/key.hpp similarity index 100% rename from src/key.hpp rename to src/gamelib/key.hpp diff --git a/src/moveable.cpp b/src/gamelib/moveable.cpp similarity index 100% rename from src/moveable.cpp rename to src/gamelib/moveable.cpp diff --git a/src/moveable.hpp b/src/gamelib/moveable.hpp similarity index 100% rename from src/moveable.hpp rename to src/gamelib/moveable.hpp diff --git a/src/movingobject.cpp b/src/gamelib/movingobject.cpp similarity index 100% rename from src/movingobject.cpp rename to src/gamelib/movingobject.cpp diff --git a/src/movingobject.hpp b/src/gamelib/movingobject.hpp similarity index 100% rename from src/movingobject.hpp rename to src/gamelib/movingobject.hpp diff --git a/src/observersmanager.hpp b/src/gamelib/observersmanager.hpp similarity index 100% rename from src/observersmanager.hpp rename to src/gamelib/observersmanager.hpp diff --git a/src/rect.hpp b/src/gamelib/rect.hpp similarity index 100% rename from src/rect.hpp rename to src/gamelib/rect.hpp diff --git a/src/rect_to_sdl.cpp b/src/gamelib/rect_to_sdl.cpp similarity index 100% rename from src/rect_to_sdl.cpp rename to src/gamelib/rect_to_sdl.cpp diff --git a/src/rect_to_sdl.hpp b/src/gamelib/rect_to_sdl.hpp similarity index 100% rename from src/rect_to_sdl.hpp rename to src/gamelib/rect_to_sdl.hpp diff --git a/src/sdlmain.cpp b/src/gamelib/sdlmain.cpp similarity index 100% rename from src/sdlmain.cpp rename to src/gamelib/sdlmain.cpp diff --git a/src/sdlmain.hpp b/src/gamelib/sdlmain.hpp similarity index 100% rename from src/sdlmain.hpp rename to src/gamelib/sdlmain.hpp diff --git a/src/sizenotifiable.cpp b/src/gamelib/sizenotifiable.cpp similarity index 100% rename from src/sizenotifiable.cpp rename to src/gamelib/sizenotifiable.cpp diff --git a/src/sizenotifiable.hpp b/src/gamelib/sizenotifiable.hpp similarity index 100% rename from src/sizenotifiable.hpp rename to src/gamelib/sizenotifiable.hpp diff --git a/src/sizeratio.cpp b/src/gamelib/sizeratio.cpp similarity index 100% rename from src/sizeratio.cpp rename to src/gamelib/sizeratio.cpp diff --git a/src/sizeratio.hpp b/src/gamelib/sizeratio.hpp similarity index 100% rename from src/sizeratio.hpp rename to src/gamelib/sizeratio.hpp diff --git a/src/texture.cpp b/src/gamelib/texture.cpp similarity index 100% rename from src/texture.cpp rename to src/gamelib/texture.cpp diff --git a/src/texture.hpp b/src/gamelib/texture.hpp similarity index 100% rename from src/texture.hpp rename to src/gamelib/texture.hpp diff --git a/src/tileindextype.hpp b/src/gamelib/tileindextype.hpp similarity index 100% rename from src/tileindextype.hpp rename to src/gamelib/tileindextype.hpp diff --git a/src/tileiterator.cpp b/src/gamelib/tileiterator.cpp similarity index 100% rename from src/tileiterator.cpp rename to src/gamelib/tileiterator.cpp diff --git a/src/tileiterator.hpp b/src/gamelib/tileiterator.hpp similarity index 100% rename from src/tileiterator.hpp rename to src/gamelib/tileiterator.hpp diff --git a/src/tileproperty.hpp b/src/gamelib/tileproperty.hpp similarity index 100% rename from src/tileproperty.hpp rename to src/gamelib/tileproperty.hpp diff --git a/src/vector.hpp b/src/gamelib/vector.hpp similarity index 100% rename from src/vector.hpp rename to src/gamelib/vector.hpp diff --git a/src/worldgrid.cpp b/src/gamelib/worldgrid.cpp similarity index 100% rename from src/worldgrid.cpp rename to src/gamelib/worldgrid.cpp diff --git a/src/worldgrid.hpp b/src/gamelib/worldgrid.hpp similarity index 100% rename from src/worldgrid.hpp rename to src/gamelib/worldgrid.hpp diff --git a/src/worlditems.cpp b/src/gamelib/worlditems.cpp similarity index 100% rename from src/worlditems.cpp rename to src/gamelib/worlditems.cpp diff --git a/src/worlditems.hpp b/src/gamelib/worlditems.hpp similarity index 100% rename from src/worlditems.hpp rename to src/gamelib/worlditems.hpp diff --git a/src/worldsizenotifiable.cpp b/src/gamelib/worldsizenotifiable.cpp similarity index 100% rename from src/worldsizenotifiable.cpp rename to src/gamelib/worldsizenotifiable.cpp diff --git a/src/worldsizenotifiable.hpp b/src/gamelib/worldsizenotifiable.hpp similarity index 100% rename from src/worldsizenotifiable.hpp rename to src/gamelib/worldsizenotifiable.hpp diff --git a/src/worldviewport.cpp b/src/gamelib/worldviewport.cpp similarity index 100% rename from src/worldviewport.cpp rename to src/gamelib/worldviewport.cpp diff --git a/src/worldviewport.hpp b/src/gamelib/worldviewport.hpp similarity index 100% rename from src/worldviewport.hpp rename to src/gamelib/worldviewport.hpp diff --git a/src/mycurryConfig.h.in b/src/mycurry_toplevelConfig.h.in similarity index 100% rename from src/mycurryConfig.h.in rename to src/mycurry_toplevelConfig.h.in diff --git a/src/standalone/CMakeLists.txt b/src/standalone/CMakeLists.txt new file mode 100644 index 0000000..a44913f --- /dev/null +++ b/src/standalone/CMakeLists.txt @@ -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 +) diff --git a/src/main.cpp b/src/standalone/main.cpp similarity index 100% rename from src/main.cpp rename to src/standalone/main.cpp diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 78f141b..4134d13 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -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 +)