### Example Usage of CMake add_sample Function Source: https://github.com/amerkoleci/joltc/blob/main/samples/CMakeLists.txt This snippet demonstrates how to use the `add_sample` CMake function to add a specific sample application, `01_HelloWorld`, to the build system. It assumes the function `add_sample` has been previously defined. ```CMake # Add samples add_sample(01_HelloWorld) ``` -------------------------------- ### Define JoltC Installation Rules Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet defines the installation rules for the JoltC library and its public header. It specifies that the built library (archive, library, and runtime components) should be installed into the standard library and binary directories, and the 'joltc.h' header into a Jolt-specific include directory. ```CMake install(TARGETS ${TARGET_NAME} EXPORT ${TARGET_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/joltc.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Jolt ) ``` -------------------------------- ### Include Standard CMake Modules Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This section includes two essential CMake modules: `GNUInstallDirs` for standard installation directory variables (like BINDIR, LIBDIR) and `FetchContent` for easily integrating external projects and dependencies into the build. ```CMake include(GNUInstallDirs) include(FetchContent) ``` -------------------------------- ### Define CMake Function to Add Jolt Physics Samples Source: https://github.com/amerkoleci/joltc/blob/main/samples/CMakeLists.txt This CMake function, `add_sample`, automates the process of adding sample applications to a build system. It discovers source files, configures them as either shared libraries (for Android) or executables (for other platforms), links them against appropriate Jolt Physics libraries (double or single precision), and sets specific target properties like the debugger working directory and folder. ```CMake function(add_sample SAMPLE_NAME) file(GLOB SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_NAME}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_NAME}/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/${SAMPLE_NAME}/*.cpp" ) if (ANDROID) add_library(${SAMPLE_NAME} SHARED ${SOURCE_FILES}) else () add_executable(${SAMPLE_NAME} ${SOURCE_FILES}) endif () if (DOUBLE_PRECISION) target_link_libraries(${SAMPLE_NAME} LINK_PUBLIC joltc_double) else() target_link_libraries(${SAMPLE_NAME} LINK_PUBLIC joltc) endif () if (MSVC) target_link_options(${SAMPLE_NAME} PUBLIC "/SUBSYSTEM:CONSOLE") endif() set_target_properties(${SAMPLE_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$" FOLDER "samples" ) endfunction() ``` -------------------------------- ### Configure JoltC Compile Definitions and Include Paths Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This section configures compile-time definitions and include directories for the JoltC target. It adds a specific definition if building a shared library and includes necessary header paths for both the build interface and the Jolt Physics source directory. ```CMake if(JPH_BUILD_SHARED) target_compile_definitions(${TARGET_NAME} PRIVATE JPH_SHARED_LIBRARY_BUILD=1) endif () target_include_directories(${TARGET_NAME} PUBLIC $ ${JoltPhysics_SOURCE_DIR}/.. ) ``` -------------------------------- ### Configure Jolt Physics Engine Project and C++ Standard Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet sets the minimum required CMake version, defines the project name as 'joltc' with C++ language support, enables solution folders for better organization, and enforces the C++17 standard with specific settings for extensions and position-independent code. ```CMake cmake_minimum_required(VERSION 3.16 FATAL_ERROR) project(joltc CXX) # Use solution folders to organize projects set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Requires C++ 17 set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_INSTALL_MESSAGE LAZY) set(CMAKE_POSITION_INDEPENDENT_CODE ON) ``` -------------------------------- ### CMake Build Type and JoltPhysics Dependency Configuration Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet sets the default CMake build type to 'Distribution' if not already defined, specifically for master projects. It then uses CMake's FetchContent module to declare and make available the JoltPhysics library, fetching it from its GitHub repository at a specified version tag. ```CMake if (JPH_MASTER_PROJECT AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Distribution" CACHE STRING "The default build type" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES}) endif () FetchContent_Declare( JoltPhysics GIT_REPOSITORY "https://github.com/jrouwe/JoltPhysics" GIT_TAG v5.3.0 SOURCE_SUBDIR "Build" ) FetchContent_MakeAvailable(JoltPhysics) ``` -------------------------------- ### Set macOS Deployment Target and Architectures Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This configuration snippet specifies the minimum macOS deployment version to '11' and defines the build architectures for macOS as 'x86_64' and 'arm64', ensuring compatibility across different Apple silicon and Intel-based systems. ```CMake set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "Minimum OS X deployment version") set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for OS X") ``` -------------------------------- ### Include Samples and Display Build Status Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This final section conditionally includes a 'samples' subdirectory if 'JPH_SAMPLES' is enabled. It also prints informative status messages to the console, indicating whether the library is built as SHARED or STATIC, the status of samples, and various CMake generator and system processor details. ```CMake if (JPH_SAMPLES) add_subdirectory(samples) endif () if (JPH_BUILD_SHARED) message(STATUS " Library SHARED") else () message(STATUS " Library STATIC") endif () message(STATUS " Samples ${JPH_SAMPLES}") if (CMAKE_GENERATOR_PLATFORM) message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}") endif() message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") if (CMAKE_OSX_ARCHITECTURES) message(STATUS "CMAKE_OSX_ARCHITECTURES: ${CMAKE_OSX_ARCHITECTURES}") endif () ``` -------------------------------- ### Enable WASM SIMD and Global Warning Settings Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This section defines two important build options: `USE_WASM_SIMD` to enable SIMD instructions for WebAssembly builds (currently off by default due to browser support variations) and `ENABLE_ALL_WARNINGS` to globally enable all compiler warnings and treat them as errors, promoting stricter code quality. ```CMake # Enable SIMD for the WASM build. Note that this is currently off by default since not all browsers support this. # See: https://caniuse.com/?search=WebAssembly%20SIMD (Safari got support in March 2023 and was the last major browser to get support). option(USE_WASM_SIMD "Enable SIMD for WASM" OFF) # Enable all warnings option(ENABLE_ALL_WARNINGS "Enable all warnings and warnings as errors" OFF) ``` -------------------------------- ### MSVC Compiler and Linker Flag Configuration for JoltPhysics Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This extensive block configures various compiler and linker flags specifically for Microsoft Visual C++ (MSVC) builds. It includes setting the path for ASan libraries, specifying 64-bit architecture, defining general C++ flags, enabling warnings, and managing RTTI and exception handling. It also adjusts floating-point precision based on whether the compiler is MSVC or Clang-cl. ```CMake if (MSVC) # Fill in the path to the asan libraries set(CLANG_LIB_PATH "\"$(VSInstallDir)\\VC\\Tools\\Llvm\\x64\\lib\\clang\\${CMAKE_CXX_COMPILER_VERSION}\\lib\\windows\"") # 64 bit architecture set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64") # Set general compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus /Gm- /MP /nologo /diagnostics:classic /FC /fp:except- /Zc:inline") # Enable warnings if (ENABLE_ALL_WARNINGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /WX") endif() # Set compiler flag for disabling RTTI if (NOT CPP_RTTI_ENABLED) # Set compiler flag for disabling RTTI set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") else() # Set compiler flag for enabling RTTI set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR") endif() if (NOT CPP_EXCEPTIONS_ENABLED) # Remove any existing compiler flag that enables exceptions string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable warning about STL and compiler-generated types using noexcept when exceptions are disabled set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4577") else() # Enable exceptions set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") endif() set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}") # Set linker flags set(CMAKE_EXE_LINKER_FLAGS "/SUBSYSTEM:WINDOWS /ignore:4221") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if (CROSS_PLATFORM_DETERMINISTIC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:precise") else() 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 endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /showFilenames") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") # Clang emits warnings about unused arguments such as /MP and /GL endif() endif() ``` -------------------------------- ### Configure Performance Tracking and Debug Renderer Options Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This final set of options allows for detailed performance analysis and debug visualization. It includes flags to periodically track broadphase and narrowphase statistics, aiding in optimization, and controls the enabling of the debug renderer in various build configurations (Debug, Release, or all builds). ```CMake # Setting to periodically trace broadphase stats to help determine if the broadphase layer configuration is optimal option(TRACK_BROADPHASE_STATS "Track Broadphase Stats" OFF) # Setting to periodically trace narrowphase stats to help determine which collision queries could be optimized option(TRACK_NARROWPHASE_STATS "Track Narrowphase Stats" OFF) # Enable the debug renderer in the Debug and Release builds. Note that DEBUG_RENDERER_IN_DISTRIBUTION will override this setting. option(DEBUG_RENDERER_IN_DEBUG_AND_RELEASE "Enable debug renderer in Debug and Release builds" ON) # Setting to enable the debug renderer in all builds. ``` -------------------------------- ### Specify JoltC Source Files Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This code block lists all the header and source files that constitute the JoltC library. It includes the main C and C++ source files, as well as the assertion implementation, ensuring all necessary components are included in the build. ```CMake set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/joltc.h ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc_assert.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/joltc.c ) ``` -------------------------------- ### GCC/Clang Compiler and Linker Flag Configuration for JoltPhysics Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This section defines compiler and linker flags for non-MSVC environments, primarily targeting GCC and Clang. It covers enabling warnings, configuring RTTI and exception handling, setting floating-point models (precise vs. fast math), handling specific Clang versions (14+), cross-compilation for ARM, and macOS-specific flags. It also includes an option to override CXX flags for debug and release configurations. ```CMake else() # Enable warnings if (ENABLE_ALL_WARNINGS) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror") endif() # Set compiler flag for disabling RTTI if (NOT CPP_RTTI_ENABLED) # Set compiler flag for disabling RTTI set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") else() # Set compiler flag for enabling RTTI set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti") endif() # Disable exception-handling if (NOT CPP_EXCEPTIONS_ENABLED) # Set compiler flag for disabling exception-handling set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") else() # Set compiler flag for enabling exception-handling set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions") endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # Also disable -Wstringop-overflow or it will generate false positives that can't be disabled from code when link-time optimizations are enabled # 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 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow -ffp-contract=off") else() # Do not use -ffast-math since it cannot be turned off in a single compilation unit under clang, see Core.h set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-model=precise") # 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 if (CMAKE_CXX_COMPILER_VERSION LESS 14 OR CROSS_PLATFORM_DETERMINISTIC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off") endif() # Cross compiler flags if (CROSS_COMPILE_ARM) set(CMAKE_CXX_FLAGS "--target=aarch64-linux-gnu ${CMAKE_CXX_FLAGS}") endif() endif() # 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. if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-allocation") endif() # Set compiler flags for various configurations if (OVERRIDE_CXX_FLAGS) set(CMAKE_CXX_FLAGS_DEBUG "") set(CMAKE_CXX_FLAGS_RELEASE "-O3") endif() set(CMAKE_CXX_FLAGS_DISTRIBUTION "${CMAKE_CXX_FLAGS_RELEASE}") # Set linker flags if (NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")) ``` -------------------------------- ### Configure Cross-Compilation and C++ Exception/RTTI Options Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet defines options for advanced compilation scenarios. It includes settings for cross-compiling to ARM (aarch64-linux-gnu), enabling floating-point exceptions (primarily for MSVC), and enabling C++ exceptions and RTTI, which are typically off by default due to their overhead as Jolt does not inherently use them. ```CMake option(CROSS_COMPILE_ARM "Cross compile to aarch64-linux-gnu" OFF) # 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 # and will enable floating point exceptions during simulation to detect divisions by zero. # Note that this currently only works using MSVC. Clang turns Float2 into a SIMD vector sometimes causing floating point exceptions (the option is ignored). option(FLOATING_POINT_EXCEPTIONS_ENABLED "Enable floating point exceptions" ON) # When turning this on, the library will be compiled with C++ exceptions enabled. # This adds some overhead and Jolt doesn't use exceptions so by default it is off. option(CPP_EXCEPTIONS_ENABLED "Enable C++ exceptions" OFF) # When turning this on, the library will be compiled with C++ RTTI enabled. # This adds some overhead and Jolt doesn't use RTTI so by default it is off. option(CPP_RTTI_ENABLED "Enable C++ RTTI" OFF) ``` -------------------------------- ### Configure JoltC++ Build Options with CMake Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This set of CMake options allows fine-grained control over various aspects of the JoltC++ library's build configuration. It includes toggles for debug features, performance profiling, memory allocation strategies, data structure choices, and the inclusion of specific modules like ObjectStream and project samples. ```CMake option(DEBUG_RENDERER_IN_DISTRIBUTION "Enable debug renderer in all builds" ON) ``` ```CMake option(PROFILER_IN_DEBUG_AND_RELEASE "Enable the profiler in Debug and Release builds" ON) ``` ```CMake option(PROFILER_IN_DISTRIBUTION "Enable the profiler in all builds" OFF) ``` ```CMake option(DISABLE_CUSTOM_ALLOCATOR "Disable support for a custom memory allocator" OFF) ``` ```CMake option(USE_STD_VECTOR "Use std::vector instead of own Array class" OFF) ``` ```CMake option(ENABLE_OBJECT_STREAM "Compile the ObjectStream class and RTTI attribute information" ON) ``` ```CMake option(JPH_SAMPLES "Build samples" ${JPH_MASTER_PROJECT}) ``` ```CMake set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Distribution") ``` -------------------------------- ### Create JoltC Library Target Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet creates the actual library target for JoltC. It conditionally builds either a SHARED or STATIC library based on the 'JPH_BUILD_SHARED' option, linking the previously defined source files. ```CMake if (JPH_BUILD_SHARED) add_library(${TARGET_NAME} SHARED ${SOURCE_FILES}) else() add_library(${TARGET_NAME} ${SOURCE_FILES}) endif() ``` -------------------------------- ### Detect Master Project and Configure Build Output Paths Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This section determines if the Jolt engine is being built as the main project or as a subproject. If it's the master project, it configures the global output directories for runtime executables, libraries, and archives to be within the CMake binary directory. ```CMake # Determine if engine is built as a subproject (using add_subdirectory) # or if it is the master project. if (NOT DEFINED JPH_MASTER_PROJECT) set(JPH_MASTER_PROJECT OFF) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(JPH_MASTER_PROJECT ON) message(STATUS "CMake version: ${CMAKE_VERSION}") endif () endif () if (JPH_MASTER_PROJECT) # Configure CMake global variables set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) endif() ``` -------------------------------- ### Configure MSVC Runtime Library for Master Project Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet specifically configures the MSVC runtime library. If Jolt is the master project and the compiler is MSVC, it sets the CMAKE_MSVC_RUNTIME_LIBRARY to 'MultiThreaded' with a debug variant for debug configurations, ensuring proper linking. ```CMake if (MSVC AND JPH_MASTER_PROJECT) if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif () endif () ``` -------------------------------- ### Configure Linker Flags for JoltC Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet sets the executable linker flags to include pthreads for thread safety and configures distribution-specific linker flags by copying release build settings. This ensures proper linking for multi-threaded applications and consistent build configurations. ```CMake set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") endif() endif() # Set linker flags set(CMAKE_EXE_LINKER_FLAGS_DISTRIBUTION "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_DISTRIBUTION "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") SET_INTERPROCEDURAL_OPTIMIZATION() ``` -------------------------------- ### Define JoltC Shared Library Build Option Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This section controls whether JoltC is built as a shared or static library. It forces static builds for iOS and Emscripten platforms, while providing an option for other platforms to build a shared library, defaulting to the master project's setting. ```CMake set(BUILD_SHARED_LIBS OFF CACHE BOOL "Disable shared library when building Jolt" FORCE) # Options if (IOS OR EMSCRIPTEN) set(JPH_BUILD_SHARED OFF CACHE BOOL "Always Disable shared library on (IOS, WEB)" FORCE) else() option(JPH_BUILD_SHARED "Build a shared library" ${JPH_MASTER_PROJECT}) endif() ``` -------------------------------- ### Apply MSVC-Specific Compiler Options for JoltC Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This extensive block applies various compiler options specifically for MSVC builds. It configures debug information, optimization levels (full optimization for release, no optimization for debug), function inlining, intrinsic functions, fast code favoring, fiber-safe optimizations, string pooling, and security checks based on the build configuration. ```CMake if (MSVC) # Debug information target_compile_options(${TARGET_NAME} PRIVATE $<$:/Zi>) # Enable full optimization in dev/release target_compile_options(${TARGET_NAME} PRIVATE $<$:/Od> $<$>:/Ox>) # Inline function expansion target_compile_options(${TARGET_NAME} PRIVATE /Ob2) # Enable intrinsic functions in dev/release target_compile_options(${TARGET_NAME} PRIVATE $<$>:/Oi>) # Favor fast code target_compile_options(${TARGET_NAME} PRIVATE /Ot) # Enable fiber-safe optimizations in dev/release target_compile_options(${TARGET_NAME} PRIVATE $<$>:/GT>) # Enable string pooling target_compile_options(${TARGET_NAME} PRIVATE /GF) # Use security checks only in debug target_compile_options(${TARGET_NAME} PRIVATE $<$:/sdl> $<$>:/sdl->) else() endif () ``` -------------------------------- ### Define Core Jolt Physics Engine Build Options Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This set of options controls fundamental compilation aspects of the Jolt Physics Engine. It allows enabling assertions, using double precision for positions (for larger worlds), generating debug symbols, overriding default C++ compiler flags, and ensuring cross-platform determinism in simulations. ```CMake option(USE_ASSERTS "Enable asserts" OFF) # When turning this option on, the library will be compiled using doubles for positions. This allows for much bigger worlds. option(DOUBLE_PRECISION "Use double precision math" OFF) # When turning this option on, the library will be compiled with debug symbols option(GENERATE_DEBUG_SYMBOLS "Generate debug symbols" OFF) # When turning this option on, the library will override the default CMAKE_CXX_FLAGS_DEBUG/RELEASE values, otherwise they will use the platform defaults option(OVERRIDE_CXX_FLAGS "Override CMAKE_CXX_FLAGS_DEBUG/RELEASE" ON) # When turning this option on, the library will be compiled in such a way to attempt to keep the simulation deterministic across platforms option(CROSS_PLATFORM_DETERMINISTIC "Cross platform deterministic" OFF) ``` -------------------------------- ### Xcode Specific Compiler Flags for JoltPhysics Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This configuration block applies specific compiler flags when building with Xcode. It ensures that SSE4.2 and POPCNT instructions are enabled for x86_64 architectures, which is crucial for optimizing JoltPhysics performance on macOS platforms. ```CMake if (XCODE) # Ensure that we enable SSE4.2 for the x86_64 build, XCode builds multiple architectures set_property(TARGET Jolt PROPERTY XCODE_ATTRIBUTE_OTHER_CPLUSPLUSFLAGS[arch=x86_64] "$(inherited) -msse4.2 -mpopcnt") endif() ``` -------------------------------- ### Determine JoltC Target Name Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This snippet defines the target name for the JoltC library. It conditionally appends '_double' to the target name if the 'DOUBLE_PRECISION' option is enabled, allowing for separate builds based on floating-point precision. ```CMake # Define target name if (DOUBLE_PRECISION) set (TARGET_NAME joltc_double) else() set (TARGET_NAME joltc) endif () ``` -------------------------------- ### Link JoltC with Jolt Physics Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This simple line ensures that the JoltC library target is privately linked against the core Jolt Physics library. This establishes the necessary dependency for JoltC to utilize Jolt Physics functionalities. ```CMake target_link_libraries(${TARGET_NAME} PRIVATE Jolt) ``` -------------------------------- ### Conditional Inclusion of Jolt Physics Samples in CMake Source: https://github.com/amerkoleci/joltc/blob/main/samples/CMakeLists.txt This CMake snippet checks if the `JPH_SAMPLES` variable is set. If it's not, the script returns, effectively preventing the inclusion and compilation of sample applications. This acts as a guard to optionally disable sample builds. ```CMake if (NOT JPH_SAMPLES) return () endif () ``` -------------------------------- ### Set Object Layer Bits and X86 Processor Feature Flags Source: https://github.com/amerkoleci/joltc/blob/main/CMakeLists.txt This configuration sets the number of bits for object layers to 32, which is relevant for the `ObjectLayerPairFilterMask`. It also provides a comprehensive set of options to enable specific X86 processor features like SSE4.1, SSE4.2, AVX, AVX2, AVX512, LZCNT, TZCNT, F16C, and FMADD, allowing for fine-grained control over SIMD and instruction set optimizations. ```CMake # Use 32-bit object layers to support more bits in ObjectLayerPairFilterMask set(OBJECT_LAYER_BITS 32) # Select X86 processor features to use (if everything is off it will be SSE2 compatible) option(USE_SSE4_1 "Enable SSE4.1" ON) option(USE_SSE4_2 "Enable SSE4.2" ON) option(USE_AVX "Enable AVX" ON) option(USE_AVX2 "Enable AVX2" ON) option(USE_AVX512 "Enable AVX512" OFF) option(USE_LZCNT "Enable LZCNT" ON) option(USE_TZCNT "Enable TZCNT" ON) option(USE_F16C "Enable F16C" ON) option(USE_FMADD "Enable FMADD" ON) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.