cmake_minimum_required(VERSION 3.23) project(meowcraft) set(CMAKE_CXX_STANDARD 17) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Enable assertions for RelWithDebInfo builds. string(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") if (NOT UNIX) set(GLEW_USE_STATIC_LIBS ON) endif (NOT UNIX) find_package(glfw3 3.3 REQUIRED) find_package(GLEW REQUIRED) find_package(OpenGL REQUIRED) # Vendored shared libraries for MinGW-w64 # for cross-compiling to Windows from macOS if (WIN32) set_target_properties(glfw PROPERTIES IMPORTED_IMPLIB_RELEASE "${CMAKE_SOURCE_DIR}/vendor/mingw/libglfw3.a" ) set_target_properties(GLEW::glew_s PROPERTIES IMPORTED_LOCATION_RELEASE "${CMAKE_SOURCE_DIR}/vendor/mingw/libglew32.a" INTERFACE_LINK_LIBRARIES "" # Tries importing OpenGL.framework on macOS otherwise ) endif (WIN32) add_executable(meowcraft src/main.cpp src/Defines.hpp src/Game.cpp src/Game.hpp src/Render.cpp src/Render.hpp src/Common/Sizes.hpp src/GFX/Window.cpp src/GFX/Window.hpp src/GFX/Mesh.cpp src/GFX/Mesh.hpp src/Math/Vector.hpp src/Math/Common.hpp src/GFX/Shading/Shader.cpp src/GFX/Shading/Shader.hpp src/GFX/Shading/Program.cpp src/GFX/Shading/Program.hpp src/Math/Matrix.hpp src/Math/MVP.hpp src/GFX/Camera.cpp src/GFX/Camera.hpp src/Math/Rotation.hpp src/GFX/Shading/Uniform.cpp src/GFX/Shading/Uniform.hpp src/GFX/Texture.cpp src/GFX/Texture.hpp src/Assets.cpp src/Assets.hpp src/GFX/Image/RawImage.cpp src/GFX/Image/RawImage.hpp src/GFX/Image/PPMParser.cpp src/GFX/Image/PPMParser.hpp src/World/Chunk.cpp src/World/Chunk.hpp src/World/BlockType.hpp src/World/Generation/Generator.cpp src/World/Generation/Generator.hpp src/World/BlockSide.hpp src/World/World.cpp src/World/World.hpp src/World/ChunkIndex.hpp src/Util/ImageViewer.cpp src/Util/ImageViewer.hpp src/Math/Interpolation.cpp src/Math/Grid.cpp src/Math/Perlin.cpp src/Compute/Queue.hpp src/Math/Constants.hpp src/World/Generation/ChunkMeshing.cpp src/World/Generation/ChunkMeshing.hpp src/Math/Tensor.hpp src/World/Generation/Decoration.cpp src/World/Generation/Decoration.hpp src/Math/Random.cpp src/Math/Random.hpp src/World/Clouds.cpp src/World/Clouds.hpp src/GFX/Util/MeshBuilder.hpp src/GFX/Util/Primitives.cpp src/GFX/Util/Primitives.hpp src/Math/AABB.cpp src/Math/AABB.hpp src/Time.cpp src/Time.hpp src/World/Generation/Lighting.cpp src/World/Generation/Lighting.hpp src/World/Generation/ChunkNeighbors.hpp src/World/Generation/ChunkNeighbors.cpp src/World/ChunkRegistry.cpp src/World/ChunkRegistry.hpp src/World/Position.hpp src/World/ChunkDimensions.hpp src/Transform.cpp src/Transform.hpp src/Entities/Player.cpp src/Entities/Player.hpp src/Common/FlexArray.hpp src/Math/Ray.hpp src/Common/Lambda.hpp src/Math/Functions.hpp src/Common/Casts.hpp src/World/VoxelTraversal.hpp src/Common/Assert.hpp src/Common/Pure.hpp src/GFX/Actions.hpp src/GFX/Resources.cpp src/GFX/Resources.hpp src/ThreadRole.hpp src/Input.cpp src/Input.hpp ) if (WIN32) set(LINK_FLAGS "-static-libgcc -static-libstdc++ -static -mwindows") endif (WIN32) target_link_libraries(meowcraft PRIVATE glfw GLEW::GLEW OpenGL::GL ${LINK_FLAGS}) function(make_includable input_file output_file) file(READ ${input_file} content) set(delim "meowcraft_asset") set(content "R\"${delim}(${content})${delim}\"") file(WRITE ${output_file} "${content}") endfunction(make_includable) function(make_assets) foreach(file ${ARGN}) make_includable(assets/${file} assets/generated/${file}.include) endforeach() endfunction(make_assets) make_assets(images/atlas.ppm shaders/terrain.frag.glsl shaders/terrain.vert.glsl shaders/clouds.frag.glsl shaders/clouds.vert.glsl shaders/image_viewer.frag.glsl shaders/image_viewer.vert.glsl shaders/block_outline.frag.glsl shaders/block_outline.vert.glsl )