@bloomengine/engine 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/native/third_party/JoltPhysics/Build/Android/PerformanceTest/build.gradle +51 -0
- package/native/third_party/JoltPhysics/Build/Android/PerformanceTest/src/main/AndroidManifest.xml +20 -0
- package/native/third_party/JoltPhysics/Build/Android/PerformanceTest/src/main/cpp/CMakeLists.txt +20 -0
- package/native/third_party/JoltPhysics/Build/Android/UnitTests/build.gradle +51 -0
- package/native/third_party/JoltPhysics/Build/Android/UnitTests/src/main/AndroidManifest.xml +20 -0
- package/native/third_party/JoltPhysics/Build/Android/UnitTests/src/main/cpp/CMakeLists.txt +20 -0
- package/native/third_party/JoltPhysics/Build/Android/build.gradle +17 -0
- package/native/third_party/JoltPhysics/Build/Android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/native/third_party/JoltPhysics/Build/Android/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/native/third_party/JoltPhysics/Build/Android/gradle.properties +21 -0
- package/native/third_party/JoltPhysics/Build/Android/gradlew +185 -0
- package/native/third_party/JoltPhysics/Build/Android/gradlew.bat +89 -0
- package/native/third_party/JoltPhysics/Build/Android/settings.gradle +10 -0
- package/native/third_party/JoltPhysics/Build/CMakeLists.txt +449 -0
- package/native/third_party/JoltPhysics/Build/README.md +250 -0
- package/native/third_party/JoltPhysics/Build/cmake_linux_clang_gcc.sh +28 -0
- package/native/third_party/JoltPhysics/Build/cmake_linux_emscripten.sh +19 -0
- package/native/third_party/JoltPhysics/Build/cmake_linux_mingw.sh +19 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_32bit.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_arm.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_arm_32bit.bat +4 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_cross_platform_deterministic.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_double.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_cl_no_object_stream.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_clang.bat +10 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_clang_cross_platform_deterministic.bat +10 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_clang_double.bat +10 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_uwp.bat +5 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2022_uwp_arm.bat +5 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_cl.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_cl_cross_platform_deterministic.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_cl_double.bat +3 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_clang.bat +10 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_clang_cross_platform_deterministic.bat +10 -0
- package/native/third_party/JoltPhysics/Build/cmake_vs2026_clang_double.bat +10 -0
- package/native/third_party/JoltPhysics/Build/cmake_windows_mingw.sh +19 -0
- package/native/third_party/JoltPhysics/Build/cmake_xcode_ios.sh +4 -0
- package/native/third_party/JoltPhysics/Build/cmake_xcode_macos.sh +4 -0
- package/native/third_party/JoltPhysics/Build/iOS/JoltViewerInfo.plist +34 -0
- package/native/third_party/JoltPhysics/Build/iOS/SamplesInfo.plist +34 -0
- package/native/third_party/JoltPhysics/Build/iOS/UnitTestsInfo.plist +34 -0
- package/native/third_party/JoltPhysics/Build/macOS/icon.icns +0 -0
- package/native/third_party/JoltPhysics/Build/macos_install_vulkan_sdk.sh +13 -0
- package/native/third_party/JoltPhysics/Build/ubuntu24_install_vulkan_sdk.sh +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
|
|
2
|
+
|
|
3
|
+
project(JoltPhysics VERSION 5.5.0 LANGUAGES CXX)
|
|
4
|
+
|
|
5
|
+
# When turning this option on, the library will be compiled using assertions. By default asserts are enabled in Debug build.
|
|
6
|
+
option(USE_ASSERTS "Enable asserts" OFF)
|
|
7
|
+
|
|
8
|
+
# When turning this option on, the library will be compiled using doubles for positions. This allows for much bigger worlds.
|
|
9
|
+
option(DOUBLE_PRECISION "Use double precision math" OFF)
|
|
10
|
+
|
|
11
|
+
# When turning this option on, the library will be compiled with debug symbols
|
|
12
|
+
option(GENERATE_DEBUG_SYMBOLS "Generate debug symbols" ON)
|
|
13
|
+
|
|
14
|
+
# Which type of debug symbols to generate, e.g. using source-map when compiling with emscripten makes compilation a lot faster
|
|
15
|
+
set(JPH_DEBUG_SYMBOL_FORMAT "" CACHE STRING "Which type of debug symbols to generate")
|
|
16
|
+
|
|
17
|
+
# When turning this option on, the library will override the default CMAKE_CXX_FLAGS_DEBUG/RELEASE values, otherwise they will use the platform defaults
|
|
18
|
+
option(OVERRIDE_CXX_FLAGS "Override CMAKE_CXX_FLAGS_DEBUG/RELEASE" ON)
|
|
19
|
+
|
|
20
|
+
# When turning this option on, the library will be compiled in such a way to attempt to keep the simulation deterministic across platforms
|
|
21
|
+
option(CROSS_PLATFORM_DETERMINISTIC "Cross platform deterministic" OFF)
|
|
22
|
+
|
|
23
|
+
# When turning this option on, the library will be compiled for ARM using the CROSS_COMPILE_ARM_TARGET architecture, requires compiling with clang
|
|
24
|
+
option(CROSS_COMPILE_ARM "Cross compile to the CROSS_COMPILE_ARM_TARGET architecture" OFF)
|
|
25
|
+
|
|
26
|
+
# When cross compiling to ARM this specifies which target to use. Can be 'aarch64-linux-gnu' for 64-bit or 'arm-linux-gnueabihf' for 32-bit
|
|
27
|
+
set(CROSS_COMPILE_ARM_TARGET "aarch64-linux-gnu" CACHE STRING "The target to use")
|
|
28
|
+
|
|
29
|
+
# When turning this option on, Jolt will be compiled as a shared library and public symbols will be exported.
|
|
30
|
+
option(BUILD_SHARED_LIBS "Compile Jolt as a shared library" OFF)
|
|
31
|
+
|
|
32
|
+
# When turning this option on, the library will be compiled with interprocedural optimizations enabled, also known as link-time optimizations or link-time code generation.
|
|
33
|
+
# Note that if you turn this on you need to use SET_INTERPROCEDURAL_OPTIMIZATION() or set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) to enable LTO specifically for your own project as well.
|
|
34
|
+
# If you don't do this you may get an error: /usr/bin/ld: libJolt.a: error adding symbols: file format not recognized
|
|
35
|
+
option(INTERPROCEDURAL_OPTIMIZATION "Enable interprocedural optimizations" ON)
|
|
36
|
+
|
|
37
|
+
# When turning this on, in Debug and Release mode, the library will emit extra code to ensure that the 4th component of a 3-vector is kept the same as the 3rd component
|
|
38
|
+
# and will enable floating point exceptions during simulation to detect divisions by zero.
|
|
39
|
+
# Note that this currently only works using MSVC. Clang turns Float2 into a SIMD vector sometimes causing floating point exceptions (the option is ignored).
|
|
40
|
+
option(FLOATING_POINT_EXCEPTIONS_ENABLED "Enable floating point exceptions" ON)
|
|
41
|
+
|
|
42
|
+
# When turning this on, the library will be compiled with C++ exceptions enabled.
|
|
43
|
+
# This adds some overhead and Jolt doesn't use exceptions so by default it is off.
|
|
44
|
+
option(CPP_EXCEPTIONS_ENABLED "Enable C++ exceptions" OFF)
|
|
45
|
+
|
|
46
|
+
# When turning this on, the library will be compiled with C++ RTTI enabled.
|
|
47
|
+
# This adds some overhead and Jolt doesn't use RTTI so by default it is off.
|
|
48
|
+
option(CPP_RTTI_ENABLED "Enable C++ RTTI" OFF)
|
|
49
|
+
|
|
50
|
+
# Number of bits to use in ObjectLayer. Can be 16 or 32.
|
|
51
|
+
option(OBJECT_LAYER_BITS "Number of bits in ObjectLayer" 16)
|
|
52
|
+
|
|
53
|
+
# Select X86 processor features to use (if everything is off it will be SSE2 compatible)
|
|
54
|
+
option(USE_SSE4_1 "Enable SSE4.1" ON)
|
|
55
|
+
option(USE_SSE4_2 "Enable SSE4.2" ON)
|
|
56
|
+
option(USE_AVX "Enable AVX" ON)
|
|
57
|
+
option(USE_AVX2 "Enable AVX2" ON)
|
|
58
|
+
option(USE_AVX512 "Enable AVX512" OFF)
|
|
59
|
+
option(USE_LZCNT "Enable LZCNT" ON)
|
|
60
|
+
option(USE_TZCNT "Enable TZCNT" ON)
|
|
61
|
+
option(USE_F16C "Enable F16C" ON)
|
|
62
|
+
option(USE_FMADD "Enable FMADD" ON)
|
|
63
|
+
|
|
64
|
+
# Enable SIMD for the WASM build. Note that this is currently off by default since not all browsers support this.
|
|
65
|
+
# See: https://caniuse.com/?search=WebAssembly%20SIMD (Safari got support in March 2023 and was the last major browser to get support).
|
|
66
|
+
option(USE_WASM_SIMD "Enable SIMD for WASM" OFF)
|
|
67
|
+
|
|
68
|
+
# Enable 64 bit WASM instead of the default 32 bit WASM. Note that this currently requires special commandline flags in browsers and nodejs to enable.
|
|
69
|
+
# E.g. use 'node --experimental-wasm-memory64 UnitTests.js' to run the unit tests in nodejs in 64 bit.
|
|
70
|
+
option(JPH_USE_WASM64 "Enable 64 bit WASM" OFF)
|
|
71
|
+
|
|
72
|
+
# Enable all warnings
|
|
73
|
+
option(ENABLE_ALL_WARNINGS "Enable all warnings and warnings as errors" ON)
|
|
74
|
+
|
|
75
|
+
# Setting to periodically trace broadphase stats to help determine if the broadphase layer configuration is optimal
|
|
76
|
+
option(TRACK_BROADPHASE_STATS "Track Broadphase Stats" OFF)
|
|
77
|
+
|
|
78
|
+
# Setting to periodically trace narrowphase stats to help determine which collision queries could be optimized
|
|
79
|
+
option(TRACK_NARROWPHASE_STATS "Track Narrowphase Stats" OFF)
|
|
80
|
+
|
|
81
|
+
# Setting to track simulation timings per body
|
|
82
|
+
option(JPH_TRACK_SIMULATION_STATS "Track Simulation Stats" OFF)
|
|
83
|
+
|
|
84
|
+
# Enable the debug renderer in the Debug and Release builds. Note that DEBUG_RENDERER_IN_DISTRIBUTION will override this setting.
|
|
85
|
+
option(DEBUG_RENDERER_IN_DEBUG_AND_RELEASE "Enable debug renderer in Debug and Release builds" ON)
|
|
86
|
+
|
|
87
|
+
# Setting to enable the debug renderer in all builds.
|
|
88
|
+
# Note that enabling this reduces the performance of the library even if you're not drawing anything.
|
|
89
|
+
option(DEBUG_RENDERER_IN_DISTRIBUTION "Enable debug renderer in all builds" OFF)
|
|
90
|
+
|
|
91
|
+
# Enable the profiler in Debug and Release builds. Note that PROFILER_IN_DISTRIBUTION will override this setting.
|
|
92
|
+
option(PROFILER_IN_DEBUG_AND_RELEASE "Enable the profiler in Debug and Release builds" ON)
|
|
93
|
+
|
|
94
|
+
# Enable the profiler in all builds.
|
|
95
|
+
# Note that enabling this reduces the performance of the library.
|
|
96
|
+
option(PROFILER_IN_DISTRIBUTION "Enable the profiler in all builds" OFF)
|
|
97
|
+
|
|
98
|
+
# Ability to use the external profiler using CMake config. Defines preprocessor JPH_EXTERNAL_PROFILE.
|
|
99
|
+
# Use external profiler set using ProfileStartMeasurement and ProfileEndMeasurement to profile.
|
|
100
|
+
# Option is available only when profiling is enabled using PROFILER_IN_DEBUG_AND_RELEASE or PROFILER_IN_DISTRIBUTION.
|
|
101
|
+
option(JPH_USE_EXTERNAL_PROFILE "Use external profiler when profiling is enabled" OFF)
|
|
102
|
+
|
|
103
|
+
# Setting this option will force the library to use malloc/free instead of allowing the user to override the memory allocator
|
|
104
|
+
option(DISABLE_CUSTOM_ALLOCATOR "Disable support for a custom memory allocator" OFF)
|
|
105
|
+
|
|
106
|
+
# Setting this option will force the library to use the STL vector instead of the custom Array class
|
|
107
|
+
option(USE_STD_VECTOR "Use std::vector instead of own Array class" OFF)
|
|
108
|
+
|
|
109
|
+
# Setting this option will compile the ObjectStream class and RTTI attribute information
|
|
110
|
+
option(ENABLE_OBJECT_STREAM "Compile the ObjectStream class and RTTI attribute information" ON)
|
|
111
|
+
|
|
112
|
+
# Enable installation
|
|
113
|
+
option(ENABLE_INSTALL "Generate installation target" ON)
|
|
114
|
+
|
|
115
|
+
include(CMakeDependentOption)
|
|
116
|
+
|
|
117
|
+
# Ability to toggle between the static and DLL versions of the MSVC runtime library
|
|
118
|
+
# Windows Store only supports the DLL version
|
|
119
|
+
cmake_dependent_option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" ON "MSVC;NOT WINDOWS_STORE" OFF)
|
|
120
|
+
|
|
121
|
+
# Enable Vulkan instead of DirectX
|
|
122
|
+
cmake_dependent_option(JPH_ENABLE_VULKAN "Enable Vulkan" ON "LINUX" OFF)
|
|
123
|
+
|
|
124
|
+
# Determine which configurations exist
|
|
125
|
+
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) # Only do this when we're at the top level, see: https://gitlab.kitware.com/cmake/cmake/-/issues/24181
|
|
126
|
+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
127
|
+
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
|
|
128
|
+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
|
129
|
+
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;ReleaseASAN;ReleaseUBSAN;ReleaseTSAN;ReleaseCoverage;Distribution")
|
|
130
|
+
endif()
|
|
131
|
+
endif()
|
|
132
|
+
|
|
133
|
+
if (MSVC)
|
|
134
|
+
# Fill in the path to the asan libraries
|
|
135
|
+
set(CLANG_LIB_PATH "\"$(VSInstallDir)\\VC\\Tools\\Llvm\\x64\\lib\\clang\\${CMAKE_CXX_COMPILER_VERSION}\\lib\\windows\"")
|
|
136
|
+
|
|
137
|
+
# 64 bit architecture
|
|
138
|
+
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
|
|
139
|
+
|
|
140
|
+
# Set runtime library
|
|
141
|
+
if (USE_STATIC_MSVC_RUNTIME_LIBRARY)
|
|
142
|
+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
143
|
+
endif()
|
|
144
|
+
|
|
145
|
+
# Set general compiler flags
|
|
146
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Gm- /MP /nologo /diagnostics:classic /FC /fp:except- /Zc:inline")
|
|
147
|
+
|
|
148
|
+
# Enable warnings
|
|
149
|
+
if (ENABLE_ALL_WARNINGS)
|
|
150
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /WX")
|
|
151
|
+
endif()
|
|
152
|
+
|
|
153
|
+
# Optionally generate debug symbols
|
|
154
|
+
if (GENERATE_DEBUG_SYMBOLS)
|
|
155
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
|
|
156
|
+
endif()
|
|
157
|
+
|
|
158
|
+
if (NOT CPP_RTTI_ENABLED)
|
|
159
|
+
# Set compiler flag for disabling RTTI
|
|
160
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
|
|
161
|
+
else()
|
|
162
|
+
# Set compiler flag for enabling RTTI
|
|
163
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR")
|
|
164
|
+
endif()
|
|
165
|
+
|
|
166
|
+
if (NOT CPP_EXCEPTIONS_ENABLED)
|
|
167
|
+
# Remove any existing compiler flag that enables exceptions
|
|
168
|
+
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
169
|
+
|
|
170
|
+
# Disable warning about STL and compiler-generated types using noexcept when exceptions are disabled
|
|
171
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4577")
|
|
172
|
+
else()
|
|
173
|
+
# Enable exceptions
|
|
174
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
|
175
|
+
endif()
|
|
176
|
+
|
|
177
|
+
# Set compiler flags for various configurations
|
|
178
|
+
if (OVERRIDE_CXX_FLAGS)
|
|
179
|
+
set(CMAKE_CXX_FLAGS_DEBUG "/GS /Od /Ob0 /RTC1")
|
|
180
|
+
set(CMAKE_CXX_FLAGS_RELEASE "/GS- /Gy /O2 /Oi /Ot")
|
|
181
|
+
endif()
|
|
182
|
+
set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
183
|
+
set(CMAKE_CXX_FLAGS_RELEASEASAN "-fsanitize=address /Od")
|
|
184
|
+
set(CMAKE_CXX_FLAGS_RELEASEUBSAN "-fsanitize=undefined,implicit-conversion,float-divide-by-zero,local-bounds -fno-sanitize-recover=all")
|
|
185
|
+
set(CMAKE_CXX_FLAGS_RELEASETSAN "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=thread")
|
|
186
|
+
set(CMAKE_CXX_FLAGS_RELEASECOVERAGE "-fprofile-instr-generate -fcoverage-mapping")
|
|
187
|
+
|
|
188
|
+
# Set linker flags
|
|
189
|
+
set(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /ignore:4221")
|
|
190
|
+
if (GENERATE_DEBUG_SYMBOLS)
|
|
191
|
+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
|
|
192
|
+
endif()
|
|
193
|
+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
194
|
+
if (CROSS_PLATFORM_DETERMINISTIC)
|
|
195
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise")
|
|
196
|
+
else()
|
|
197
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast") # Clang doesn't use fast math because it cannot be turned off inside a single compilation unit
|
|
198
|
+
endif()
|
|
199
|
+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
200
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /showFilenames")
|
|
201
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Clang emits warnings about unused arguments such as /MP and /GL
|
|
202
|
+
set(CMAKE_EXE_LINKER_FLAGS_RELEASEASAN "/SUBSYSTEM:CONSOLE /LIBPATH:${CLANG_LIB_PATH} clang_rt.asan-x86_64.lib -wholearchive:clang_rt.asan-x86_64.lib clang_rt.asan_cxx-x86_64.lib -wholearchive:clang_rt.asan_cxx-x86_64.lib")
|
|
203
|
+
set(CMAKE_EXE_LINKER_FLAGS_RELEASEUBSAN "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
|
|
204
|
+
set(CMAKE_EXE_LINKER_FLAGS_RELEASETSAN "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
|
|
205
|
+
set(CMAKE_EXE_LINKER_FLAGS_RELEASECOVERAGE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
|
|
206
|
+
endif()
|
|
207
|
+
else()
|
|
208
|
+
# Enable warnings
|
|
209
|
+
if (ENABLE_ALL_WARNINGS)
|
|
210
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
|
211
|
+
endif()
|
|
212
|
+
|
|
213
|
+
# Optionally generate debug symbols
|
|
214
|
+
if (GENERATE_DEBUG_SYMBOLS)
|
|
215
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g${JPH_DEBUG_SYMBOL_FORMAT}")
|
|
216
|
+
endif()
|
|
217
|
+
|
|
218
|
+
if (NOT CPP_RTTI_ENABLED)
|
|
219
|
+
# Set compiler flag for disabling RTTI
|
|
220
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
|
221
|
+
else()
|
|
222
|
+
# Set compiler flag for enabling RTTI
|
|
223
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
|
|
224
|
+
endif()
|
|
225
|
+
|
|
226
|
+
if (NOT CPP_EXCEPTIONS_ENABLED)
|
|
227
|
+
# Set compiler flag for disabling exception-handling
|
|
228
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
|
229
|
+
else()
|
|
230
|
+
# Set compiler flag for enabling exception-handling
|
|
231
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
|
232
|
+
endif()
|
|
233
|
+
|
|
234
|
+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
235
|
+
# Also disable -Wstringop-overflow or it will generate false positives that can't be disabled from code when link-time optimizations are enabled
|
|
236
|
+
# Also disable -Wno-psabi to avoid messages of the form note: parameter passing for argument of type '...' changed in GCC 7.1
|
|
237
|
+
# Also turn off automatic fused multiply add contractions, there doesn't seem to be a way to do this selectively through the macro JPH_PRECISE_MATH_OFF
|
|
238
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -Wno-psabi -ffp-contract=off")
|
|
239
|
+
else()
|
|
240
|
+
# Do not use -ffast-math since it cannot be turned off in a single compilation unit under clang, see Core.h
|
|
241
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise")
|
|
242
|
+
|
|
243
|
+
# On clang 14 and later we can turn off float contraction through a pragma, older versions and deterministic versions need it off always, see Core.h
|
|
244
|
+
# clang on LoongArch does not support such pragma, also turn off contraction for it.
|
|
245
|
+
if (CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "loongarch")
|
|
246
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off")
|
|
247
|
+
|
|
248
|
+
# Clang 20 and later complain with: overriding '-ffp-model=precise' option with '-ffp-contract=off' [-Woverriding-option], but this is exactly what we want.
|
|
249
|
+
if (CMAKE_CXX_COMPILER_VERSION GREATER 19)
|
|
250
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-overriding-option")
|
|
251
|
+
endif()
|
|
252
|
+
endif()
|
|
253
|
+
|
|
254
|
+
# Cross compiler flags
|
|
255
|
+
if (CROSS_COMPILE_ARM AND NOT ("${CROSS_COMPILE_ARM_TARGET}" STREQUAL ""))
|
|
256
|
+
set(CMAKE_CXX_FLAGS "--target=${CROSS_COMPILE_ARM_TARGET} ${CMAKE_CXX_FLAGS}")
|
|
257
|
+
endif()
|
|
258
|
+
endif()
|
|
259
|
+
|
|
260
|
+
# See https://github.com/jrouwe/JoltPhysics/issues/922. When compiling with DOUBLE_PRECISION=YES and CMAKE_OSX_DEPLOYMENT_TARGET=10.12 clang triggers a warning that we silence here.
|
|
261
|
+
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
|
262
|
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-allocation")
|
|
263
|
+
endif()
|
|
264
|
+
|
|
265
|
+
# Set compiler flags for various configurations
|
|
266
|
+
if (OVERRIDE_CXX_FLAGS)
|
|
267
|
+
set(CMAKE_CXX_FLAGS_DEBUG "")
|
|
268
|
+
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
|
269
|
+
endif()
|
|
270
|
+
set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}")
|
|
271
|
+
set(CMAKE_CXX_FLAGS_RELEASEASAN "-fsanitize=address")
|
|
272
|
+
set(CMAKE_CXX_FLAGS_RELEASEUBSAN "-fsanitize=undefined,implicit-conversion,float-divide-by-zero,local-bounds -fno-sanitize-recover=all")
|
|
273
|
+
set(CMAKE_CXX_FLAGS_RELEASETSAN "${CMAKE_CXX_FLAGS_RELEASE} -fsanitize=thread")
|
|
274
|
+
set(CMAKE_CXX_FLAGS_RELEASECOVERAGE "-O0 -DJPH_NO_FORCE_INLINE -fprofile-instr-generate -fcoverage-mapping")
|
|
275
|
+
endif()
|
|
276
|
+
|
|
277
|
+
# Set linker flags
|
|
278
|
+
set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
|
279
|
+
|
|
280
|
+
# Enable link time optimization in Release and Distribution mode if requested and available
|
|
281
|
+
function(SET_INTERPROCEDURAL_OPTIMIZATION)
|
|
282
|
+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF PARENT_SCOPE)
|
|
283
|
+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION OFF PARENT_SCOPE)
|
|
284
|
+
|
|
285
|
+
# On ARM, whole program optimization triggers an internal compiler error during code gen, so we don't turn it on
|
|
286
|
+
# When compiling as a shared lib with MinGW, turning on LTO causes errors of the form 'ld.exe: cannot export symbol X wrong type (4 vs 3)'
|
|
287
|
+
if (INTERPROCEDURAL_OPTIMIZATION
|
|
288
|
+
AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM64")
|
|
289
|
+
AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM")
|
|
290
|
+
AND (NOT CROSS_COMPILE_ARM OR ("${CROSS_COMPILE_ARM_TARGET}" STREQUAL "aarch64-linux-gnu"))
|
|
291
|
+
AND NOT (MINGW AND BUILD_SHARED_LIBS))
|
|
292
|
+
include(CheckIPOSupported)
|
|
293
|
+
check_ipo_supported(RESULT IS_IPO_SUPPORTED OUTPUT IPO_CHECK_OUTPUT)
|
|
294
|
+
|
|
295
|
+
if (IS_IPO_SUPPORTED)
|
|
296
|
+
message("Interprocedural optimizations are turned on")
|
|
297
|
+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON PARENT_SCOPE)
|
|
298
|
+
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION ON PARENT_SCOPE)
|
|
299
|
+
else()
|
|
300
|
+
message("Warning: Interprocedural optimizations are not supported for this target, turn off the option INTERPROCEDURAL_OPTIMIZATION to disable this warning")
|
|
301
|
+
endif()
|
|
302
|
+
endif()
|
|
303
|
+
endfunction()
|
|
304
|
+
SET_INTERPROCEDURAL_OPTIMIZATION()
|
|
305
|
+
|
|
306
|
+
# Set repository root
|
|
307
|
+
set(PHYSICS_REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../)
|
|
308
|
+
|
|
309
|
+
# Make Jolt Library
|
|
310
|
+
include(${PHYSICS_REPO_ROOT}/Jolt/Jolt.cmake)
|
|
311
|
+
if (XCODE)
|
|
312
|
+
# Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures
|
|
313
|
+
set_property(TARGET Jolt PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
|
|
314
|
+
endif()
|
|
315
|
+
|
|
316
|
+
# Install Jolt library and includes
|
|
317
|
+
if (ENABLE_INSTALL)
|
|
318
|
+
include(GNUInstallDirs)
|
|
319
|
+
install(TARGETS Jolt
|
|
320
|
+
EXPORT JoltExport
|
|
321
|
+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
322
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
323
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
324
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
325
|
+
foreach(SRC_FILE ${JOLT_PHYSICS_SRC_FILES})
|
|
326
|
+
string(REPLACE ${PHYSICS_REPO_ROOT} "" RELATIVE_SRC_FILE ${SRC_FILE})
|
|
327
|
+
get_filename_component(DESTINATION_PATH ${RELATIVE_SRC_FILE} DIRECTORY)
|
|
328
|
+
if (NOT RELATIVE_SRC_FILE MATCHES "\.cpp")
|
|
329
|
+
cmake_path(SET DST_FILE NORMALIZE "${CMAKE_INSTALL_INCLUDEDIR}/${DESTINATION_PATH}")
|
|
330
|
+
install(FILES ${SRC_FILE} DESTINATION ${DST_FILE})
|
|
331
|
+
endif()
|
|
332
|
+
endforeach()
|
|
333
|
+
|
|
334
|
+
# Export Jolt library
|
|
335
|
+
export(TARGETS Jolt
|
|
336
|
+
NAMESPACE Jolt::
|
|
337
|
+
FILE JoltConfig.cmake)
|
|
338
|
+
install(EXPORT JoltExport
|
|
339
|
+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Jolt/
|
|
340
|
+
NAMESPACE Jolt::
|
|
341
|
+
FILE JoltConfig.cmake)
|
|
342
|
+
endif()
|
|
343
|
+
|
|
344
|
+
# Check if we're the root CMakeLists.txt, if not we are included by another CMake file and we should disable everything except for the main library
|
|
345
|
+
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
|
346
|
+
# Ability to turn ON/OFF individual applications
|
|
347
|
+
option(TARGET_UNIT_TESTS "Build Unit Tests" ON)
|
|
348
|
+
option(TARGET_HELLO_WORLD "Build Hello World" ON)
|
|
349
|
+
option(TARGET_PERFORMANCE_TEST "Build Performance Test" ON)
|
|
350
|
+
option(TARGET_SAMPLES "Build Samples" ON)
|
|
351
|
+
option(TARGET_VIEWER "Build JoltViewer" ON)
|
|
352
|
+
|
|
353
|
+
if (TARGET_UNIT_TESTS)
|
|
354
|
+
# Create UnitTests executable
|
|
355
|
+
include(${PHYSICS_REPO_ROOT}/UnitTests/UnitTests.cmake)
|
|
356
|
+
add_executable(UnitTests ${UNIT_TESTS_SRC_FILES})
|
|
357
|
+
target_include_directories(UnitTests PUBLIC ${UNIT_TESTS_ROOT})
|
|
358
|
+
target_link_libraries(UnitTests LINK_PUBLIC Jolt)
|
|
359
|
+
|
|
360
|
+
if (EMSCRIPTEN)
|
|
361
|
+
target_link_options(UnitTests PUBLIC -sSTACK_SIZE=1048576 -sINITIAL_MEMORY=134217728)
|
|
362
|
+
endif()
|
|
363
|
+
|
|
364
|
+
# Code coverage doesn't work when using precompiled headers
|
|
365
|
+
if (CMAKE_GENERATOR STREQUAL "Ninja Multi-Config" AND MSVC)
|
|
366
|
+
# The Ninja Multi-Config generator errors out when selectively disabling precompiled headers for certain configurations.
|
|
367
|
+
# See: https://github.com/jrouwe/JoltPhysics/issues/1211
|
|
368
|
+
target_precompile_headers(UnitTests PRIVATE "${JOLT_PHYSICS_ROOT}/Jolt.h")
|
|
369
|
+
else()
|
|
370
|
+
target_precompile_headers(UnitTests PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>")
|
|
371
|
+
endif()
|
|
372
|
+
|
|
373
|
+
if (MSVC)
|
|
374
|
+
target_link_options(UnitTests PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
375
|
+
endif()
|
|
376
|
+
|
|
377
|
+
if (IOS)
|
|
378
|
+
# Set the bundle information
|
|
379
|
+
set_property(TARGET UnitTests PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/iOS/UnitTestsInfo.plist")
|
|
380
|
+
set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.joltphysics.unittests")
|
|
381
|
+
endif()
|
|
382
|
+
|
|
383
|
+
if (XCODE)
|
|
384
|
+
# Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures
|
|
385
|
+
set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
|
|
386
|
+
endif()
|
|
387
|
+
|
|
388
|
+
# Register unit tests as a test so that it can be run with:
|
|
389
|
+
# ctest --output-on-failure
|
|
390
|
+
enable_testing()
|
|
391
|
+
add_test(UnitTests UnitTests)
|
|
392
|
+
endif()
|
|
393
|
+
|
|
394
|
+
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
|
|
395
|
+
if (TARGET_HELLO_WORLD)
|
|
396
|
+
# Example 'Hello World' application
|
|
397
|
+
include(${PHYSICS_REPO_ROOT}/HelloWorld/HelloWorld.cmake)
|
|
398
|
+
add_executable(HelloWorld ${HELLO_WORLD_SRC_FILES})
|
|
399
|
+
target_include_directories(HelloWorld PUBLIC ${HELLO_WORLD_ROOT})
|
|
400
|
+
target_link_libraries(HelloWorld LINK_PUBLIC Jolt)
|
|
401
|
+
if (MSVC)
|
|
402
|
+
target_link_options(HelloWorld PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
403
|
+
endif()
|
|
404
|
+
if (EMSCRIPTEN)
|
|
405
|
+
target_link_options(HelloWorld PUBLIC -sSTACK_SIZE=1048576 -sINITIAL_MEMORY=134217728)
|
|
406
|
+
endif()
|
|
407
|
+
endif()
|
|
408
|
+
|
|
409
|
+
if (TARGET_PERFORMANCE_TEST)
|
|
410
|
+
# Performance Test application
|
|
411
|
+
include(${PHYSICS_REPO_ROOT}/PerformanceTest/PerformanceTest.cmake)
|
|
412
|
+
add_executable(PerformanceTest ${PERFORMANCE_TEST_SRC_FILES})
|
|
413
|
+
target_include_directories(PerformanceTest PUBLIC ${PERFORMANCE_TEST_ROOT})
|
|
414
|
+
target_link_libraries(PerformanceTest LINK_PUBLIC Jolt)
|
|
415
|
+
if (MSVC)
|
|
416
|
+
target_link_options(PerformanceTest PUBLIC "/SUBSYSTEM:CONSOLE")
|
|
417
|
+
endif()
|
|
418
|
+
if (EMSCRIPTEN)
|
|
419
|
+
# Embed the assets for the RagdollScene
|
|
420
|
+
target_link_options(PerformanceTest PUBLIC "SHELL:--preload-file ${PHYSICS_REPO_ROOT}/Assets/Human.tof@/Assets/Human.tof")
|
|
421
|
+
target_link_options(PerformanceTest PUBLIC "SHELL:--preload-file ${PHYSICS_REPO_ROOT}/Assets/Human/dead_pose1.tof@/Assets/Human/dead_pose1.tof")
|
|
422
|
+
target_link_options(PerformanceTest PUBLIC "SHELL:--preload-file ${PHYSICS_REPO_ROOT}/Assets/terrain2.bof@/Assets/terrain2.bof")
|
|
423
|
+
target_link_options(PerformanceTest PUBLIC -sSTACK_SIZE=1048576 -sINITIAL_MEMORY=134217728)
|
|
424
|
+
endif()
|
|
425
|
+
set_property(TARGET PerformanceTest PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PHYSICS_REPO_ROOT}")
|
|
426
|
+
endif()
|
|
427
|
+
endif()
|
|
428
|
+
|
|
429
|
+
if ((WIN32 OR LINUX OR ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")) AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM")) # ARM 32-bit is missing dinput8.lib
|
|
430
|
+
# Windows only targets
|
|
431
|
+
if (TARGET_SAMPLES OR TARGET_VIEWER)
|
|
432
|
+
include(${PHYSICS_REPO_ROOT}/TestFramework/TestFramework.cmake)
|
|
433
|
+
endif()
|
|
434
|
+
if (TARGET_SAMPLES)
|
|
435
|
+
if (TEST_FRAMEWORK_AVAILABLE)
|
|
436
|
+
include(${PHYSICS_REPO_ROOT}/Samples/Samples.cmake)
|
|
437
|
+
else()
|
|
438
|
+
message("Cannot build Samples because Vulkan/DirectX SDK is not available!")
|
|
439
|
+
endif()
|
|
440
|
+
endif()
|
|
441
|
+
if (TARGET_VIEWER)
|
|
442
|
+
if (TEST_FRAMEWORK_AVAILABLE)
|
|
443
|
+
include(${PHYSICS_REPO_ROOT}/JoltViewer/JoltViewer.cmake)
|
|
444
|
+
else()
|
|
445
|
+
message("Cannot build JoltViewer because Vulkan/DirectX SDK is not available!")
|
|
446
|
+
endif()
|
|
447
|
+
endif()
|
|
448
|
+
endif()
|
|
449
|
+
endif()
|