-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We introduced 2 custom CMake options: - `VOLT_USE_SIMD` :: Enable SIMD math - `VOLT_USE_AVX2` :: Enable AVX2 instruction set
- Loading branch information
1 parent
f0f5ebf
commit 0caefa8
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function (volt_set_options) | ||
option(VOLT_USE_SIMD "Enable SIMD math" ON) | ||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64") | ||
cmake_dependent_option(VOLT_USE_AVX2 "Enable AVX2 instruction set" ON "VOLT_USE_SIMD" OFF) | ||
endif() | ||
|
||
# Check VOLT_USE_SIMD value is valid | ||
if (NOT VOLT_USE_SIMD STREQUAL "ON" AND NOT VOLT_USE_SIMD STREQUAL "OFF") | ||
message(WARNING "VOLT_USE_SIMD is set to an invalid value (${VOLT_USE_SIMD}), defaulting to ON") | ||
set(VOLT_USE_SIMD ON CACHE STRING "Enable SIMD math" FORCE) | ||
endif() | ||
|
||
# Check VOLT_USE_AVX2 value is valid | ||
if (NOT VOLT_USE_AVX2 STREQUAL "ON" AND NOT VOLT_USE_AVX2 STREQUAL "OFF") | ||
message(WARNING "VOLT_USE_AVX2 is set to an invalid value (${VOLT_USE_AVX2}), defaulting to ON") | ||
set(VOLT_USE_AVX2 ON CACHE STRING "Enable AVX2 instruction set" FORCE) | ||
endif() | ||
|
||
message(STATUS "Use SIMD: ${VOLT_USE_SIMD}") | ||
message(STATUS "Use AVX2: ${VOLT_USE_AVX2}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,40 @@ | ||
file(GLOB IMGUI_SRCS CONFIGURE_DEPENDS "imgui/*.cpp") | ||
file(GLOB BOX2D_SRCS CONFIGURE_DEPENDS "box2d/src/*.c") | ||
file(GLOB RAYLIB_SRCS CONFIGURE_DEPENDS "raylib/src/*.c") | ||
file(GLOB IMGUIZMO_SRCS CONFIGURE_DEPENDS "imguizmo/*.cpp") | ||
file(GLOB_RECURSE YAML_CPP_SRCS CONFIGURE_DEPENDS "yaml-cpp/src/*.cpp") | ||
file(GLOB IMGUI_IMPL_RAYLIB_SRCS CONFIGURE_DEPENDS "imgui_impl_raylib/*.cpp") | ||
|
||
add_library(imgui OBJECT ${IMGUI_SRCS}) | ||
add_library(box2d OBJECT ${BOX2D_SRCS}) | ||
add_library(raylib OBJECT ${RAYLIB_SRCS}) | ||
add_library(imguizmo OBJECT ${IMGUIZMO_SRCS}) | ||
add_library(yaml_cpp OBJECT ${YAML_CPP_SRCS}) | ||
add_library(imgui_impl_raylib OBJECT ${IMGUI_IMPL_RAYLIB_SRCS}) | ||
|
||
target_compile_definitions(raylib PRIVATE PLATFORM_DESKTOP) | ||
target_compile_definitions(yaml_cpp PRIVATE YAML_CPP_STATIC_DEFINE) | ||
if (VOLT_USE_SIMD) | ||
target_compile_definitions(box2d PRIVATE BOX2D_ENABLE_SIMD) | ||
endif() | ||
|
||
target_include_directories(imguizmo SYSTEM PUBLIC imgui) | ||
target_include_directories(box2d SYSTEM PUBLIC box2d/include) | ||
target_include_directories(imgui_impl_raylib SYSTEM PUBLIC imgui) | ||
target_include_directories(box2d SYSTEM PUBLIC box2d/extern/simde) | ||
target_include_directories(yaml_cpp SYSTEM PUBLIC yaml-cpp/include) | ||
target_include_directories(imgui_impl_raylib SYSTEM PUBLIC raylib/src) | ||
target_include_directories(raylib SYSTEM PUBLIC raylib/src/external/glfw/include) | ||
|
||
target_compile_options(raylib PRIVATE "-w") | ||
target_compile_options(box2d PRIVATE "-ffp-contract=off") | ||
target_compile_options(raylib PRIVATE "-Wno-implicit-function-declaration") | ||
|
||
if (VOLT_USE_AVX2) | ||
target_compile_definitions(box2d PRIVATE BOX2D_AVX2) | ||
if (MSVC) | ||
target_compile_options(box2d PRIVATE "/arch:AVX2") | ||
else() | ||
target_compile_options(box2d PRIVATE "-mavx2") | ||
endif() | ||
endif() |