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}") set(GLEW_USE_STATIC_LIBS ON) 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/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/Mouse.cpp src/GFX/Mouse.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 ) if (WIN32) set(LINK_FLAGS "-static-libgcc -static-libstdc++ -static -mwindows") endif (WIN32) target_link_libraries(meowcraft PRIVATE glfw GLEW::glew_s OpenGL::GL ${LINK_FLAGS}) function(make_includable input_file output_file) file(READ ${input_file} content) set(delim "for_c++_include") set(content "R\"${delim}(\n${content})${delim}\"") file(WRITE ${output_file} "${content}") endfunction(make_includable) make_includable(assets/shaders/fragment.glsl assets/generated/shaders/fragment.glsl.includable) make_includable(assets/shaders/vertex.glsl assets/generated/shaders/vertex.glsl.includable) make_includable(assets/images/atlas.ppm assets/generated/images/atlas.ppm.includable)