### Axmol Basic Project Setup Source: https://github.com/axmolengine/axmol/blob/dev/docs/DevSetup.md The minimal workflow for starting a new Axmol project involves running the setup script, creating a new project, and then building it. ```bash ./setup.ps1 ``` ```bash axmol new ``` ```bash axmol build ``` -------------------------------- ### Install Example Executables Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Conditionally installs the 'altonegen', 'alrecord', 'aldebug', and 'allafplay' targets if the 'ALSOFT_INSTALL_EXAMPLES' option is enabled. ```cmake if(ALSOFT_INSTALL_EXAMPLES) install(TARGETS altonegen alrecord aldebug allafplay) endif() ``` -------------------------------- ### Install the Project Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/freetype/CMakeLists.txt Installs the built project files. Use with sudo if installing to a system-wide location. ```bash (sudo) cmake --build build --target install ``` -------------------------------- ### Run Axmol Setup Script Source: https://github.com/axmolengine/axmol/blob/dev/docs/DevSetup.md Execute the setup script to install dependencies and configure environment variables. A terminal restart is required after completion. ```pwsh ./setup.ps1 ``` -------------------------------- ### Conditional Installation of Example Targets Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs specified OpenAL example targets (alplay, alstream, alreverb, almultireverb, allatency, alhrtf, aldirect) only if the ALSOFT_INSTALL_EXAMPLES option is enabled. ```cmake if(ALSOFT_INSTALL_EXAMPLES) install(TARGETS alplay alstream alreverb almultireverb allatency alhrtf aldirect) endif() ``` -------------------------------- ### Add Examples Subdirectory Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/CMakeLists.txt Adds the examples subdirectory if GLFW_BUILD_EXAMPLES is ON. ```cmake if (GLFW_BUILD_EXAMPLES) add_subdirectory(examples) endif() ``` -------------------------------- ### Install OpenAL Soft using vcpkg Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/README.md Steps to clone the vcpkg repository, bootstrap it, integrate it with your system, and then install openal-soft. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install openal-soft ``` -------------------------------- ### Install OpenAL Sample Configuration Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs a sample configuration file for OpenAL if the corresponding build option is enabled. ```cmake if(ALSOFT_INSTALL_CONFIG) install(FILES alsoftrc.sample DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) message(STATUS "Installing sample configuration") endif() ``` -------------------------------- ### Build Examples Option Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/CMakeLists.txt Configures whether to build the GLFW example programs. Defaults to the value of GLFW_STANDALONE. ```cmake option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE}) ``` -------------------------------- ### Install alloopback Target Conditionally Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs the 'alloopback' target if the ALSOFT_INSTALL_EXAMPLES option is enabled. ```cmake if(ALSOFT_INSTALL_EXAMPLES) install(TARGETS alloopback) endif() ``` -------------------------------- ### Utility and Example Dependencies Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt This section manages dependencies for utility and example builds. It finds packages like MySOFA, Qt6Widgets, SndFile, and FFmpeg based on build options. ```cmake if(ALSOFT_UTILS) find_package(MySOFA) if(NOT ALSOFT_NO_CONFIG_UTIL) find_package(Qt6Widgets QUIET) if(NOT Qt6Widgets_FOUND) message(STATUS "Could NOT find Qt6Widgets") endif() endif() endif() if(ALSOFT_UTILS OR ALSOFT_EXAMPLES) find_package(SndFile) endif() if(ALSOFT_EXAMPLES AND SDL3_FOUND) find_package(FFmpeg COMPONENTS AVFORMAT AVCODEC AVUTIL SWSCALE SWRESAMPLE) endif() ``` -------------------------------- ### Install OpenAL Library and Headers Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Configures and installs the main OpenAL library and header files. It handles different CMake versions and installation destinations. ```cmake if(ALSOFT_INSTALL) configure_package_config_file(OpenALConfig.cmake.in OpenALConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL) if(CMAKE_VERSION GREATER_EQUAL 3.23) install(TARGETS OpenAL EXPORT OpenAL FILE_SET public_headers FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL) else() install(TARGETS OpenAL EXPORT OpenAL FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/AL) install(DIRECTORY include/AL TYPE INCLUDE) endif() export(TARGETS OpenAL NAMESPACE OpenAL:: FILE OpenALTargets.cmake) install(EXPORT OpenAL DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL NAMESPACE OpenAL:: FILE OpenALTargets.cmake) install(FILES "${OpenAL_BINARY_DIR}/openal.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES "${OpenAL_BINARY_DIR}/OpenALConfig.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/OpenAL") if(TARGET soft_oal) install(TARGETS soft_oal) endif() message(STATUS "Installing library and headers") else() message(STATUS "NOT installing library and headers") endif() ``` -------------------------------- ### Generate Installation Target Option Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/CMakeLists.txt Configures whether to generate an installation target for the project. Defaults to ON. ```cmake option(GLFW_INSTALL "Generate installation target" ON) ``` -------------------------------- ### Setup Application Configuration Source: https://github.com/axmolengine/axmol/blob/dev/tests/cpp-tests/CMakeLists.txt Applies application-specific configurations, such as setting up configuration files and properties. ```cmake ax_setup_app_config(${APP_NAME}) ``` -------------------------------- ### Install GLFW Targets Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/src/CMakeLists.txt Installs the GLFW target (library) to the appropriate runtime, archive, and library directories based on CMake installation prefixes when GLFW_INSTALL is enabled. ```cmake if (GLFW_INSTALL) install(TARGETS glfw EXPORT glfwTargets RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### Install alffplay Target Conditionally Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs the 'alffplay' target if the ALSOFT_INSTALL_EXAMPLES option is enabled. ```cmake if(ALSOFT_INSTALL_EXAMPLES) install(TARGETS alffplay) endif() ``` -------------------------------- ### Configure CMake Installation Directories Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/CMakeLists.txt Sets installation directories for CMake configuration files, libraries, and pkgconfig files. These paths are relative and joined with the installation prefix. ```cmake if (FMT_INSTALL) include(CMakePackageConfigHelpers) set_verbose(FMT_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/fmt CACHE STRING "Installation directory for cmake files, a relative path that " "will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute " "path.") set(version_config ${PROJECT_BINARY_DIR}/fmt-config-version.cmake) set(project_config ${PROJECT_BINARY_DIR}/fmt-config.cmake) set(pkgconfig ${PROJECT_BINARY_DIR}/fmt.pc) set(targets_export_name fmt-targets) set_verbose(FMT_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Installation directory for libraries, a relative path that " "will be joined to ${CMAKE_INSTALL_PREFIX} or an absolute path.") set_verbose(FMT_PKGCONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig CACHE STRING "Installation directory for pkgconfig (.pc) files, a relative " "path that will be joined with ${CMAKE_INSTALL_PREFIX} or an " "absolute path.") # Generate the version, config and target files into the build directory. write_basic_package_version_file( ${version_config} VERSION ${FMT_VERSION} COMPATIBILITY AnyNewerVersion) join_paths(libdir_for_pc_file "\${exec_prefix}" "${FMT_LIB_DIR}") join_paths(includedir_for_pc_file "\${prefix}" "${FMT_INC_DIR}") configure_file( "${PROJECT_SOURCE_DIR}/support/cmake/fmt.pc.in" "${pkgconfig}" @ONLY) configure_package_config_file( ${PROJECT_SOURCE_DIR}/support/cmake/fmt-config.cmake.in ${project_config} INSTALL_DESTINATION ${FMT_CMAKE_DIR}) set(INSTALL_TARGETS fmt fmt-header-only) set(INSTALL_FILE_SET) if (FMT_USE_CMAKE_MODULES) set(INSTALL_FILE_SET FILE_SET fmt DESTINATION "${FMT_INC_DIR}/fmt") endif() # Install the library and headers. install(TARGETS ${INSTALL_TARGETS} COMPONENT fmt_core EXPORT ${targets_export_name} LIBRARY DESTINATION ${FMT_LIB_DIR} ARCHIVE DESTINATION ${FMT_LIB_DIR} PUBLIC_HEADER DESTINATION "${FMT_INC_DIR}/fmt" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ${INSTALL_FILE_SET}) # Use a namespace because CMake provides better diagnostics for namespaced # imported targets. export(TARGETS ${INSTALL_TARGETS} NAMESPACE fmt:: FILE ${PROJECT_BINARY_DIR}/${targets_export_name}.cmake) # Install version, config and target files. install(FILES ${project_config} ${version_config} DESTINATION ${FMT_CMAKE_DIR} COMPONENT fmt_core) install(EXPORT ${targets_export_name} DESTINATION ${FMT_CMAKE_DIR} NAMESPACE fmt:: COMPONENT fmt_core) install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}" COMPONENT fmt_core) endif () ``` -------------------------------- ### Add Subdirectories for Source, Tests, and Examples Source: https://github.com/axmolengine/axmol/blob/dev/extensions/Effekseer/3rdParty/LLGI/CMakeLists.txt Includes subdirectories for the main source code, unit tests, and examples based on build flags. ```cmake add_subdirectory("src") if(BUILD_TEST) add_subdirectory("src_test") endif() if(BUILD_EXAMPLE) add_subdirectory("examples") endif() if(BUILD_TOOL) ``` -------------------------------- ### Define Library Name and Project Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/angle/CMakeLists.txt Sets the library name and initializes the project. This is a standard CMake setup. ```cmake set(lib_name angle) project(${lib_name}) ``` -------------------------------- ### NuGet Package Installation for Windows Source: https://github.com/axmolengine/axmol/blob/dev/axmol/CMakeLists.txt Handles the installation of NuGet packages like CppWinRT and WebView2 for Windows development. Includes checks for nuget.exe and conditional linking based on the CMake generator. ```cmake if(WINDOWS) # cppwinrt or webview2 require nuget if(WINDOWS_STORE OR AX_ENABLE_MSEDGE_WEBVIEW2) find_program(NUGET_EXE NAMES nuget PATHS "$ENV{AX_ROOT}/tools/external/nuget") if(NOT NUGET_EXE) message("NUGET.EXE not found.") message(FATAL_ERROR "Please run setup.ps1 again to download NUGET.EXE, and run CMake again.") endif() endif() if(WINDOWS_STORE) configure_file(${_AX_ROOT}/cmake/CppWinRT.props.in ${CMAKE_BINARY_DIR}/CppWinRT.props @ONLY) # intsall cppwinrt package for xaml apps execute_process(COMMAND "${NUGET_EXE}" install "Microsoft.Windows.CppWinRT" -Version ${AX_CPPWINRT_VERSION} -ExcludeVersion -OutputDirectory "${_NUGET_PACKAGE_DIR}") set_target_properties(${_AX_CORE_LIB} PROPERTIES VS_PROJECT_IMPORT "${_NUGET_PACKAGE_DIR}/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.props" ) target_link_libraries(${_AX_CORE_LIB} "${_NUGET_PACKAGE_DIR}/Microsoft.Windows.CppWinRT/build/native/Microsoft.Windows.CppWinRT.targets") endif() if(AX_ENABLE_MSEDGE_WEBVIEW2) execute_process(COMMAND "${NUGET_EXE}" install "Microsoft.Web.WebView2" -Version ${AX_MSEDGE_WEBVIEW2_VERSION} -ExcludeVersion -OutputDirectory "${_NUGET_PACKAGE_DIR}") if(CMAKE_GENERATOR MATCHES "Ninja") target_link_libraries(${_AX_CORE_LIB} "${_NUGET_PACKAGE_DIR}/Microsoft.Web.WebView2/build/native/${ARCH_ALIAS}/WebView2Loader.dll.lib") target_include_directories(${_AX_CORE_LIB} PUBLIC "${_NUGET_PACKAGE_DIR}/Microsoft.Web.WebView2/build/native/include") else() target_link_libraries(${_AX_CORE_LIB} "${_NUGET_PACKAGE_DIR}/Microsoft.Web.WebView2/build/native/Microsoft.Web.WebView2.targets") endif() endif() endif() ``` -------------------------------- ### Install OpenAL AmbDec Presets Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs Ambisonic Decoder (AmbDec) presets for OpenAL if the build option is enabled. ```cmake if(ALSOFT_INSTALL_AMBDEC_PRESETS) install(DIRECTORY presets DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) message(STATUS "Installing AmbDec presets") endif() ``` -------------------------------- ### Create a New Axmol Project Source: https://github.com/axmolengine/axmol/blob/dev/tools/cmdline/README.md Use this command to start a new project with specified language and package name. Navigate into the project directory afterwards. ```bash $ axmol new MyGame -l cpp -p dev.axmol.mygame $ cd MyGame ``` -------------------------------- ### Add 'alrecord' Example Executable Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'alrecord' executable target, linking it with linker flags, the common example library, and Unicode support. ```cmake add_executable(alrecord examples/alrecord.c) target_link_libraries(alrecord PRIVATE ${LINKER_FLAGS} alsoft.excommon ${UNICODE_FLAG}) set_target_properties(alrecord PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alrecord.c") ``` -------------------------------- ### Install NDK r23d for Axmol Source: https://github.com/axmolengine/axmol/wiki/Update-guide-to-v2.3.0-for-Android Run this command from the Axmol root folder to install NDK r23d if you encounter the 'No installed ndk found, required 23.3.*' error. This version is not available through the Android Studio SDK Manager. ```bash ./setup.ps1 -p android ``` -------------------------------- ### Add 'altonegen' Example Executable Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'altonegen' executable target, linking it with essential flags, the math library, the common example library, and Unicode support. ```cmake add_executable(altonegen examples/altonegen.c) target_link_libraries(altonegen PRIVATE ${LINKER_FLAGS} ${MATH_LIB} alsoft.excommon ${UNICODE_FLAG}) set_target_properties(altonegen PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/altonegen.c") ``` -------------------------------- ### Install GLFW Headers and Configuration Files Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/CMakeLists.txt Installs GLFW header files and CMake configuration files to the appropriate system directories. This ensures that projects using GLFW can find its headers and CMake modules. ```cmake install(DIRECTORY include/GLFW DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h) install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake" "${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake" DESTINATION "${GLFW_CONFIG_PATH}") ``` -------------------------------- ### Format Subseconds with fmt/chrono Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/ChangeLog.md This example demonstrates formatting subseconds using the `{:%S}` specifier with `fmt/chrono`. It shows how to format microseconds. ```cpp #include int main() { // prints 01.234567 fmt::print("{:%S} ", std::chrono::microseconds(1234567)); } ``` -------------------------------- ### Install Headers Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/freetype/CMakeLists.txt Installs FreeType headers, excluding internal and configuration files, to the appropriate directory. Requires `SKIP_INSTALL_HEADERS` and `SKIP_INSTALL_ALL` to be false. ```cmake include(GNUInstallDirs) if (NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) install( # Note the trailing slash in the argument to `DIRECTORY'! DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2 COMPONENT headers PATTERN "internal" EXCLUDE PATTERN "ftconfig.h" EXCLUDE PATTERN "ftoption.h" EXCLUDE) install( FILES ${PROJECT_BINARY_DIR}/include/freetype/config/ftconfig.h ${PROJECT_BINARY_DIR}/include/freetype/config/ftoption.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/freetype2/freetype/config COMPONENT headers) endif () ``` -------------------------------- ### Add Executable for alloopback Example Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Adds the 'alloopback' executable using the 'alloopback.c' source file. It links against SDL3, alsoft.excommon, and MATH_LIB, with properties set via ALSOFT_STD_VERSION_PROPS. ```cmake add_executable(alloopback examples/alloopback.c) target_link_libraries(alloopback PRIVATE ${LINKER_FLAGS} SDL3::SDL3 alsoft.excommon ${MATH_LIB}) set_target_properties(alloopback PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alloopback.c") ``` -------------------------------- ### Write to a file with fmtlib Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/README.md Example of writing to a file using fmt::output_file for efficient single-threaded output. ```c++ #include int main() { auto out = fmt::output_file("guide.txt"); out.print("Don't {}", "Panic"); } ``` -------------------------------- ### Install GLFW Export and Pkg-config Files Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/CMakeLists.txt Installs the CMake export file for GLFW targets and the pkg-config file. These are necessary for other build systems and tools to correctly link against and identify the GLFW library. ```cmake install(EXPORT glfwTargets FILE glfw3Targets.cmake EXPORT_LINK_INTERFACE_LIBRARIES DESTINATION "${GLFW_CONFIG_PATH}") install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") ``` -------------------------------- ### Print dates and times with fmtlib Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/README.md Example of formatting and printing current date and time using fmt::chrono. ```c++ #include int main() { auto now = std::chrono::system_clock::now(); fmt::print("Date and time: {} ", now); fmt::print("Time: {:%H:%M} ", now); } ``` -------------------------------- ### Implementation Comment Example Source: https://github.com/axmolengine/axmol/blob/dev/docs/CODING_STYLE.md Use implementation comments to explain tricky, non-obvious, or important parts of the code logic. ```cpp // Divide result by two, taking into account that x // contains the carry from the add. for (int i = 0; i < result->size(); i++) { x = (x << 8) + (*result)[i]; (*result)[i] = x >> 1; x &= 1; } ``` -------------------------------- ### Add 'almultireverb' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'almultireverb' executable, linking it with linker flags, the SndFile library, the common example library, the math library, and Unicode support. This target is created only if sndfile is found. ```cmake add_executable(almultireverb examples/almultireverb.c) target_link_libraries(almultireverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${MATH_LIB} ${UNICODE_FLAG}) set_target_properties(almultireverb PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/almultireverb.c") ``` -------------------------------- ### Set up App Configuration Source: https://github.com/axmolengine/axmol/blob/dev/tests/unit-tests/CMakeLists.txt Initializes the application configuration, specifying the app name and console output. ```cmake ax_setup_app_config(${APP_NAME} CONSOLE) ``` -------------------------------- ### C++ Class and Type Naming Examples Source: https://github.com/axmolengine/axmol/blob/dev/docs/CODING_STYLE.md Demonstrates the naming convention for C++ classes, structs, typedefs, and enums. Type names should start with a capital letter and use capital letters for each new word, without underscores. ```cpp // classes and structs class UrlTable { ... class UrlTableTester { ... struct UrlTableProperties { ... // typedefs typedef hash_map PropertiesMap; // enums enum UrlTableErrors { ... ``` -------------------------------- ### Build OpenAL Info Utility Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Compiles the 'openal-info' utility, which provides information about the OpenAL installation. It links against necessary libraries and flags. ```cmake if(ALSOFT_UTILS) add_executable(openal-info utils/openal-info.c) target_include_directories(openal-info PRIVATE ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) target_compile_options(openal-info PRIVATE ${C_FLAGS}) target_link_libraries(openal-info PRIVATE Threads::Threads ${LINKER_FLAGS} OpenAL ${UNICODE_FLAG}) set_target_properties(openal-info PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/utils/openal-info.c") if(ALSOFT_INSTALL_UTILS) install(TARGETS openal-info) endif() ``` -------------------------------- ### Install alsort-config Target Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs the 'alsoft-config' target if the ALSOFT_INSTALL_UTILS flag is enabled. This makes the configuration utility available after installation. ```cmake if(ALSOFT_INSTALL_UTILS) install(TARGETS alsoft-config) endif() ``` -------------------------------- ### Install Box2D Library Targets Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/box2d/src/CMakeLists.txt Installs the Box2D library targets, including shared libraries, static archives, and runtime binaries, to their designated installation directories. ```cmake install( TARGETS box2d EXPORT box2dConfig LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Fetch and Link Sample Assets Source: https://github.com/axmolengine/axmol/blob/dev/tests/cpp-tests/CMakeLists.txt Fetches sample assets using the '_1kfetch' command and then links them to the specified content directory. This ensures test assets are available. ```cmake _1kfetch(sample-assets) _1klink("${sample-assets_SOURCE_DIR}/cpp-tests/Content" "${CMAKE_CURRENT_LIST_DIR}/Content") ``` -------------------------------- ### Fetch and Set Up VLC Library Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/vlc/CMakeLists.txt Fetches the VLC development library zip archive based on the operating system and sets up the project name. This is a prerequisite for defining VLC targets. ```cmake set(lib_name vlc) project(${lib_name}) if(WIN32) set(vlc_suffix win) elseif(LINUX) set(vlc_suffix linux) else() message(FATAL_ERROR "axmol not built vlc for current platform: ${CMAKE_SYSTEM_NAME}") endif() _1kfetch("https://github.com/halx99/build-vlc/releases/download/v3.0.18/libvlc-dev-${vlc_suffix}.zip" NAME vlc) ``` -------------------------------- ### Setting OpenAL Installation Paths Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines installation directories for OpenAL components based on CMake variables. ```cmake set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "${prefix}") set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") set(bindir "${CMAKE_INSTALL_FULL_BINDIR}") set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") set(PACKAGE_VERSION "${OpenAL_VERSION}") set(PKG_CONFIG_CFLAGS ) set(PKG_CONFIG_PRIVATE_LIBS ) ``` -------------------------------- ### Standard Include Order Example Source: https://github.com/axmolengine/axmol/blob/dev/docs/CODING_STYLE.md Follow this order for includes: C system files, C++ system files, other libraries' headers, and finally your project's headers. This helps catch missing dependencies early. ```cpp #include "base/logging.h" ``` ```cpp #include "sprite_nodes/CCSprite.h" #include #include #include #include #include "base/basictypes.h" #include "base/commandlineflags.h" #include "foo/public/bar.h" ``` -------------------------------- ### Experimental fmt::writer API Example Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/ChangeLog.md Demonstrates the experimental fmt::writer API for writing to different destinations like files, stdout, and strings. Requires including . ```c++ #include void write_text(fmt::writer w) { w.print("The answer is {}.", 42); } int main() { // Write to FILE. write_text(stdout); // Write to fmt::ostream. auto f = fmt::output_file("myfile"); write_text(f); // Write to std::string. auto sb = fmt::string_buffer(); write_text(sb); std::string s = sb.str(); } ``` -------------------------------- ### View All Configuration Options Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/freetype/CMakeLists.txt Lists all available CMake configuration options for the project. Use this to discover and set various build parameters. ```bash cmake -LAH ``` -------------------------------- ### Build Documentation Option Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glfw/CMakeLists.txt Configures whether to build the GLFW documentation. Defaults to ON. ```cmake option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) ``` -------------------------------- ### Install OpenAL HRTF Data Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Installs HRTF (Head-Related Transfer Function) data files for OpenAL if the build option is enabled. ```cmake if(ALSOFT_INSTALL_HRTF_DATA) install(DIRECTORY hrtf DESTINATION ${CMAKE_INSTALL_DATADIR}/openal) message(STATUS "Installing HRTF data files") endif() ``` -------------------------------- ### Core Library Setup and Properties Source: https://github.com/axmolengine/axmol/blob/dev/axmol/CMakeLists.txt Configures include directories, output paths, and version for the core Axmol library. Sets properties for archive, library, and runtime output directories. ```cmake use_ax_depend(${_AX_CORE_LIB}) target_include_directories(${_AX_CORE_LIB} PUBLIC ${_AX_ROOT} PUBLIC ${_AX_ROOT}/3rdparty ) set_target_properties(${_AX_CORE_LIB} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" VERSION "${_AX_VERSION}" FOLDER "Engine" ) ``` -------------------------------- ### Install Box2D Package Version File Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/box2d/src/CMakeLists.txt Installs the generated Box2D package version configuration file to the CMake package directory. ```cmake install( FILES "${CMAKE_CURRENT_BINARY_DIR}/box2dConfigVersion.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/box2d" ) ``` -------------------------------- ### Switch Third-Party Mirror (Older Versions) Source: https://github.com/axmolengine/axmol/wiki/FAQ For Axmol versions less than or equal to axmol-v3-416aaec, create an empty file named .gitee in the 1k directory to switch to a Gitee mirror. ```bash touch 1k/.gitee ``` -------------------------------- ### Run the 'new' Plugin Source: https://github.com/axmolengine/axmol/blob/dev/tools/cmdline/README.md Executes the 'new' plugin, typically used for creating new projects. ```bash $ axmol new ``` -------------------------------- ### Clone and Configure Benchmark Repository Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/README.md Clone the format-benchmark repository and configure it using CMake to prepare for running benchmarks. ```bash git clone --recursive https://github.com/fmtlib/format-benchmark.git cd format-benchmark cmake . ``` -------------------------------- ### Install Box2D API Header Files Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/box2d/src/CMakeLists.txt Installs the Box2D API header files to the include directory, making them available for projects that depend on Box2D. ```cmake install( FILES ${BOX2D_API_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/box2d ) ``` -------------------------------- ### Configure Default Static Library Build Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/freetype/CMakeLists.txt Creates a build directory and configures the project to build as a static library with default parameters. Use this for a standard build setup. ```bash cmake -B build ``` -------------------------------- ### Set Application Properties Source: https://github.com/axmolengine/axmol/blob/dev/tests/unit-tests/CMakeLists.txt Applies general application properties using the ax_setup_app_props macro. ```cmake ax_setup_app_props(${APP_NAME}) ``` -------------------------------- ### Project Initialization and Include Directories Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/CMakeLists.txt Initializes the project named 'FMT' for C++ and sets the installation directory for include files. This configuration is essential for managing project structure and dependencies. ```cmake project(FMT CXX) include(GNUInstallDirs) set_verbose(FMT_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Installation directory for include files, a relative path that " "will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.") ``` -------------------------------- ### Example Fragment Shader in Axmol 2.0+ Source: https://github.com/axmolengine/axmol/wiki/Shaders-in-Axmol This is an example of a fragment shader for Axmol 2.0+. It uses ESSL v310, defines input variables, and samples a texture. ```glsl #version 310 es precision highp float; precision highp int; layout(location = 0) in vec2 v_texCoord; layout(binding = 0) uniform sampler2D u_tex0; layout(location = 0) out vec4 FragColor; void main() { FragColor = texture(u_tex0, v_texCoord); } ``` -------------------------------- ### Initialize Project Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/glad/CMakeLists.txt Initializes the CMake project for the GLAD target. ```cmake project(${target_name}) ``` -------------------------------- ### Install Box2D CMake Configuration Export Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/box2d/src/CMakeLists.txt Installs the CMake configuration export files for the Box2D package, enabling other projects to find and use Box2D via CMake. ```cmake install( EXPORT box2dConfig NAMESPACE box2d:: DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/box2d" ) ``` -------------------------------- ### Create Spawn and Sequence Actions Source: https://github.com/axmolengine/axmol/wiki/Introduction-to-Game-Dev-using-Axmol Use Spawn to run actions simultaneously and Sequence to run them one after another. Actions must be terminated with nullptr. ```cpp auto simultaneousActions = Spawn::create(action1, action2, action3, nullptr); auto mySequence = Sequence::create(action1, action2, action3, nullptr); ``` -------------------------------- ### GargantuanTableIterator Class Comment Example Source: https://github.com/axmolengine/axmol/blob/dev/docs/CODING_STYLE.md Example of a class comment that provides sample usage and notes synchronization assumptions. Use this style for classes where multithreaded access is a concern. ```cpp // Iterates over the contents of a GargantuanTable. Sample usage: // GargantuanTableIterator* iter = table->NewIterator(); // for (iter->Seek("foo"); !iter->done(); iter->Next()) { // process(iter->key(), iter->value()); // } // delete iter; class GargantuanTableIterator { ... }; ``` -------------------------------- ### Format string with fmtlib Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/README.md Demonstrates formatting a string with an integer argument using fmt::format. ```c++ std::string s = fmt::format("The answer is {}.", 42); // s == "The answer is 42." ``` -------------------------------- ### Example Vertex Shader in Axmol 2.0+ Source: https://github.com/axmolengine/axmol/wiki/Shaders-in-Axmol This is an example of a vertex shader written for Axmol 2.0+. It uses ESSL v310 and defines input/output variables and a uniform buffer for the MVP matrix. ```glsl #version 310 es layout(location = 0) in vec4 a_position; layout(location = 1) in vec2 a_texCoord; layout(location = 0) out vec2 v_texCoord; layout(std140) uniform vs_ub { mat4 u_MVPMatrix; }; void main() { gl_Position = u_MVPMatrix * a_position; v_texCoord = a_texCoord; } ``` -------------------------------- ### Configure Include Directories Source: https://github.com/axmolengine/axmol/blob/dev/extensions/fairygui/CMakeLists.txt Sets up public and interface include directories for the 'fairygui' target, specifying source paths. ```cmake target_include_directories(${target_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(${target_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/fairygui INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/fairygui ) ``` -------------------------------- ### Add 'allatency' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'allatency' executable, linking it with linker flags, the SndFile library, the common example library, and Unicode support. This target is created only if sndfile is found. ```cmake add_executable(allatency examples/allatency.c) target_link_libraries(allatency PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${UNICODE_FLAG}) set_target_properties(allatency PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/allatency.c") ``` -------------------------------- ### Print with colors and text styles using fmtlib Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/README.md Demonstrates using fmtlib to print text with foreground color, background color, and text emphasis (bold, underline, italic). ```c++ #include int main() { fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold, "Hello, {}!\n", "world"); fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | fmt::emphasis::underline, "Olá, {}!\n", "Mundo"); fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, "你好{}!\n", "世界"); } ``` -------------------------------- ### Add 'alreverb' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'alreverb' executable, linking it with linker flags, the SndFile library, the common example library, and Unicode support. This target is created only if sndfile is found. ```cmake add_executable(alreverb examples/alreverb.c) target_link_libraries(alreverb PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${UNICODE_FLAG}) set_target_properties(alreverb PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alreverb.c") ``` -------------------------------- ### Add 'alstream' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'alstream' executable, linking it with linker flags, the SndFile library, the common example library, and Unicode support. This target is created only if sndfile is found. ```cmake add_executable(alstream examples/alstream.c) target_link_libraries(alstream PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${UNICODE_FLAG}) set_target_properties(alstream PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alstream.c") ``` -------------------------------- ### Add 'alplay' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'alplay' executable, linking it with linker flags, the SndFile library, the common example library, and Unicode support. This target is created only if sndfile is found. ```cmake if(SNDFILE_FOUND) add_executable(alplay examples/alplay.c) target_link_libraries(alplay PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${UNICODE_FLAG}) set_target_properties(alplay PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alplay.c") ``` -------------------------------- ### Applying Text Styles with fmt::styled Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/ChangeLog.md Demonstrates how to apply text styles (bold, color) to individual arguments using fmt::styled and color constants. This example also formats a std::chrono::system_clock::time_point. ```c++ #include #include int main() { auto now = std::chrono::system_clock::now(); fmt::print( "[\{\}] \{\}: \{\}\n", fmt::styled(now, fmt::emphasis::bold), fmt::styled("error", fg(fmt::color::red)), "something went wrong"); } ``` -------------------------------- ### Run Benchmark Tests Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/fmt/README.md Execute the speed or bloat tests after configuring the benchmark repository. Ensure the library is built separately. ```bash make speed-test ``` ```bash make bloat-test ``` -------------------------------- ### Add 'aldirect' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'aldirect' executable, linking it with the SndFile library, 'alsoft::common', the common example library, Unicode support, and the modules target. This target is created only if sndfile is found. ```cmake add_executable(aldirect examples/aldirect.cpp) target_link_libraries(aldirect PRIVATE SndFile::SndFile alsoft::common alsoft.excommon ${UNICODE_FLAG} ${MODULES_TARGET}) ``` -------------------------------- ### Add 'alstreamcb' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'alstreamcb' executable, linking it with the SndFile library, 'alsoft::common', the common example library, Unicode support, and the modules target. This target is created only if sndfile is found. ```cmake add_executable(alstreamcb examples/alstreamcb.cpp) target_link_libraries(alstreamcb PRIVATE SndFile::SndFile alsoft::common alsoft.excommon ${UNICODE_FLAG} ${MODULES_TARGET}) set_target_properties(alstreamcb PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alstreamcb.cpp") ``` -------------------------------- ### Run Axmol Project on Device Source: https://github.com/axmolengine/axmol/blob/dev/tools/cmdline/README.md Deploys the current project to a connected Android device and runs it. ```bash $ axmol run -p android ``` -------------------------------- ### Add 'alhrtf' Example Executable with sndfile Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines the 'alhrtf' executable, linking it with linker flags, the SndFile library, the common example library, the math library, and Unicode support. This target is created only if sndfile is found. ```cmake add_executable(alhrtf examples/alhrtf.c) target_link_libraries(alhrtf PRIVATE ${LINKER_FLAGS} SndFile::SndFile alsoft.excommon ${MATH_LIB} ${UNICODE_FLAG}) set_target_properties(alhrtf PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/alhrtf.c") ``` -------------------------------- ### Configure WebP Library Build Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/webp/CMakeLists.txt Sets up the WebP library build process using CMake. It defines the library name, finds source files, creates a static library, and configures include directories and compile definitions, including conditional definitions for SIMD optimizations. ```cmake set(lib_name webp) set(target_name ${lib_name}) project(${lib_name}) FILE(GLOB_RECURSE ${target_name}_src *.h;*.c) add_library(${target_name} STATIC ${${target_name}_src} ) target_include_directories(${target_name} PRIVATE "${CMAKE_CURRENT_LIST_DIR}") target_include_directories(${target_name} PUBLIC "${CMAKE_CURRENT_LIST_DIR}/src") target_compile_definitions(${target_name} PRIVATE HAVE_CONFIG_H=1) if(AX_ISA_SIMD MATCHES "neon") target_compile_definitions(${target_name} PRIVATE WEBP_HAVE_NEON=1) elseif(AX_ISA_SIMD MATCHES "avx2" OR AX_ISA_SIMD MATCHES "sse4") target_compile_definitions(${target_name} PRIVATE WEBP_HAVE_SSE2=1) target_compile_definitions(${target_name} PRIVATE WEBP_HAVE_SSE41=1) elseif(AX_ISA_SIMD MATCHES "sse2") target_compile_definitions(${target_name} PRIVATE WEBP_HAVE_SSE2=1) endif() ``` -------------------------------- ### Fragment Shader with Macro Layout Locations Source: https://github.com/axmolengine/axmol/wiki/Shaders-in-Axmol This fragment shader example uses macros for layout locations, aligning with the vertex shader example. It includes necessary precision declarations and defines an output color variable. ```glsl #version 310 es precision highp float; precision highp int; layout(location = TEXCOORD0) in vec2 v_texCoord; uniform sampler2D u_tex0; layout(location = SV_Target0) out vec4 FragColor; void main() { FragColor = texture(u_tex0, v_texCoord); } ``` -------------------------------- ### Axmol Object Creation and Lifecycle Example Source: https://github.com/axmolengine/axmol/wiki/Memory-Management Demonstrates the correct usage of `create`, `retain`, `release`, and `addChild` for managing Axmol object reference counts within a custom class. Ensure `retain` is called when storing a reference and `release` in the destructor. ```cpp class MyNode : public ax::Node { public: ~MyNode(); // destructor bool init() override; private: ax::Sprite* _mySprite = nullptr; } ``` ```cpp bool MyNode::init() // In current main loop cycle init() is called: { //... _mySprite = Sprite::create(); // _referenceCount = 1, added to auto-release pool _mySprite->retain(); // _referenceCount = 2 (in auto-release pool) addChild(_mySprite); // _referenceCount = 3 (in auto-release pool) //... } MyNode::~MyNode() // Destructor { if (_mySprite != nullptr) _mySprite->release(); // _referenceCount = _referenceCount - 1 } ``` -------------------------------- ### Get Tile GID and Sprite at Position Source: https://github.com/axmolengine/axmol/wiki/Tiled Access individual tiles within a tile layer by specifying their column and row. You can get the tile's Global ID (GID) to check if it exists, or retrieve the tile's sprite object. ```cpp Vec2 tilePosition = Vec2(1, 1); // column and row int tileGID = groundLayer->getTileGIDAt(tilePosition); // Get the Global ID of the tile in order to check if it's empty if (tileGID != 0) { auto tileSprite = groundLayer->getTileAt(tilePosition); // Do something with the tile } ``` -------------------------------- ### Switch Third-Party Mirror (Newer Versions) Source: https://github.com/axmolengine/axmol/wiki/FAQ For Axmol versions greater than axmol-v3-416aaec, use the echo command to set .active-mirror to atomgit to switch to an AtomGit mirror. ```bash echo atomgit >1k/.active-mirror ``` -------------------------------- ### Add Common Static Library for Examples Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Defines a static library 'alsoft.excommon' to hold common C/C++ source files used across multiple example executables. It sets up compile definitions, include directories, compile options, and links against necessary libraries like Threads and OpenAL. ```cmake if(ALSOFT_EXAMPLES) add_library(alsoft.excommon STATIC EXCLUDE_FROM_ALL examples/common/alhelpers.c examples/common/alhelpers.h examples/common/alhelpers.hpp) target_compile_definitions(alsoft.excommon PUBLIC ${CPP_DEFS}) target_include_directories(alsoft.excommon PUBLIC ${OpenAL_BINARY_DIR} ${OpenAL_SOURCE_DIR}/common) target_compile_options(alsoft.excommon PUBLIC ${C_FLAGS}) target_link_libraries(alsoft.excommon PUBLIC Threads::Threads OpenAL PRIVATE ${RT_LIB}) set_target_properties(alsoft.excommon PROPERTIES ${ALSOFT_STD_VERSION_PROPS}) list(APPEND NEED_ANALYZE_SOURCE_FILES "${OpenAL_SOURCE_DIR}/examples/common/alhelpers.c" "${OpenAL_SOURCE_DIR}/examples/common/alhelpers.h") endif() ``` -------------------------------- ### JACK Backend Check Source: https://github.com/axmolengine/axmol/blob/dev/3rdparty/openal/CMakeLists.txt Configures and checks for the JACK audio backend. It uses `find_package(JACK)` to locate the necessary components and adds JACK-specific sources and headers if found. ```cmake # Check JACK backend option(ALSOFT_BACKEND_JACK "Enable JACK backend" ON) option(ALSOFT_REQUIRE_JACK "Require JACK backend" OFF) if(ALSOFT_BACKEND_JACK) find_package(JACK) if(JACK_FOUND) set(HAVE_JACK 1) set(BACKENDS "${BACKENDS} JACK${IS_LINKED},") list(APPEND ALC_SRCS alc/backends/jack.cpp) list(APPEND ALC_HDRS alc/backends/jack.h) add_backend_libs(${JACK_LIBRARIES}) list(APPEND INC_PATHS ${JACK_INCLUDE_DIRS}) endif() endif() if(ALSOFT_REQUIRE_JACK AND NOT HAVE_JACK) message(FATAL_ERROR "Failed to enable required JACK backend") endif() ``` -------------------------------- ### Global Variable Comment Example Source: https://github.com/axmolengine/axmol/blob/dev/docs/CODING_STYLE.md Global variables should have comments explaining their purpose and usage. ```cpp // The total number of tests cases that we run through in this regression test. const int NUM_TEST_CASES = 6; ```