Skip to content

Commit 2f2da32

Browse files
committed
Apply suggestions
1 parent b5997bf commit 2f2da32

52 files changed

Lines changed: 3372 additions & 20 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitmodules

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
[submodule "engine/native/thirdparty/bgfx.cmake"]
2-
path = engine/native/thirdparty/bgfx.cmake
3-
url = https://github.com/bkaradzic/bgfx.cmake
1+
[submodule "engine/native/thirdparty/bx"]
2+
path = engine/native/thirdparty/bx
3+
url = https://github.com/bkaradzic/bx
4+
[submodule "engine/native/thirdparty/bimg"]
5+
path = engine/native/thirdparty/bimg
6+
url = https://github.com/bkaradzic/bimg
7+
[submodule "engine/native/thirdparty/bgfx"]
8+
path = engine/native/thirdparty/bgfx
9+
url = https://github.com/bkaradzic/bgfx

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
2424
endif()
2525

2626
project(DraconicEngine LANGUAGES C CXX)
27-
set(CMAKE_CXX_SCAN_FOR_MODULES ON)
28-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
27+
28+
# Only have safe global rules here
29+
set(CMAKE_CXX_STANDARD 23)
30+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2931
set(CMAKE_CXX_MODULE_STD ON)
32+
3033
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
3134

3235
include(CTest)

cmake/Modules.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ function(add_modules_library)
9393

9494
endfunction()
9595

96+
function(enable_modules target)
97+
set_target_properties(
98+
${target} PROPERTIES
99+
CXX_SCAN_FOR_MODULES ON
100+
)
101+
endfunction()
102+
96103
function(target_link_modules)
97104
cmake_parse_arguments(
98105
MOD_LINK # prefix for all variables

engine/native/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
include(Compiler)
2+
include(Modules)
23

34
add_subdirectory(thirdparty)
45

5-
include(Modules)
6-
76
add_modules_library(core SHARED)
87
target_link_libraries(core PUBLIC definitions math)

engine/native/thirdparty/CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ set(BGFX_BUILD_TOOLS OFF CACHE BOOL "" FORCE)
33
set(BGFX_INSTALL OFF CACHE BOOL "" FORCE)
44
set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
55

6-
add_subdirectory(bgfx.cmake)
7-
8-
# Prevent module scanning for bgfx & it's deps
9-
set_target_properties(bgfx PROPERTIES CXX_SCAN_FOR_MODULES OFF)
10-
11-
if(TARGET bx)
12-
set_target_properties(bx PROPERTIES CXX_SCAN_FOR_MODULES OFF)
13-
endif()
14-
15-
if(TARGET bimg)
16-
set_target_properties(bimg PROPERTIES CXX_SCAN_FOR_MODULES OFF)
17-
endif()
6+
set(BX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bx CACHE STRING "" FORCE)
7+
set(BIMG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bimg CACHE STRING "" FORCE)
8+
set(BGFX_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bgfx CACHE STRING "" FORCE)
9+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx bx-build)
10+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg bimg-build)
11+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx bgfx-build)
12+
13+
target_link_libraries(bgfx PUBLIC bx bimg)

engine/native/thirdparty/bgfx

Submodule bgfx added at 8532b2c
Lines changed: 0 additions & 1 deletion
This file was deleted.

engine/native/thirdparty/bimg

Submodule bimg added at 9114b47

engine/native/thirdparty/bx

Submodule bx added at cac72f6
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@PACKAGE_INIT@
2+
3+
if(@BGFX_CMAKE_USER_SCRIPT_PRESENT@)
4+
include("${CMAKE_CURRENT_LIST_DIR}/@BGFX_CMAKE_USER_SCRIPT_INSTALL_NAME@")
5+
endif()
6+
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
7+
get_target_property(BGFX_INCLUDE_PATH bgfx::bgfx INTERFACE_INCLUDE_DIRECTORIES)
8+
list(GET BGFX_INCLUDE_PATH 0 BGFX_INCLUDE_PATH_1) # bgfx::bgfx exports include directory twice?
9+
set(BGFX_SHADER_INCLUDE_PATH ${BGFX_INCLUDE_PATH_1}/bgfx)
10+
11+
# If cross compiling, we need a host-compatible version of shaderc to compile shaders
12+
macro(_bgfx_crosscompile_use_host_tool TOOL_NAME)
13+
if(NOT TARGET bgfx::${TOOL_NAME})
14+
find_program(
15+
${TOOL_NAME}_EXECUTABLE
16+
NAMES bgfx-${TOOL_NAME} ${TOOL_NAME}
17+
PATHS @BGFX_ADDITIONAL_TOOL_PATHS@ /usr/bin
18+
)
19+
add_executable(bgfx::${TOOL_NAME} IMPORTED)
20+
set_target_properties(bgfx::${TOOL_NAME} PROPERTIES IMPORTED_LOCATION "${${TOOL_NAME}_EXECUTABLE}")
21+
endif()
22+
endmacro()
23+
24+
_bgfx_crosscompile_use_host_tool(bin2c)
25+
_bgfx_crosscompile_use_host_tool(texturec)
26+
_bgfx_crosscompile_use_host_tool(shaderc)
27+
_bgfx_crosscompile_use_host_tool(texturev)
28+
_bgfx_crosscompile_use_host_tool(geometryv)
29+
30+
include("${CMAKE_CURRENT_LIST_DIR}/bgfxToolUtils.cmake")
31+
check_required_components("@PROJECT_NAME@")

0 commit comments

Comments
 (0)