Skip to content

Commit

Permalink
code refine
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingstom committed Oct 25, 2023
1 parent 63299f3 commit 63226b7
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 753 deletions.
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ cmake_minimum_required(VERSION 3.24)

project(Aphrodite)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/")
set(APH_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin)
set(APH_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(APH_EXAMPLES_DIR ${APH_ROOT_DIR}/examples)
set(APH_ENGINE_DIR ${APH_ROOT_DIR}/engine)
set(APH_EXTERNAL_DIR ${APH_ROOT_DIR}/external)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${APH_ROOT_DIR}/cmake")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${APH_OUTPUT_DIR}")

include(AphCompilerOptions)
include(AphExternal)

add_subdirectory(engine)
add_subdirectory(examples)

find_package(PkgConfig REQUIRED)
pkg_check_modules(xcb REQUIRED IMPORTED_TARGET xcb)
24 changes: 13 additions & 11 deletions cmake/AphExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,27 @@ set(SHADERC_SKIP_INSTALL ON CACHE BOOL "" FORCE)
set(SHADERC_SKIP_TESTS ON CACHE BOOL "" FORCE)
set(SHADERC_SKIP_EXAMPLES ON CACHE BOOL "" FORCE)
set(SHADERC_SKIP_COPYRIGHT_CHECK ON CACHE BOOL "" FORCE)
set(SHADERC_THIRD_PARTY_ROOT_DIR "${CMAKE_SOURCE_DIR}/external" CACHE STRING "Third party path." FORCE)
set(SHADERC_THIRD_PARTY_ROOT_DIR "${APH_EXTERNAL_DIR}" CACHE STRING "Third party path." FORCE)

# mimalloc
set(MI_BUILD_SHARED OFF CACHE BOOL "" FORCE)
set(MI_BUILD_OBJECT OFF CACHE BOOL "" FORCE)
set(MI_BUILD_STATIC ON CACHE BOOL "" FORCE)

# glfw
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
# glfw set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)


add_subdirectory(external)
add_subdirectory(external/mimalloc EXCLUDE_FROM_ALL)
add_subdirectory(external/glfw EXCLUDE_FROM_ALL)
add_subdirectory(external/reckless EXCLUDE_FROM_ALL)
add_subdirectory(external/volk EXCLUDE_FROM_ALL)
add_subdirectory(external/spirv-cross EXCLUDE_FROM_ALL)
add_subdirectory(external/shaderc EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR})
add_subdirectory(${APH_EXTERNAL_DIR}/mimalloc EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR}/glfw EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR}/reckless EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR}/volk EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR}/spirv-cross EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR}/shaderc EXCLUDE_FROM_ALL)
add_subdirectory(${APH_EXTERNAL_DIR}/imgui EXCLUDE_FROM_ALL)
# add_subdirectory(external/mmgr EXCLUDE_FROM_ALL)

find_package(PkgConfig REQUIRED)
pkg_check_modules(xcb REQUIRED IMPORTED_TARGET xcb)
43 changes: 16 additions & 27 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
message("source dir ${CMAKE_SOURCE_DIR}")
file(GLOB base_src
common/*.cpp
input/*.cpp
Expand All @@ -18,38 +17,28 @@ file(GLOB base_src

)

add_library(imgui SHARED
${CMAKE_SOURCE_DIR}/external/imgui/imgui.cpp
${CMAKE_SOURCE_DIR}/external/imgui/imgui_demo.cpp
${CMAKE_SOURCE_DIR}/external/imgui/imgui_draw.cpp
${CMAKE_SOURCE_DIR}/external/imgui/imgui_tables.cpp
${CMAKE_SOURCE_DIR}/external/imgui/imgui_widgets.cpp
${CMAKE_SOURCE_DIR}/external/imgui/imgui_impl_glfw.cpp
${CMAKE_SOURCE_DIR}/external/imgui/imgui_impl_vulkan.cpp
)

add_library(engine STATIC ${base_src})
aph_compiler_options(engine)

target_include_directories(engine SYSTEM PUBLIC
../external/glm
../external/reckless/reckless/include
../external/tinyimageformat
../external/volk
${APH_EXTERNAL_DIR}/glm
${APH_EXTERNAL_DIR}/reckless/reckless/include
${APH_EXTERNAL_DIR}/tinyimageformat
${APH_EXTERNAL_DIR}/volk

PRIVATE
./
../external/backward-cpp/include
../external/mmgr
../external/glfw/include
../external/shaderc/libshaderc/include
../external/imgui
../external/vulkan
../external/stb/include
../external/tinygltf/include
../external/spirv-cross
../external/tinyktx
../external/tinydds
${APH_ENGINE_DIR}
${APH_EXTERNAL_DIR}/backward-cpp/include
${APH_EXTERNAL_DIR}/mmgr
${APH_EXTERNAL_DIR}/glfw/include
${APH_EXTERNAL_DIR}/shaderc/libshaderc/include
${APH_EXTERNAL_DIR}/imgui
${APH_EXTERNAL_DIR}/vulkan
${APH_EXTERNAL_DIR}/stb/include
${APH_EXTERNAL_DIR}/tinygltf/include
${APH_EXTERNAL_DIR}/spirv-cross
${APH_EXTERNAL_DIR}/tinyktx
${APH_EXTERNAL_DIR}/tinydds
)

target_link_libraries(engine PRIVATE
Expand Down
30 changes: 0 additions & 30 deletions external/imgui/.gitattributes

This file was deleted.

1 change: 0 additions & 1 deletion external/imgui/.github/FUNDING.yml

This file was deleted.

46 changes: 0 additions & 46 deletions external/imgui/.github/issue_template.md

This file was deleted.

6 changes: 0 additions & 6 deletions external/imgui/.github/pull_request_template.md

This file was deleted.

Loading

0 comments on commit 63226b7

Please sign in to comment.