Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ bits/
cmake-build-*/
bin/
build/
graph/

CMakeUserPresets.json
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "engine/native/thirdparty/bgfx.cmake"]
path = engine/native/thirdparty/bgfx.cmake
url = https://github.com/bkaradzic/bgfx.cmake
Comment thread
This conversation was marked as resolved.
Outdated
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,25 @@ elseif (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0")
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
endif()

project(DraconicEngine LANGUAGES C CXX)
find_package(Git QUIET)

if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
message(STATUS "Updating submodules...")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT
)

if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "Failed to update submodules. Please run manually.")
endif()
endif()

project(DraconicEngine LANGUAGES C CXX)
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
Comment thread
This conversation was marked as resolved.
Outdated
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Comment thread
This conversation was marked as resolved.
Outdated
set(CMAKE_CXX_MODULE_STD ON)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

include(CTest)
Expand Down
6 changes: 6 additions & 0 deletions cmake/Compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ else()
add_compile_definitions(DEBUG)
endif()

# Force Clang to use libc++
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-stdlib=libc++)
add_link_options(-stdlib=libc++)
endif()
Comment thread
coderabbitai[bot] marked this conversation as resolved.

if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64")
# TODO: Make SIMD level configurable or detect at runtime
Expand Down
11 changes: 11 additions & 0 deletions cmake/Modules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ set(NATIVE_THIRD_PARTY_DIR "${NATIVE_SOURCE_DIR}/thirdparty")
if (BUILD_TESTING)
message(STATUS "Bootstrapping unit tests module boost.ut")
add_library(boost_ut_main "${NATIVE_THIRD_PARTY_DIR}/boost/ut_main.cpp")
set_target_properties(boost_ut_main PROPERTIES
CXX_SCAN_FOR_MODULES ON
CXX_EXTENSIONS OFF
Comment thread
This conversation was marked as resolved.
)
target_sources(boost_ut_main
PUBLIC
FILE_SET CXX_MODULES
Expand Down Expand Up @@ -52,6 +56,12 @@ function(add_modules_library)
message(STATUS "Adding static modules library ${LIB_TARGET}")
add_library(${LIB_TARGET} STATIC)
endif()

set_target_properties(${LIB_TARGET} PROPERTIES
CXX_SCAN_FOR_MODULES ON
CXX_EXTENSIONS OFF
)

target_compile_features(${LIB_TARGET} PUBLIC cxx_std_23)
target_include_directories(${LIB_TARGET} PUBLIC ${NATIVE_SOURCE_DIR})

Expand All @@ -73,6 +83,7 @@ function(add_modules_library)
string(PREPEND UNIT_TEST_TARGET "${LIB_TARGET}_")
endif()
add_executable(${UNIT_TEST_TARGET} ${UNIT_TEST_FILE})
set_target_properties(${UNIT_TEST_TARGET} PROPERTIES CXX_SCAN_FOR_MODULES ON)
target_compile_features(${UNIT_TEST_TARGET} PUBLIC cxx_std_23)
target_link_libraries(${UNIT_TEST_TARGET} PRIVATE boost_ut_main ${LIB_TARGET})
message(STATUS "Unit test ${UNIT_TEST_TARGET}")
Expand Down
3 changes: 3 additions & 0 deletions engine/native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include(Compiler)

add_subdirectory(thirdparty)
Comment thread
This conversation was marked as resolved.

include(Modules)

add_modules_library(core SHARED)
Expand Down
17 changes: 17 additions & 0 deletions engine/native/thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(BGFX_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BGFX_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
set(BGFX_INSTALL OFF CACHE BOOL "" FORCE)
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)

add_subdirectory(bgfx.cmake)

# Prevent module scanning for bgfx & it's deps
set_target_properties(bgfx PROPERTIES CXX_SCAN_FOR_MODULES OFF)

if(TARGET bx)
set_target_properties(bx PROPERTIES CXX_SCAN_FOR_MODULES OFF)
endif()

if(TARGET bimg)
set_target_properties(bimg PROPERTIES CXX_SCAN_FOR_MODULES OFF)
endif()
1 change: 1 addition & 0 deletions engine/native/thirdparty/bgfx.cmake
Submodule bgfx.cmake added at 668550