Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of MacOS #36

Draft
wants to merge 16 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 0 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +0,0 @@
[submodule "Engine/vendor/GLFW"]
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved
path = Engine/vendor/GLFW
url = https://github.com/glfw/glfw
[submodule "Engine/vendor/spdlog"]
path = Engine/vendor/spdlog
url = https://github.com/gabime/spdlog
[submodule "Engine/vendor/lia"]
path = Engine/vendor/lia
url = https://github.com/denyskryvytskyi/lia
[submodule "Engine/vendor/assimp"]
path = Engine/vendor/assimp
url = https://github.com/assimp/assimp
22 changes: 22 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/Engine/src/**",
"${workspaceFolder}/build/_deps/json-src/include"
],
"defines": [],
"macFrameworkPath": [
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-clang-arm64",
"forcedInclude": ["${workspaceFolder}/Engine/src/elpch.h"]
}
],
"version": 4
}
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C++ Debug",
"cwd": "${workspaceFolder}/build/Sandbox3D",
"type": "lldb",
"request": "launch",
"breakpointMode": "file",
"program": "${workspaceFolder}/build/Sandbox3D/Sandbox3D"
}
]
}
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"files.associations": {
"*.cl": "cuda-cpp",
"*.sl": "latex",
"vector": "cpp",
"__split_buffer": "cpp",
"deque": "cpp",
"list": "cpp",
"__config": "cpp",
"ios": "cpp"
}
}
12 changes: 9 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved
cmake_minimum_required(VERSION 3.11)

project(ElvenEngine
VERSION 1.0
Expand All @@ -10,6 +10,9 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

include(FetchContent)
set(FETCHCONTENT_QUIET OFF)

option(BUILD_SANDBOX "build sandbox projects" ON)
option(BUILD_GAMES "build games" ON)
option(PROFILE_MODE "Enable functions profiling" ON)
Expand All @@ -23,7 +26,11 @@ if(WIN32)
NOMINMAX
)
else()
message("This is not supported platform for now!")
if (APPLE)
# something
else()
message("This is not supported platform for now!")
endif()
endif()

if (PROFILE_MODE)
Expand All @@ -46,7 +53,6 @@ add_subdirectory(Engine)

set(ElvenEngine_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})


if (BUILD_SANDBOX)
if (MODULE_3D_ENABLED)
add_subdirectory(Sandbox3D)
Expand Down
226 changes: 145 additions & 81 deletions Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ set(ENGINE_HEADERS
"src/Renderer/Mesh.h"
"src/Renderer/RenderTopology.h"
"src/Renderer/PostProcessor.h"
"src/Platform/Windows/WindowsWindow.h"
"src/Platform/GLFW/GLFWWindowImpl.h"
"src/Platform/OpenGL/OpenGLBuffer.h"
"src/Platform/OpenGL/OpenGLContext.h"
"src/Platform/OpenGL/OpenGLRendererAPI.h"
Expand Down Expand Up @@ -104,6 +104,7 @@ set(ENGINE_SOURCES
"src/Renderer/RHI/Shader.cpp"
"src/Renderer/RHI/VertexArray.cpp"
"src/Renderer/RHI/RenderTarget.cpp"
"src/Renderer/RHI/Texture.cpp"
"src/Renderer/Camera.cpp"
"src/Renderer/CameraController.cpp"
"src/Renderer/OrthographicCameraController.cpp"
Expand All @@ -121,8 +122,15 @@ set(ENGINE_SOURCES
"src/Platform/OpenGL/OpenGLVertexArray.cpp"
"src/Platform/OpenGL/OpenGLTexture.cpp"
"src/Platform/OpenGL/OpenGLRenderTarget.cpp"
"src/Platform/Windows/WindowsInput.cpp"
"src/Platform/Windows/WindowsWindow.cpp"
"src/Platform/OpenGL41/OpenGL41Buffer.cpp"
"src/Platform/OpenGL41/OpenGL41Context.cpp"
"src/Platform/OpenGL41/OpenGL41RendererAPI.cpp"
"src/Platform/OpenGL41/OpenGL41VertexArray.cpp"
"src/Platform/OpenGL41/OpenGL41Texture.cpp"
"src/Platform/OpenGL41/OpenGL41RenderTarget.cpp"
"src/Platform/GLFW/GLFWInputImpl.cpp"
"src/Platform/GLFW/GLFWWindowImpl.cpp"
"src/Platform/OpenGLCommon.cpp"
"src/Scene/Behavior.cpp"
"src/Scene/Component.cpp"
"src/Scene/ComponentSystem.cpp"
Expand Down Expand Up @@ -163,6 +171,11 @@ endif()
set(LIBRARY_NAME ElvenEngine)
add_library(${LIBRARY_NAME} STATIC ${ENGINE_SOURCES})

target_compile_features(${LIBRARY_NAME} PRIVATE cxx_std_20)
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_CXX_STANDARD 20 CACHE STRING "v")
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${ENGINE_SOURCES})

# path to dependencies
Expand All @@ -171,102 +184,153 @@ set(VENDOR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/vendor)
# include dirs
set(ENGINE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)

set(ENGINE_INCLUDE_DIRS
${ENGINE_SOURCE_DIR}
${VENDOR_PATH}/GLAD/include
${VENDOR_PATH}/GLFW/include
${VENDOR_PATH}/lia/include
${VENDOR_PATH}/spdlog/include
${VENDOR_PATH}/stb/include
${VENDOR_PATH}/json/include
${VENDOR_PATH}/freetype/include
${VENDOR_PATH}/fmt/include
# ------------------
# Dependencies
# ------------------
FetchContent_Declare(
glfw
GIT_REPOSITORY "https://github.com/glfw/glfw.git"
GIT_TAG "3.4"
)
FetchContent_MakeAvailable(glfw)
set_target_properties(glfw PROPERTIES FOLDER "Libs")

if (MODULE_EDITOR_ENABLED)
set(ENGINE_INCLUDE_DIRS
${ENGINE_INCLUDE_DIRS}
${VENDOR_PATH}/imgui/include
)
endif()
FetchContent_Declare(
lia
GIT_REPOSITORY "https://github.com/denyskryvytskyi/lia.git"
GIT_TAG "main"
)
FetchContent_MakeAvailable(lia)
set_target_properties(lia PROPERTIES FOLDER "Libs")

if (MODULE_SOUND_ENABLED)
set(ENGINE_INCLUDE_DIRS
${ENGINE_INCLUDE_DIRS}
${VENDOR_PATH}/irrklang/include
)
endif()
FetchContent_Declare(
spdlog
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
GIT_TAG "v1.14.1"
)
FetchContent_MakeAvailable(spdlog)
set_target_properties(spdlog PROPERTIES FOLDER "Libs")

if (MODULE_3D_ENABLED)
set(ENGINE_INCLUDE_DIRS
${ENGINE_INCLUDE_DIRS}
${VENDOR_PATH}/assimp/include
${PROJECT_SOURCE_DIR}/build_vendor/assimp/include # include generated config.h for assimp
)
endif()
FetchContent_Declare(json URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz")
FetchContent_MakeAvailable(json)
set_target_properties(nlohmann_json PROPERTIES FOLDER "Libs")

FetchContent_Declare(
freetype
GIT_REPOSITORY "https://github.com/freetype/freetype.git"
GIT_TAG "VER-2-13-2"
)

set(FT_DISABLE_ZLIB ON CACHE BOOL "" FORCE)
set(FT_DISABLE_BZIP2 ON CACHE BOOL "" FORCE)
set(FT_DISABLE_PNG ON CACHE BOOL "" FORCE)
set(FT_DISABLE_HARFBUZZ ON CACHE BOOL "" FORCE)
set(FT_DISABLE_BROTLI ON CACHE BOOL "" FORCE)
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved
FetchContent_MakeAvailable(freetype)
set_target_properties(freetype PROPERTIES FOLDER "Libs")

FetchContent_Declare(
fmt
GIT_REPOSITORY "https://github.com/fmtlib/fmt.git"
GIT_TAG "10.2.1"
)
FetchContent_MakeAvailable(fmt)
set_target_properties(fmt PROPERTIES FOLDER "Libs")

FetchContent_Declare(
assimp
GIT_REPOSITORY "https://github.com/assimp/assimp.git"
GIT_TAG "v5.3.1"
)

# Manually tell assimp where to find zlib
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_ZLIB ON CACHE BOOL "" FORCE)
set(ASSIMP_INJECT_DEBUG_POSTFIX ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(assimp)
set_target_properties(assimp PROPERTIES FOLDER "Libs")

target_include_directories(${LIBRARY_NAME} PUBLIC ${ENGINE_INCLUDE_DIRS})

set(VENDOR_PATH_DEBUG ${PROJECT_SOURCE_DIR}/build_vendor/lib/Debug/)
set(VENDOR_PATH_RELEASE ${PROJECT_SOURCE_DIR}/build_vendor/lib/Release/)

find_library(glfw_d NAMES glfw3 PATHS ${VENDOR_PATH_DEBUG})
find_library(glad_d NAMES glad PATHS ${VENDOR_PATH_DEBUG})
find_library(spdlog_d NAMES spdlogd PATHS ${VENDOR_PATH_DEBUG})
find_library(stb_d NAMES stb PATHS ${VENDOR_PATH_DEBUG})
find_library(freetype_d NAMES freetyped PATHS ${VENDOR_PATH_DEBUG})
find_library(fmt_d NAMES fmtd PATHS ${VENDOR_PATH_DEBUG})
find_library(glad NAMES glad PATHS ${VENDOR_PATH_RELEASE})
find_library(glfw NAMES glfw3 PATHS ${VENDOR_PATH_RELEASE})
find_library(spdlog NAMES spdlog PATHS ${VENDOR_PATH_RELEASE})
find_library(stb NAMES stb PATHS ${VENDOR_PATH_RELEASE})
find_library(freetype NAMES freetype PATHS ${VENDOR_PATH_RELEASE})
find_library(fmt NAMES fmt PATHS ${VENDOR_PATH_RELEASE})

set(VENDOR
debug ${glfw_d} optimized ${glfw}
debug ${glad_d} optimized ${glad}
debug ${spdlog_d} optimized ${spdlog}
debug ${stb_d} optimized ${stb}
debug ${freetype_d} optimized ${freetype}
debug ${fmt_d} optimized ${fmt}
FetchContent_Declare(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui
GIT_TAG "docking"
)

FetchContent_MakeAvailable(imgui)

set(IRRKLANG_INSTALL_DIR ${CMAKE_BINARY_DIR}/_deps/irrklang)

FetchContent_Declare(
irrklang
URL "http://www.ambiera.at/downloads/irrKlang-64bit-1.5.0.zip"
SOURCE_DIR ${IRRKLANG_INSTALL_DIR}
)

FetchContent_GetProperties(irrklang)

if(NOT irrklang_POPULATED)
FetchContent_Populate(irrklang)
set(IRRKLANG_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(IRRKLANG_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(IRRKLANG_BUILD_TESTS OFF CACHE BOOL "" FORCE)
endif()

add_subdirectory(${VENDOR_PATH}/GLAD)
add_subdirectory(${VENDOR_PATH}/stb)
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved


if (MODULE_EDITOR_ENABLED)
find_library(imgui_d NAMES imgui imguid PATHS ${VENDOR_PATH_DEBUG})
find_library(imgui NAMES imgui PATHS ${VENDOR_PATH_RELEASE})
set(IMGUI_DIR ${imgui_SOURCE_DIR})

set(VENDOR
${VENDOR}
debug ${imgui_d} optimized ${imgui}

set(IMGUI_SOURCES
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/misc/cpp/imgui_stdlib.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/imgui_demo.cpp
)
add_library(imgui STATIC ${IMGUI_SOURCES})

target_include_directories(imgui
PUBLIC ${IMGUI_DIR} ${IMGUI_DIR}/backends
)

target_link_libraries(imgui glfw)
target_link_libraries(${LIBRARY_NAME} imgui)
set_target_properties(imgui PROPERTIES FOLDER "Libs")
endif()

if (MODULE_SOUND_ENABLED)
find_library(irrklang NAMES irrKlang.lib PATHS ${VENDOR_PATH}/irrklang/lib)

set(VENDOR
${VENDOR}
debug ${irrklang} optimized ${irrklang}
)
if (APPLE)
messsage(FATAL_ERROR "Sound module is not yet supported on MacOS. Please disable this option for now")
else()
target_include_directories(${LIBRARY_NAME} PUBLIC ${irrklang_SOURCE_DIR}/include)
# irrklang is marked here STATIC to avoid IMPORTED_IMPLIB not found error on Windows
# the dlls are copied manually in the post build step
add_library(irrklang STATIC IMPORTED)
set_target_properties(irrklang PROPERTIES IMPORTED_LOCATION "${IRRKLANG_INSTALL_DIR}/lib/Winx64-visualStudio/irrKlang.lib")
target_link_libraries(${LIBRARY_NAME} irrklang)
endif()
endif()


target_include_directories(${LIBRARY_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(${LIBRARY_NAME} glfw spdlog freetype fmt glad stb)
target_link_libraries(${LIBRARY_NAME} nlohmann_json::nlohmann_json)
target_include_directories(${LIBRARY_NAME} PUBLIC ${lia_SOURCE_DIR}/include)

if (MODULE_3D_ENABLED)
find_library(assimp_d NAMES assimp-vc143-mtd PATHS ${VENDOR_PATH_DEBUG})
find_library(zlib_d NAMES zlibstaticd PATHS ${VENDOR_PATH_DEBUG})
find_library(assimp NAMES assimp-vc143-mt PATHS ${VENDOR_PATH_RELEASE})
find_library(zlib NAMES zlibstatic PATHS ${VENDOR_PATH_RELEASE})

set(VENDOR
${VENDOR}
debug ${assimp_d} optimized ${assimp}
debug ${zlib_d} optimized ${zlib}
)
target_link_libraries(${LIBRARY_NAME} assimp)
endif()

target_link_libraries(${LIBRARY_NAME} ${VENDOR})

# pch header file path
set(ENGINE_PRECOMPILED_HEADERS
${ENGINE_SOURCE_DIR}/elpch.h
Expand Down
2 changes: 1 addition & 1 deletion Engine/src/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# include <signal.h>
# define EL_DEBUGBREAK() raise(SIGTRAP)
# else
# error "Platform doesn't support debugbreak yet!"
# define EL_DEBUGBREAK() __builtin_trap()
denyskryvytskyi marked this conversation as resolved.
Show resolved Hide resolved
# endif
# define EL_ASSERTIONS_ENABLED
#else
Expand Down
Loading