cmake_minimum_required(VERSION 3.28) project(PhysicsBlockGame CXX) set(CMAKE_CXX_STANDARD 23) include(FetchContent) # Enable Hot Reload for MSVC compilers if supported. if (POLICY CMP0141) cmake_policy(SET CMP0141 NEW) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") endif() if(WIN32) set(CMAKE_GENERATOR "Visual Studio 17 2022") endif() FetchContent_Declare( spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git GIT_TAG v1.15.0 GIT_PROGRESS TRUE ) message("Fetched Spdlog") FetchContent_Declare( clipp GIT_REPOSITORY https://github.com/muellan/clipp.git GIT_TAG v1.2.3 GIT_PROGRESS TRUE ) message("Fetched Clipp") FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz) message("Fetched Nlohmann JSON") set(OGRE_CONFIG_THREAD_PROVIDER 0) set(OGRE_CONFIG_THREADS 0) set(OGRE_BUILD_COMPONENT_SCENE_FORMAT 1) set(OGRE_BUILD_SAMPLES2 0) set(OGRE_BUILD_TESTS 0) FetchContent_Declare( "Ogre-Next-Deps" GIT_REPOSITORY "https://github.com/OGRECave/ogre-next-deps" GIT_TAG "master" GIT_PROGRESS TRUE ) set(OGRE_DEPENDENCIES_DIR ${Ogre-Next-Deps_SOURCE_DIR}../../Ogre-Next-Deps/build/ogredeps) #..\..\ogre-next-deps\build\ogredeps) message("Fetched Ogre-Next-Deps") FetchContent_Declare( "Ogre-Next" GIT_REPOSITORY "https://github.com/OGRECave/ogre-next" GIT_TAG "master" GIT_PROGRESS TRUE ) message("Fetched Ogre-Next") # The configurations we support set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution") # When turning this option on, the library will be compiled using doubles for positions. This allows for much bigger worlds. set(DOUBLE_PRECISION OFF) # When turning this option on, the library will be compiled with debug symbols set(GENERATE_DEBUG_SYMBOLS ON) # When turning this option on, the library will override the default CMAKE_CXX_FLAGS_DEBUG/RELEASE values, otherwise they will use the platform defaults set(OVERRIDE_CXX_FLAGS OFF) # When turning this option on, the library will be compiled in such a way to attempt to keep the simulation deterministic across platforms set(CROSS_PLATFORM_DETERMINISTIC ON) # When turning this option on, the library will be compiled with interprocedural optimizations enabled, also known as link-time optimizations or link-time code generation. # Note that if you turn this on you need to use SET_INTERPROCEDURAL_OPTIMIZATION() or set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) to enable LTO specifically for your own project as well. # If you don't do this you may get an error: /usr/bin/ld: libJolt.a: error adding symbols: file format not recognized set(INTERPROCEDURAL_OPTIMIZATION ON) # When turning this on, in Debug and Release mode, the library will emit extra code to ensure that the 4th component of a 3-vector is kept the same as the 3rd component # and will enable floating point exceptions during simulation to detect divisions by zero. # Note that this currently only works using MSVC. Clang turns Float2 into a SIMD vector sometimes causing floating point exceptions (the option is ignored). set(FLOATING_POINT_EXCEPTIONS_ENABLED OFF) # When turning this on, the library will be compiled with C++ exceptions enabled. # This adds some overhead and Jolt doesn't use exceptions so by default it is off. set(CPP_EXCEPTIONS_ENABLED ON) # When turning this on, the library will be compiled with C++ RTTI enabled. # This adds some overhead and Jolt doesn't use RTTI so by default it is off. set(CPP_RTTI_ENABLED OFF) # Number of bits to use in ObjectLayer. Can be 16 or 32. set(OBJECT_LAYER_BITS 16) # Select X86 processor features to use, by default the library compiles with AVX2, if everything is off it will be SSE2 compatible. set(USE_SSE4_1 ON) set(USE_SSE4_2 ON) set(USE_AVX ON) set(USE_AVX2 ON) set(USE_AVX512 OFF) set(USE_LZCNT ON) set(USE_TZCNT ON) set(USE_F16C ON) set(USE_FMADD ON) FetchContent_Declare( JoltPhysics GIT_REPOSITORY "https://github.com/jrouwe/JoltPhysics" GIT_TAG "v5.3.0" SOURCE_SUBDIR "Build" ) message("Fetched Jolt Physics Engine") FetchContent_MakeAvailable(spdlog) message("SpdLog Made Availible") FetchContent_MakeAvailable(json) message("Nlohmann JSON Made Availible") FetchContent_MakeAvailable(JoltPhysics) option(OgreNextHlmsPbs TRUE) option(OgreNextHlmsUnlit TRUE) option(OgreNextMeshLodGenerator TRUE) option(OgreNextProperty TRUE) option(OgreNextOverlay TRUE) option(OgreCmgenToCubemap TRUE) option(OgreMeshTool TRUE) option(RenderSystem_GL3Plus TRUE) option(Plugin_ParticleFX TRUE) option(Plugin_ParticleFX2 TRUE) message("Jolt Physics Engine Made Availible") FetchContent_MakeAvailable(Ogre-Next-Deps) message("Ogre-Next-Deps Made Availible") FetchContent_MakeAvailable(Ogre-Next) message("Ogre-Next Made Availible") if (MSVC) # 64 bit architecture set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64") # Set runtime library if (USE_STATIC_MSVC_RUNTIME_LIBRARY) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif()# endif() add_compile_options(-fconcepts-diagnostics-depth=10) file(GLOB LIBRARY_SOURCES source/*.cpp) file(GLOB TEST_SOURCES test/*.cpp) file(GLOB SCRATCHPAD_SOURCE scratchpad/*.cpp) set(OgreNextSourceDir ${Ogre-Next_SOURCE_DIR}) include_directories( include ${json_SOURCE_DIR}/include ${OgreNextMain_SOURCE_DIR}/include ${OgreNextMain_BINARY_DIR}/../include ${OgreNextMain_SOURCE_DIR}/../Components/Hlms/Pbs/include ${OgreNextMain_SOURCE_DIR}/../Components/Hlms/Unlit/include ${OgreNextMain_SOURCE_DIR}/../Components/Hlms/Common/include ${JoltPhysics_SOURCE_DIR}/.. ${ftxui_SOURCE_DIR}/include ${clipp_SOURCE_DIR}/include ${spdlog_SOURCE_DIR}/include ) message("Include Directories Set") set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") message("Set Linker Flags") # Enable link time optimization in Release and Distribution mode if requested and available #SET_INTERPROCEDURAL_OPTIMIZATION() #add_library(${PROJECT_NAME} ${LIBRARY_SOURCES}) #target_link_libraries(${PROJECT_NAME} PRIVATE OpenCL af afopencl) add_executable(scratchpad ${SCRATCHPAD_SOURCE}) message("Executable Added") set_property(TARGET scratchpad PROPERTY CXX_STANDARD 23) message("C++ Standard Set") target_link_libraries(scratchpad PRIVATE # ftxui::component # ftxui::dom # ftxui::screen OgreMain OgreHlmsPbs OgreHlmsUnlit spdlog::spdlog #$<$:ws2_32> Jolt ) message("Link Libraries Targeted")