### Install dependencies on Linux Source: https://github.com/orange-cpp/omath/blob/main/writerside/topics/Documentation.md Installs the necessary tools (cmake, ninja, clang, git) for building the omath library from source on a Linux system using pacman. ```bash sudo pacman -Sy cmake ninja clang git ``` -------------------------------- ### Install dependencies on MacOS Source: https://github.com/orange-cpp/omath/blob/main/writerside/topics/Documentation.md Installs the necessary tools (llvm, git, cmake, ninja) for building the omath library from source on a macOS system using Homebrew. ```bash brew install llvm git cmake ninja ``` -------------------------------- ### Install omath with xrepo Source: https://github.com/orange-cpp/omath/blob/main/INSTALL.md Installs the omath package using xrepo. This is another package management option. Ensure xmake is installed prior to execution. The xmake.lua snippet demonstrates how to integrate omath into your project. ```bash xrepo install omath ``` ```xmake add_requires("omath") target("...") add_packages("omath") ``` -------------------------------- ### Install omath with vcpkg Source: https://github.com/orange-cpp/omath/blob/main/INSTALL.md Installs the orange-math package using vcpkg. This method simplifies dependency management. It requires vcpkg to be installed beforehand. The CMakeLists.txt snippet shows how to link against the installed library. ```bash vcpkg install orange-math ``` ```cmake find_package(omath CONFIG REQUIRED) target_link_libraries(main PRIVATE omath::omath) ``` -------------------------------- ### Install omath via vcpkg Source: https://github.com/orange-cpp/omath/blob/main/writerside/topics/Documentation.md Installs the orange-math package using the vcpkg package manager. It requires vcpkg to be installed first. The code snippet also shows how to link the installed library in a CMake project. ```bash vcpkg install orange-math ``` ```cmake find_package(omath CONFIG REQUIRED) target_link_libraries(main PRIVATE omath::omath) ``` -------------------------------- ### Build omath from source with CMake Source: https://github.com/orange-cpp/omath/blob/main/INSTALL.md Builds the omath project from source using CMake. This method requires CMake, clang, git, and MSVC (on Windows). It includes steps for cloning the repository, navigating to the directory, and executing build commands with specific presets for different platforms and configurations. ```bash # Linux installation sudo pacman -Sy cmake ninja clang git ``` ```bash # MacOS installation brew install llvm git cmake ninja ``` ```bash # Clone the repository git clone https://github.com/orange-cpp/omath.git ``` ```bash # Navigate to the project directory cd omath ``` ```bash # Build the project using CMake (example for Windows release) cmake --preset windows-release -S . cmake --build cmake-build/build/windows-release --target omath -j 6 ``` -------------------------------- ### Build omath from source with CMake Source: https://github.com/orange-cpp/omath/blob/main/writerside/topics/Documentation.md Builds the omath library from source using CMake. This involves configuring the build with a specific preset (e.g., 'windows-release') and then building the 'omath' target with parallel jobs. ```bash cmake --preset windows-release -S . cmake --build cmake-build/build/windows-release --target omath -j 6 ``` -------------------------------- ### Clone omath repository Source: https://github.com/orange-cpp/omath/blob/main/writerside/topics/Documentation.md Clones the omath C++ library repository from GitHub using the git clone command. ```bash git clone https://github.com/orange-cpp/omath.git ``` -------------------------------- ### OMath CMake Project Setup Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Initializes CMake, sets the project name and version, and includes necessary CMake modules. It defines several boolean options to control build features like testing, warnings, shared libraries, AVX2 support, ImGui integration, examples, and legacy features. ```cmake cmake_minimum_required(VERSION 3.26) project(omath VERSION 3.5.0 LANGUAGES CXX) include(CMakePackageConfigHelpers) option(OMATH_BUILD_TESTS "Build unit tests" ${PROJECT_IS_TOP_LEVEL}) option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON) option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF) option(OMATH_USE_AVX2 "Omath will use AVX2 to boost performance" ON) option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types to imgui types" OFF) option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" OFF) option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF) option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON) option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF) option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" OFF) message(STATUS "[${PROJECT_NAME}]: Building on ${CMAKE_HOST_SYSTEM_NAME}") message(STATUS "[${PROJECT_NAME}]: Warnings as errors ${OMATH_THREAT_WARNING_AS_ERROR}") message(STATUS "[${PROJECT_NAME}]: Build unit tests ${OMATH_BUILD_TESTS}") message(STATUS "[${PROJECT_NAME}]: As dynamic library ${OMATH_BUILD_AS_SHARED_LIBRARY}") message(STATUS "[${PROJECT_NAME}]: Static C++ runtime ${OMATH_STATIC_MSVC_RUNTIME_LIBRARY}") message(STATUS "[${PROJECT_NAME}]: CMake unity build ${OMATH_USE_UNITY_BUILD}") message(STATUS "[${PROJECT_NAME}]: Example projects ${OMATH_BUILD_EXAMPLES}") message(STATUS "[${PROJECT_NAME}]: AVX2 feature status ${OMATH_USE_AVX2}") message(STATUS "[${PROJECT_NAME}]: ImGUI integration feature status ${OMATH_IMGUI_INTEGRATION}") message(STATUS "[${PROJECT_NAME}]: Legacy features support ${OMATH_ENABLE_LEGACY}") ``` -------------------------------- ### OMath Test and Example Subdirectories Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Includes the 'extlibs' and 'tests' subdirectories if unit tests are enabled (`OMATH_BUILD_TESTS`), and the 'examples' subdirectory if example projects are to be built (`OMATH_BUILD_EXAMPLES`). ```cmake if (OMATH_BUILD_TESTS) add_subdirectory(extlibs) add_subdirectory(tests) target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_BUILD_TESTS) endif () if (OMATH_BUILD_EXAMPLES) add_subdirectory(examples) endif () ``` -------------------------------- ### Install omath Library and Headers Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Defines the installation rules for the omath project. It installs the compiled library targets (static, shared, and runtime components) and the project's header files to their respective destinations, making the library available for use by other projects. ```cmake # Install the library install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION lib COMPONENT ${PROJECT_NAME} # For static libraries LIBRARY DESTINATION lib COMPONENT ${PROJECT_NAME} # For shared libraries RUNTIME DESTINATION bin COMPONENT ${PROJECT_NAME} # For executables (on Windows) ) # Install headers as part of omath_component install(DIRECTORY include/ DESTINATION include COMPONENT ${PROJECT_NAME}) ``` -------------------------------- ### ESP Example with OMath Camera Source: https://github.com/orange-cpp/omath/blob/main/README.md Demonstrates using the OMath camera class to convert world coordinates to screen coordinates for ESP rendering. It converts player origin and bone positions, then checks entity health. ```cpp omath::source_engine::Camera cam{localPlayer.GetCameraOrigin(), localPlayer.GetAimPunch(), {1920.f, 1080.f}, localPlayer.GetFieldOfView(), 0.01.f, 30000.f}; for (auto ent: apex_sdk::EntityList::GetAllEntities()) { const auto bottom = cam.world_to_screen(ent.GetOrigin()); const auto top = cam.world_to_screen(ent.GetBonePosition(8) + omath::Vector3{0, 0, 10}); const auto ent_health = ent.GetHealth(); if (!top || !bottom || ent_health <= 0) continue; // esp rendering... } ``` -------------------------------- ### OMath ImGui Integration Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Configures the build to integrate with ImGui if `OMATH_IMGUI_INTEGRATION` is enabled. It links against the `imgui` target, assuming it's either a submodule or found via `find_package`. If ImGui is a submodule, it also handles its installation. ```cmake if (OMATH_IMGUI_INTEGRATION) target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_IMGUI_INTEGRATION) # IMGUI is being linked as submodule if (TARGET imgui) target_link_libraries(${PROJECT_NAME} PUBLIC imgui) install(TARGETS imgui EXPORT omathTargets ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) else () # Assume that IMGUI linked via VCPKG. find_package(imgui CONFIG REQUIRED) target_link_libraries(${PROJECT_NAME} PUBLIC imgui::imgui) endif () endif () ``` -------------------------------- ### Export CMake Targets for find_package Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Configures the installation of CMake export files, specifically `${PROJECT_NAME}Targets.cmake`. This enables other CMake projects to find and use the omath library via the `find_package` command, facilitating dependency management. ```cmake # Export omath target for CMake find_package support, also under omath_component install(EXPORT ${PROJECT_NAME}Targets FILE ${PROJECT_NAME}Targets.cmake NAMESPACE ${PROJECT_NAME}:: DESTINATION lib/cmake/${PROJECT_NAME} COMPONENT ${PROJECT_NAME}) ``` -------------------------------- ### Define Project Include Directories Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Sets the include directories for the omath project. It uses CMake's generator expressions to specify different include paths for when the project is being built versus when it is installed, ensuring proper header resolution in both scenarios. ```cmake target_include_directories(${PROJECT_NAME} PUBLIC $ # Use this path when building the project $ # Use this path when the project is installed ) ``` -------------------------------- ### CMake Configuration for C++ Unit Tests Source: https://github.com/orange-cpp/omath/blob/main/tests/CMakeLists.txt This snippet sets up a C++ project for unit testing with Google Test. It enables testing, defines the project, includes the GoogleTest module, finds all .cpp files in the current directory for tests, and creates an executable target for the tests. It also configures output directories, enables Unity Build, sets the C++ standard to 23, and links against gtest, gtest_main, and the 'omath::omath' library. Finally, it discovers tests within the built executable. ```cmake enable_testing() project(unit_tests) include(GoogleTest) file(GLOB_RECURSE UNIT_TESTS_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp") add_executable(${PROJECT_NAME} ${UNIT_TESTS_SOURCES}) set_target_properties(unit_tests PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}" UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 20 CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON) target_link_libraries(${PROJECT_NAME} PRIVATE gtest gtest_main omath::omath) gtest_discover_tests(${PROJECT_NAME}) ``` -------------------------------- ### Build OMath using CMake Source: https://github.com/orange-cpp/omath/blob/main/CONTRIBUTING.md Builds the OMath project using CMake with a specified build directory, target, and number of parallel jobs. Assumes a release build configuration for Windows. ```bash cmake --build cmake-build/build/windows-release --target omath -j 6 ``` -------------------------------- ### World to Screen Transformation in C++ Source: https://github.com/orange-cpp/omath/blob/main/writerside/topics/starter-topic.md Demonstrates converting a 3D world coordinate to a 2D screen coordinate using the omath::projection::Camera class. It checks if the projected point falls within the screen's view. ```c++ TEST(UnitTestProjection, IsPointOnScreen) { const omath::projection::Camera camera({0.f, 0.f, 0.f}, {0, 0.f, 0.f} , {1920.f, 1080.f}, 110.f, 0.1f, 500.f); const auto proj = camera.WorldToScreen({100, 0, 15}); EXPECT_TRUE(proj.has_value()); } ``` -------------------------------- ### OMath Target Properties Configuration Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Sets various properties for the OMath target, including output directories for archives and libraries, and enforces C++23 standard compliance. It also configures Unity build settings if enabled. ```cmake set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}" CXX_STANDARD 23 CXX_STANDARD_REQUIRED ON) if (OMATH_USE_UNITY_BUILD) set_target_properties(${PROJECT_NAME} PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE 20) endif () ``` -------------------------------- ### OMath Source and Header Discovery Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Uses `file(GLOB_RECURSE ...)` to find all `.cpp` source files and `.hpp` header files within the respective 'source' and 'include' directories. `CONFIGURE_DEPENDS` ensures that CMake re-runs file globbing if new files are added during the configuration phase. ```cmake file(GLOB_RECURSE OMATH_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp") file(GLOB_RECURSE OMATH_HEADERS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp") ``` -------------------------------- ### OMath MSVC Runtime Library Configuration Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt When `OMATH_STATIC_MSVC_RUNTIME_LIBRARY` is enabled, this sets the MSVC runtime library to be statically linked, ensuring consistent behavior across different build configurations. ```cmake if (OMATH_STATIC_MSVC_RUNTIME_LIBRARY) set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" ) endif () ``` -------------------------------- ### Generate omathConfig.cmake Files Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Generates the `omathConfig.cmake` and `omathConfigVersion.cmake` files, which are essential for CMake's `find_package` mechanism. It uses `write_basic_package_version_file` and `configure_package_config_file` to create these files from templates and project version information. ```cmake # Generate the omathConfigVersion.cmake file write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion ) # Generate the omathConfig.cmake file from the template (which is in the cmake/ folder) configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/omathConfig.cmake.in" # Path to the .in file "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" # Output path for the generated file INSTALL_DESTINATION lib/cmake/${PROJECT_NAME} ) # Install the generated config files install(FILES "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" DESTINATION lib/cmake/${PROJECT_NAME}) ``` -------------------------------- ### OMath AVX2 Compiler Options Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt For Clang compilers, this targets specifically enables AVX2 and FMA instructions to optimize performance, provided the `OMATH_USE_AVX2` option is not explicitly disabled. ```cmake if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_options(${PROJECT_NAME} PRIVATE -mavx2 -mfma) endif () ``` -------------------------------- ### Handle Windows SDK NOMINMAX Conflict Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt This snippet conditionally defines NOMINMAX for MSVC compilers to prevent conflicts between the Windows SDK's min/max macros and `std::min`/`std::max`. It ensures the project compiles correctly on Windows. ```cmake if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_definitions(${PROJECT_NAME} INTERFACE NOMINMAX) endif () ``` -------------------------------- ### OMath Feature Compile Definitions Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Conditionally defines preprocessor macros for features like AVX2, suppressed safety checks, and legacy support based on the project's configuration options. ```cmake if (OMATH_USE_AVX2) target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_USE_AVX2) endif () if (OMATH_SUPRESS_SAFETY_CHECKS) target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_SUPRESS_SAFETY_CHECKS) endif () if (OMATH_ENABLE_LEGACY) target_compile_options(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY) endif () ``` -------------------------------- ### OMath Compiler Warning Handling Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Configures compiler warning levels. For MSVC, it sets `/W4` and `/WX` (treat warnings as errors). For other compilers (like GCC/Clang), it uses `-Wall -Wextra -Wpedantic -Werror` if `OMATH_THREAT_WARNING_AS_ERROR` is enabled. ```cmake if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND OMATH_THREAT_WARNING_AS_ERROR) target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX) elseif (OMATH_THREAT_WARNING_AS_ERROR) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror) endif () ``` -------------------------------- ### OMath Library Target Definition Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Defines the main OMath library target, either as SHARED or STATIC based on the `OMATH_BUILD_AS_SHARED_LIBRARY` option. It then creates an ALIAS target for convenient referencing. Public compile definitions for version and feature flags are set. ```cmake if (OMATH_BUILD_AS_SHARED_LIBRARY) add_library(${PROJECT_NAME} SHARED ${OMATH_SOURCES} ${OMATH_HEADERS}) else () add_library(${PROJECT_NAME} STATIC ${OMATH_SOURCES} ${OMATH_HEADERS}) endif () add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_VERSION="${PROJECT_VERSION}") ``` -------------------------------- ### OMath C++ Standard Feature Source: https://github.com/orange-cpp/omath/blob/main/CMakeLists.txt Explicitly declares the usage of the C++23 standard features for the OMath target, ensuring compiler support and adherence to the standard. ```cmake target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.