CMakeLists.txt 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
  2. project(JoltPhysics CXX)
  3. # When turning this option on, the library will be compiled using assertions. By default asserts are enabled in Debug build.
  4. option(USE_ASSERTS "Enable asserts" OFF)
  5. # When turning this option on, the library will be compiled using doubles for positions. This allows for much bigger worlds.
  6. option(DOUBLE_PRECISION "Use double precision math" OFF)
  7. # When turning this option on, the library will be compiled with debug symbols
  8. option(GENERATE_DEBUG_SYMBOLS "Generate debug symbols" ON)
  9. # When turning this option on, the library will override the default CMAKE_CXX_FLAGS_DEBUG/RELEASE values, otherwise they will use the platform defaults
  10. option(OVERRIDE_CXX_FLAGS "Override CMAKE_CXX_FLAGS_DEBUG/RELEASE" ON)
  11. # When turning this option on, the library will be compiled in such a way to attempt to keep the simulation deterministic across platforms
  12. option(CROSS_PLATFORM_DETERMINISTIC "Cross platform deterministic" OFF)
  13. # When turning this option on, the library will be compiled for ARM (aarch64-linux-gnu), requires compiling with clang
  14. option(CROSS_COMPILE_ARM "Cross compile to aarch64-linux-gnu" OFF)
  15. # When turning this option on, Jolt will be compiled as a shared library and public symbols will be exported.
  16. option(BUILD_SHARED_LIBS "Compile Jolt as a shared library" OFF)
  17. # 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.
  18. # 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.
  19. # If you don't do this you may get an error: /usr/bin/ld: libJolt.a: error adding symbols: file format not recognized
  20. option(INTERPROCEDURAL_OPTIMIZATION "Enable interprocedural optimizations" ON)
  21. # 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
  22. # and will enable floating point exceptions during simulation to detect divisions by zero.
  23. # Note that this currently only works using MSVC. Clang turns Float2 into a SIMD vector sometimes causing floating point exceptions (the option is ignored).
  24. option(FLOATING_POINT_EXCEPTIONS_ENABLED "Enable floating point exceptions" ON)
  25. # When turning this on, the library will be compiled with C++ exceptions enabled.
  26. # This adds some overhead and Jolt doesn't use exceptions so by default it is off.
  27. option(CPP_EXCEPTIONS_ENABLED "Enable C++ exceptions" OFF)
  28. # When turning this on, the library will be compiled with C++ RTTI enabled.
  29. # This adds some overhead and Jolt doesn't use RTTI so by default it is off.
  30. option(CPP_RTTI_ENABLED "Enable C++ RTTI" OFF)
  31. # Number of bits to use in ObjectLayer. Can be 16 or 32.
  32. option(OBJECT_LAYER_BITS "Number of bits in ObjectLayer" 16)
  33. # Select X86 processor features to use (if everything is off it will be SSE2 compatible)
  34. option(USE_SSE4_1 "Enable SSE4.1" ON)
  35. option(USE_SSE4_2 "Enable SSE4.2" ON)
  36. option(USE_AVX "Enable AVX" ON)
  37. option(USE_AVX2 "Enable AVX2" ON)
  38. option(USE_AVX512 "Enable AVX512" OFF)
  39. option(USE_LZCNT "Enable LZCNT" ON)
  40. option(USE_TZCNT "Enable TZCNT" ON)
  41. option(USE_F16C "Enable F16C" ON)
  42. option(USE_FMADD "Enable FMADD" ON)
  43. # Enable SIMD for the WASM build. Note that this is currently off by default since not all browsers support this.
  44. # See: https://caniuse.com/?search=WebAssembly%20SIMD (Safari got support in March 2023 and was the last major browser to get support).
  45. option(USE_WASM_SIMD "Enable SIMD for WASM" OFF)
  46. # Enable all warnings
  47. option(ENABLE_ALL_WARNINGS "Enable all warnings and warnings as errors" ON)
  48. # Setting to periodically trace broadphase stats to help determine if the broadphase layer configuration is optimal
  49. option(TRACK_BROADPHASE_STATS "Track Broadphase Stats" OFF)
  50. # Setting to periodically trace narrowphase stats to help determine which collision queries could be optimized
  51. option(TRACK_NARROWPHASE_STATS "Track Narrowphase Stats" OFF)
  52. # Enable the debug renderer in the Debug and Release builds. Note that DEBUG_RENDERER_IN_DISTRIBUTION will override this setting.
  53. option(DEBUG_RENDERER_IN_DEBUG_AND_RELEASE "Enable debug renderer in Debug and Release builds" ON)
  54. # Setting to enable the debug renderer in all builds.
  55. # Note that enabling this reduces the performance of the library even if you're not drawing anything.
  56. option(DEBUG_RENDERER_IN_DISTRIBUTION "Enable debug renderer in all builds" OFF)
  57. # Enable the profiler in Debug and Release builds. Note that PROFILER_IN_DISTRIBUTION will override this setting.
  58. option(PROFILER_IN_DEBUG_AND_RELEASE "Enable the profiler in Debug and Release builds" ON)
  59. # Enable the profiler in all builds.
  60. # Note that enabling this reduces the performance of the library.
  61. option(PROFILER_IN_DISTRIBUTION "Enable the profiler in all builds" OFF)
  62. # Setting this option will force the library to use malloc/free instead of allowing the user to override the memory allocator
  63. option(DISABLE_CUSTOM_ALLOCATOR "Disable support for a custom memory allocator" OFF)
  64. # Setting this option will force the library to use the STL vector instead of the custom Array class
  65. option(USE_STD_VECTOR "Use std::vector instead of own Array class" OFF)
  66. # Setting this option will compile the ObjectStream class and RTTI attribute information
  67. option(ENABLE_OBJECT_STREAM "Compile the ObjectStream class and RTTI attribute information" ON)
  68. # Enable installation
  69. option(ENABLE_INSTALL "Generate installation target" ON)
  70. include(CMakeDependentOption)
  71. # Ability to toggle between the static and DLL versions of the MSVC runtime library
  72. # Windows Store only supports the DLL version
  73. cmake_dependent_option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" ON "MSVC;NOT WINDOWS_STORE" OFF)
  74. # Determine which configurations exist
  75. 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
  76. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  77. set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution")
  78. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
  79. set(CMAKE_CONFIGURATION_TYPES "Debug;Release;ReleaseASAN;ReleaseUBSAN;ReleaseCoverage;Distribution")
  80. endif()
  81. endif()
  82. if (MSVC)
  83. # Fill in the path to the asan libraries
  84. set(CLANG_LIB_PATH "\"$(VSInstallDir)\\VC\\Tools\\Llvm\\x64\\lib\\clang\\${CMAKE_CXX_COMPILER_VERSION}\\lib\\windows\"")
  85. # 64 bit architecture
  86. set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
  87. # Set runtime library
  88. if (USE_STATIC_MSVC_RUNTIME_LIBRARY)
  89. set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
  90. endif()
  91. # Set general compiler flags
  92. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Gm- /MP /nologo /diagnostics:classic /FC /fp:except- /Zc:inline")
  93. # Enable warnings
  94. if (ENABLE_ALL_WARNINGS)
  95. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /WX")
  96. endif()
  97. # Optionally generate debug symbols
  98. if (GENERATE_DEBUG_SYMBOLS)
  99. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
  100. endif()
  101. if (NOT CPP_RTTI_ENABLED)
  102. # Set compiler flag for disabling RTTI
  103. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
  104. else()
  105. # Set compiler flag for enabling RTTI
  106. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR")
  107. endif()
  108. if (NOT CPP_EXCEPTIONS_ENABLED)
  109. # Remove any existing compiler flag that enables exceptions
  110. string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
  111. # Disable warning about STL and compiler-generated types using noexcept when exceptions are disabled
  112. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4577")
  113. else()
  114. # Enable exceptions
  115. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
  116. endif()
  117. # Set compiler flags for various configurations
  118. if (OVERRIDE_CXX_FLAGS)
  119. set(CMAKE_CXX_FLAGS_DEBUG "/GS /Od /Ob0 /RTC1")
  120. set(CMAKE_CXX_FLAGS_RELEASE "/GS- /Gy /O2 /Oi /Ot")
  121. endif()
  122. set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}")
  123. set(CMAKE_CXX_FLAGS_RELEASEASAN "-fsanitize=address /Od")
  124. set(CMAKE_CXX_FLAGS_RELEASEUBSAN "-fsanitize=undefined,implicit-conversion,float-divide-by-zero,local-bounds -fno-sanitize-recover=all")
  125. set(CMAKE_CXX_FLAGS_RELEASECOVERAGE "-fprofile-instr-generate -fcoverage-mapping")
  126. # Set linker flags
  127. set(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /ignore:4221")
  128. if (GENERATE_DEBUG_SYMBOLS)
  129. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG")
  130. endif()
  131. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  132. if (CROSS_PLATFORM_DETERMINISTIC)
  133. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise")
  134. else()
  135. 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
  136. endif()
  137. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  138. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /showFilenames")
  139. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Clang emits warnings about unused arguments such as /MP and /GL
  140. 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")
  141. set(CMAKE_EXE_LINKER_FLAGS_RELEASEUBSAN "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
  142. set(CMAKE_EXE_LINKER_FLAGS_RELEASECOVERAGE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LIBPATH:${CLANG_LIB_PATH}")
  143. endif()
  144. else()
  145. # Enable warnings
  146. if (ENABLE_ALL_WARNINGS)
  147. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
  148. endif()
  149. # Optionally generate debug symbols
  150. if (GENERATE_DEBUG_SYMBOLS)
  151. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
  152. endif()
  153. if (NOT CPP_RTTI_ENABLED)
  154. # Set compiler flag for disabling RTTI
  155. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
  156. else()
  157. # Set compiler flag for enabling RTTI
  158. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
  159. endif()
  160. if (NOT CPP_EXCEPTIONS_ENABLED)
  161. # Set compiler flag for disabling exception-handling
  162. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
  163. else()
  164. # Set compiler flag for enabling exception-handling
  165. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
  166. endif()
  167. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  168. # Also disable -Wstringop-overflow or it will generate false positives that can't be disabled from code when link-time optimizations are enabled
  169. # 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
  170. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -ffp-contract=off")
  171. else()
  172. # Do not use -ffast-math since it cannot be turned off in a single compilation unit under clang, see Core.h
  173. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise")
  174. # 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
  175. if (CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC)
  176. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off")
  177. endif()
  178. # Cross compiler flags
  179. if (CROSS_COMPILE_ARM)
  180. set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnu ${CMAKE_CXX_FLAGS}")
  181. endif()
  182. endif()
  183. # 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.
  184. if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
  185. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-allocation")
  186. endif()
  187. # Set compiler flags for various configurations
  188. if (OVERRIDE_CXX_FLAGS)
  189. set(CMAKE_CXX_FLAGS_DEBUG "")
  190. set(CMAKE_CXX_FLAGS_RELEASE "-O3")
  191. endif()
  192. set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}")
  193. set(CMAKE_CXX_FLAGS_RELEASEASAN "-fsanitize=address")
  194. set(CMAKE_CXX_FLAGS_RELEASEUBSAN "-fsanitize=undefined,implicit-conversion,float-divide-by-zero,local-bounds -fno-sanitize-recover=all")
  195. set(CMAKE_CXX_FLAGS_RELEASECOVERAGE "-O0 -DJPH_NO_FORCE_INLINE -fprofile-instr-generate -fcoverage-mapping")
  196. endif()
  197. # Set linker flags
  198. set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
  199. # Enable link time optimization in Release and Distribution mode if requested and available
  200. function(SET_INTERPROCEDURAL_OPTIMIZATION)
  201. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE OFF PARENT_SCOPE)
  202. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION OFF PARENT_SCOPE)
  203. # On ARM, whole program optimization triggers an internal compiler error during code gen, so we don't turn it on
  204. if (INTERPROCEDURAL_OPTIMIZATION AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM64") AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM"))
  205. include(CheckIPOSupported)
  206. check_ipo_supported(RESULT IS_IPO_SUPPORTED OUTPUT IPO_CHECK_OUTPUT)
  207. if (IS_IPO_SUPPORTED)
  208. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON PARENT_SCOPE)
  209. set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DISTRIBUTION ON PARENT_SCOPE)
  210. else()
  211. message("Warning: Interprocedural optimizations are not supported for this target, turn off the option INTERPROCEDURAL_OPTIMIZATION to disable this warning")
  212. endif()
  213. endif()
  214. endfunction()
  215. SET_INTERPROCEDURAL_OPTIMIZATION()
  216. # Set repository root
  217. set(PHYSICS_REPO_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../)
  218. # Make Jolt Library
  219. include(${PHYSICS_REPO_ROOT}/Jolt/Jolt.cmake)
  220. if (XCODE)
  221. # Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures
  222. set_property(TARGET Jolt PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
  223. endif()
  224. # Install Jolt library and includes
  225. if (ENABLE_INSTALL)
  226. install(TARGETS Jolt
  227. EXPORT JoltExport
  228. DESTINATION lib)
  229. foreach(SRC_FILE ${JOLT_PHYSICS_SRC_FILES})
  230. string(REPLACE ${PHYSICS_REPO_ROOT} "" RELATIVE_SRC_FILE ${SRC_FILE})
  231. get_filename_component(DESTINATION_PATH ${RELATIVE_SRC_FILE} DIRECTORY)
  232. if (NOT RELATIVE_SRC_FILE MATCHES "\.cpp")
  233. install(FILES ${SRC_FILE} DESTINATION include/${DESTINATION_PATH})
  234. endif()
  235. endforeach()
  236. # Export Jolt library
  237. export(TARGETS Jolt
  238. NAMESPACE Jolt::
  239. FILE JoltConfig.cmake)
  240. install(EXPORT JoltExport
  241. DESTINATION lib/cmake/Jolt/
  242. NAMESPACE Jolt::
  243. FILE JoltConfig.cmake)
  244. endif()
  245. # 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
  246. if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  247. # Ability to turn ON/OFF individual applications
  248. option(TARGET_UNIT_TESTS "Build Unit Tests" ON)
  249. option(TARGET_HELLO_WORLD "Build Hello World" ON)
  250. option(TARGET_PERFORMANCE_TEST "Build Performance Test" ON)
  251. option(TARGET_SAMPLES "Build Samples" ON)
  252. option(TARGET_VIEWER "Build JoltViewer" ON)
  253. if (TARGET_UNIT_TESTS)
  254. # Create UnitTests executable
  255. include(${PHYSICS_REPO_ROOT}/UnitTests/UnitTests.cmake)
  256. add_executable(UnitTests ${UNIT_TESTS_SRC_FILES})
  257. target_include_directories(UnitTests PUBLIC ${UNIT_TESTS_ROOT})
  258. target_link_libraries(UnitTests LINK_PUBLIC Jolt)
  259. target_precompile_headers(UnitTests PRIVATE "$<$<NOT:$<CONFIG:ReleaseCoverage>>:${JOLT_PHYSICS_ROOT}/Jolt.h>") # Code coverage doesn't work when using precompiled headers
  260. if (MSVC)
  261. target_link_options(UnitTests PUBLIC "/SUBSYSTEM:CONSOLE")
  262. endif()
  263. if (IOS)
  264. # Set the bundle information
  265. set_property(TARGET UnitTests PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/iOS/UnitTestsInfo.plist")
  266. set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.joltphysics.unittests")
  267. endif()
  268. if (XCODE)
  269. # Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures
  270. set_property(TARGET UnitTests PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt")
  271. endif()
  272. # Register unit tests as a test so that it can be run with:
  273. # ctest --output-on-failure
  274. enable_testing()
  275. add_test(UnitTests UnitTests)
  276. endif()
  277. if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
  278. if (TARGET_HELLO_WORLD)
  279. # Example 'Hello World' application
  280. include(${PHYSICS_REPO_ROOT}/HelloWorld/HelloWorld.cmake)
  281. add_executable(HelloWorld ${HELLO_WORLD_SRC_FILES})
  282. target_include_directories(HelloWorld PUBLIC ${HELLO_WORLD_ROOT})
  283. target_link_libraries(HelloWorld LINK_PUBLIC Jolt)
  284. if (MSVC)
  285. target_link_options(HelloWorld PUBLIC "/SUBSYSTEM:CONSOLE")
  286. endif()
  287. endif()
  288. if (TARGET_PERFORMANCE_TEST)
  289. # Performance Test application
  290. include(${PHYSICS_REPO_ROOT}/PerformanceTest/PerformanceTest.cmake)
  291. add_executable(PerformanceTest ${PERFORMANCE_TEST_SRC_FILES})
  292. target_include_directories(PerformanceTest PUBLIC ${PERFORMANCE_TEST_ROOT})
  293. target_link_libraries(PerformanceTest LINK_PUBLIC Jolt)
  294. if (MSVC)
  295. target_link_options(PerformanceTest PUBLIC "/SUBSYSTEM:CONSOLE")
  296. endif()
  297. if (EMSCRIPTEN)
  298. # Embed the assets for the RagdollScene
  299. target_link_options(PerformanceTest PUBLIC "SHELL:--preload-file ${PHYSICS_REPO_ROOT}/Assets/Human.tof@/Assets/Human.tof")
  300. target_link_options(PerformanceTest PUBLIC "SHELL:--preload-file ${PHYSICS_REPO_ROOT}/Assets/Human/dead_pose1.tof@/Assets/Human/dead_pose1.tof")
  301. target_link_options(PerformanceTest PUBLIC "SHELL:--preload-file ${PHYSICS_REPO_ROOT}/Assets/terrain2.bof@/Assets/terrain2.bof")
  302. endif()
  303. set_property(TARGET PerformanceTest PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${PHYSICS_REPO_ROOT}")
  304. # Copy the assets folder
  305. add_custom_command(TARGET PerformanceTest PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${PHYSICS_REPO_ROOT}/Assets/ $<TARGET_FILE_DIR:PerformanceTest>/Assets/)
  306. endif()
  307. endif()
  308. if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "ARM")) # ARM 32-bit is missing dinput8.lib
  309. # Windows only targets
  310. if (TARGET_SAMPLES OR TARGET_VIEWER)
  311. include(${PHYSICS_REPO_ROOT}/TestFramework/TestFramework.cmake)
  312. endif()
  313. if (TARGET_SAMPLES)
  314. include(${PHYSICS_REPO_ROOT}/Samples/Samples.cmake)
  315. endif()
  316. if (TARGET_VIEWER)
  317. include(${PHYSICS_REPO_ROOT}/JoltViewer/JoltViewer.cmake)
  318. endif()
  319. endif()
  320. endif()