### Build HelloWorld Example Executable Source: https://github.com/secondhalfgames/joltc/blob/main/CMakeLists.txt This snippet defines and configures the `HelloWorld` example executable, but only when CMake is run from the top-level source directory. It specifies the source file, enables C++20 features for designated initializers, and links against the `joltc` library. ```CMake if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) add_executable(HelloWorld HelloWorld/main.cpp ) # cxx_std_20 gives us designated initializers, bringing us closer to Actual C. target_compile_features(HelloWorld PRIVATE cxx_std_20) # Eventually we should switch back to Actual C: # set_property(TARGET HelloWorld PROPERTY C_STANDARD 23) target_include_directories(HelloWorld PUBLIC .) target_link_libraries(HelloWorld PUBLIC joltc) endif() ``` -------------------------------- ### Define and Configure JoltC Static Library Source: https://github.com/secondhalfgames/joltc/blob/main/CMakeLists.txt This section defines the `joltc` static library, specifying its source files for both C and C++ interfaces. It configures C++17 features, includes directories for dependencies like JoltPhysics, links against the Jolt library, and sets up installation rules for the compiled library. ```CMake add_library(joltc STATIC # C Interface JoltC/JoltC.h JoltC/Enums.h JoltC/Functions.h # C++ Implementation JoltCImpl/Test.cpp JoltCImpl/JoltC.cpp ) target_compile_features(joltc PUBLIC cxx_std_17) target_include_directories(joltc PUBLIC . JoltPhysics) target_link_libraries(joltc PUBLIC Jolt) install(TARGETS joltc DESTINATION lib) ``` -------------------------------- ### Build JoltC with CMake Source: https://github.com/secondhalfgames/joltc/blob/main/README.md Instructions for configuring and building the JoltC wrapper using CMake. This includes basic configuration and optional flags for enabling double precision or setting the object layer bits. ```bash # Configure the build cmake -B build # Optionally, you can enable double precision, or make ObjectLayer use 32 bits # We aim to support most of the configuration of Jolt's C++ API. cmake -B build -DDOUBLE_PRECISION=ON -DOBJECT_LAYER_BITS=32 # Build cmake --build build ``` -------------------------------- ### Configure Core Project Settings and Global Build Options Source: https://github.com/secondhalfgames/joltc/blob/main/CMakeLists.txt This snippet initializes the CMake project, sets the minimum required version, and defines various build options. It includes settings for assertions, double precision math, object layer bit depth, and MSVC runtime library linking, ensuring proper configuration based on the build environment. ```CMake cmake_minimum_required(VERSION 3.16 FATAL_ERROR) # Enable assertions in JoltPhysics 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) # Number of bits to use in ObjectLayer. Can be 16 or 32. option(OBJECT_LAYER_BITS "Number of bits in ObjectLayer" 16) include(CMakeDependentOption) # Ability to toggle between the static and DLL versions of the MSVC runtime library # Windows Store only supports the DLL version cmake_dependent_option(USE_STATIC_MSVC_RUNTIME_LIBRARY "Use the static MSVC runtime library" ON "MSVC;NOT WINDOWS_STORE" OFF) if (USE_STATIC_MSVC_RUNTIME_LIBRARY) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() # Only do this when we're at the top level, see: https://gitlab.kitware.com/cmake/cmake/-/issues/24181 if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(CMAKE_CONFIGURATION_TYPES "Debug;Release") endif() project(JoltC VERSION 0.1 DESCRIPTION "C Wrapper for Jolt Physics" LANGUAGES C CXX) ``` -------------------------------- ### Include JoltPhysics Build Subdirectory Source: https://github.com/secondhalfgames/joltc/blob/main/CMakeLists.txt This line includes the CMake build script for the JoltPhysics library as a subdirectory. This integrates the JoltPhysics build process directly into the JoltC project, ensuring that JoltPhysics is built as a dependency. ```CMake add_subdirectory(JoltPhysics/Build) ``` -------------------------------- ### Apply Platform-Specific Compiler Options Source: https://github.com/secondhalfgames/joltc/blob/main/CMakeLists.txt This snippet applies different compiler flags based on the detected compiler. For MSVC, it sets warning level 4, enables debug symbols, and suppresses a specific warning. For other compilers, it enables strict warning levels and disables RTTI. ```CMake if(MSVC) target_compile_options(joltc PRIVATE /W4) # Enable debug symbols target_compile_options(joltc PRIVATE /Zi) # Ignore 'unreferenced function with internal linkage' target_compile_options(joltc PRIVATE /wd4505) else() target_compile_options(joltc PRIVATE -Wall -Wextra -Wpedantic -fno-rtti) endif() ``` -------------------------------- ### Set Conditional Compile Definitions Source: https://github.com/secondhalfgames/joltc/blob/main/CMakeLists.txt This section adds preprocessor definitions to the `joltc` library based on CMake options. It defines `JPC_DOUBLE_PRECISION` if `DOUBLE_PRECISION` is enabled, and `JPC_OBJECT_LAYER_BITS` with its value if `OBJECT_LAYER_BITS` is set, allowing for conditional compilation within the source code. ```CMake if (DOUBLE_PRECISION) target_compile_definitions(joltc PUBLIC JPC_DOUBLE_PRECISION) endif() if (OBJECT_LAYER_BITS) target_compile_definitions(joltc PUBLIC JPC_OBJECT_LAYER_BITS=${OBJECT_LAYER_BITS}) endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.