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 8 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"]
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"
}
]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"files.associations": {
"*.cl": "cuda-cpp",
"*.sl": "latex",
"vector": "cpp",
"__split_buffer": "cpp",
"deque": "cpp",
"list": "cpp",
"__config": "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)
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
240 changes: 163 additions & 77 deletions Engine/CMakeLists.txt
Original file line number Diff line number Diff line change
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/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/Windows/WindowsInput.cpp"
"src/Platform/Windows/WindowsWindow.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)
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,175 @@ 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)

FetchContent_Declare(
lia
GIT_REPOSITORY "https://github.com/denyskryvytskyi/lia.git"
GIT_TAG "main"
)
FetchContent_MakeAvailable(lia)

FetchContent_Declare(
spdlog
GIT_REPOSITORY "https://github.com/gabime/spdlog.git"
GIT_TAG "v1.14.1"
)
FetchContent_MakeAvailable(spdlog)

FetchContent_Declare(json URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz")
FetchContent_MakeAvailable(json)

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)
FetchContent_MakeAvailable(freetype)

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

# zlib must be built before assimp
FetchContent_Declare(
zlib
GIT_REPOSITORY "https://github.com/madler/zlib.git"
GIT_TAG "v1.3.1"
)
FetchContent_MakeAvailable(zlib)
# ----

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

# Manually tell assimp where to find zlib
set(ZLIB_FOUND ON)
set(ZLIB_INCLUDE_DIR ${zlib_SOURCE_DIR} CACHE PATH "zlib include directory" FORCE)
set(ZLIB_LIBRARIES zlibstatic CACHE STRING "zlib list of libraries to link" FORCE)
set(ZLIB_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)

set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(ASSIMP_INJECT_DEBUG_POSTFIX 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 OFF CACHE BOOL "" FORCE)
set(ASSIMP_INJECT_DEBUG_POSTFIX ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(assimp)


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)


if (MODULE_EDITOR_ENABLED)
set(ENGINE_INCLUDE_DIRS
${ENGINE_INCLUDE_DIRS}
${VENDOR_PATH}/imgui/include
set(IMGUI_DIR ${imgui_SOURCE_DIR})

set(IMGUI_PUBLIC_HEADERS
${IMGUI_DIR}/imconfig.h
${IMGUI_DIR}/imgui.h
${IMGUI_DIR}/imgui_internal.h # not actually public, but users might need it
${IMGUI_DIR}/imstb_rectpack.h
${IMGUI_DIR}/imstb_textedit.h
${IMGUI_DIR}/imstb_truetype.h
${IMGUI_DIR}/misc/cpp/imgui_stdlib.h
${IMGUI_DIR}/backends/imgui_impl_opengl3.h
${IMGUI_DIR}/backends/imgui_impl_glfw.h
)
endif()

if (MODULE_SOUND_ENABLED)
set(ENGINE_INCLUDE_DIRS
${ENGINE_INCLUDE_DIRS}
${VENDOR_PATH}/irrklang/include
set(IMGUI_SOURCES
${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
)
endif()

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
target_include_directories(${LIBRARY_NAME}
PUBLIC ${IMGUI_DIR} ${IMGUI_DIR}/backends
)

target_sources(${LIBRARY_NAME} PRIVATE ${IMGUI_SOURCES})
endif()

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}
)

if (MODULE_EDITOR_ENABLED)
find_library(imgui_d NAMES imgui imguid PATHS ${VENDOR_PATH_DEBUG})
find_library(imgui NAMES imgui PATHS ${VENDOR_PATH_RELEASE})
target_include_directories(${LIBRARY_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
)

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

)
if (MODULE_SOUND_ENABLED)
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()

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

set(VENDOR
${VENDOR}
debug ${irrklang} optimized ${irrklang}
)
endif()
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)

target_include_directories(${LIBRARY_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)

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} zlib 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()
# endif
# define EL_ASSERTIONS_ENABLED
#else
Expand Down
Loading