### Setup Virtual Environment and Install Dependencies Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Creates and activates a Python virtual environment to manage project dependencies. It also upgrades pip and installs psutil within the environment. ```shell python3 -m venv football-env ``` ```shell source football-env/bin/activate ``` ```shell # update pip and setuptools ``` ```shell python3 -m pip install --upgrade pip setuptools wheel ``` ```shell python3 -m pip install psutil ``` -------------------------------- ### Install Prerequisites with Homebrew Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Installs Git, Python 3, CMake, SDL2 libraries, and Boost with Python 3 support using Homebrew. Also upgrades pip, setuptools, and wheel, and installs the psutil package. ```shell brew install git python3 cmake sdl2 sdl2_image sdl2_ttf sdl2_gfx boost boost-python3 python3 -m pip install --upgrade pip setuptools wheel python3 -m pip install psutil ``` -------------------------------- ### Install GFootball from PyPI Source: https://github.com/google-research/football/blob/master/README.md Installs the GFootball package from the Python Package Index (PyPI). This is the recommended installation method. ```shell python3 -m pip install gfootball ``` -------------------------------- ### Install GFootball Dependencies Source: https://github.com/google-research/football/blob/master/gfootball/colabs/gfootball_example_from_prebuild.ipynb Installs necessary system dependencies and clones the GFootball repository. It then downloads a prebuilt engine binary and installs the package using the prebuilt SO file. ```bash !apt-get update !apt-get install libsdl2-gfx-dev libsdl2-ttf-dev # 2.8 and 2.9 binary is the same, so we use 2.8 .so file !git clone -b v2.9 https://github.com/google-research/football.git !mkdir -p football/third_party/gfootball_engine/lib !wget https://storage.googleapis.com/gfootball/prebuilt_gameplayfootball_v2.8.so -O football/third_party/gfootball_engine/lib/prebuilt_gameplayfootball.so !cd football && GFOOTBALL_USE_PREBUILT_SO=1 python3 -m pip install . ``` -------------------------------- ### Install Sonnet and psutil for Training Source: https://github.com/google-research/football/blob/master/README.md Installs Sonnet and psutil libraries, which are dependencies for training agents. ```bash python3 -m pip install dm-sonnet==1.* psutil ``` -------------------------------- ### Install Google Research Football on Windows Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Steps to clone the football repository, set the VCPKG_ROOT environment variable, create and activate a virtual environment, upgrade pip, install necessary packages, and finally install the Google Research Football engine. ```command line :: Clone the repository git clone https://github.com/google-research/football.git cd football :: Set VCPKG_ROOT environment variable that points to vcpkg installation set VCPKG_ROOT=C:\dev\vcpkg\ :: Create and activate virtual environment python -m venv football-env football-env\Scripts\activate.bat :: For PowerShell users: football-env\Scripts\activate.ps1 :: Upgrade pip and install additional packages python -m pip install --upgrade pip setuptools wheel python -m pip install psutil :: Run the installation. It installs vcpkg dependencies and compiles the engine python -m pip install . ``` -------------------------------- ### Install GFootball from Source Source: https://github.com/google-research/football/blob/master/README.md Installs GFootball from its GitHub repository. This involves cloning the repository, navigating to the directory, and building the package. ```shell git clone https://github.com/google-research/football.git cd football python3 -m pip install . ``` -------------------------------- ### Install OpenAI Baselines for Training Source: https://github.com/google-research/football/blob/master/README.md Installs the OpenAI Baselines library from its master branch, a dependency for training agents. ```bash python3 -m pip install git+https://github.com/openai/baselines.git@master ``` -------------------------------- ### Start Docker Container (Alternative GPU) Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md An alternative method to start the Docker container if the '--gpus all' flag causes errors. It uses '--device' to explicitly map GPU devices. If issues persist, the flag can be omitted for software rendering. ```bash docker run --device /dev/dri/[X] -e DISPLAY=$DISPLAY -it -v /tmp/.X11-unix:/tmp/.X11-unix:rw gfootball bash ``` -------------------------------- ### Install vcpkg on Windows Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Commands to clone and install vcpkg, a C++ package manager, on Windows. Ensure vcpkg is updated to the latest commit if already installed. ```command line :: Navigate to the created directory cd C:\dev :: Clone vckpg git clone https://github.com/microsoft/vcpkg.git :: Run installation script .\vcpkg\bootstrap-vcpkg.bat ``` -------------------------------- ### Install Required Packages on Linux Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Installs necessary system packages for building and running the environment. Ensure you have sudo privileges. ```shell sudo apt-get install git cmake build-essential libgl1-mesa-dev libsdl2-dev \ libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev libboost-all-dev \ libdirectfb-dev libst-dev mesa-utils xvfb x11vnc python3-pip ``` ```shell python3 -m pip install --upgrade pip setuptools wheel ``` ```shell python3 -m pip install psutil ``` -------------------------------- ### Download Precompiled Gameplay Engine Source: https://github.com/google-research/football/blob/master/gfootball/colabs/gfootball_example_from_scratch.ipynb Instructions to download the precompiled gameplay engine file from the specified path. This step is part of the manual setup process for GRF. ```text # Now download the file from: # /root/prebuilt_gameplayfootball (using the menu on the left side) ``` -------------------------------- ### Install GRF Dependencies Source: https://github.com/google-research/football/blob/master/gfootball/colabs/gfootball_example_from_scratch.ipynb Installs all required system packages for compiling GRF from source. Run this command in your terminal before proceeding with the compilation. ```bash ! sudo apt-get update ! sudo apt-get install git cmake build-essential libgl1-mesa-dev libsdl2-dev \ libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev libboost-all-dev \ libdirectfb-dev libst-dev mesa-utils xvfb x11vnc libsdl-sge-dev python3-pip ``` -------------------------------- ### Install GFootball on Linux Source: https://github.com/google-research/football/blob/master/README.md Installs GFootball and its dependencies on Linux systems using apt-get and pip. ```shell sudo apt-get install git cmake build-essential libgl1-mesa-dev libsdl2-dev \ libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev libboost-all-dev \ libdirectfb-dev libst-dev mesa-utils xvfb x11vnc python3-pip python3 -m pip install --upgrade pip setuptools psutil wheel ``` -------------------------------- ### Install TensorFlow 1.15 for Training Source: https://github.com/google-research/football/blob/master/README.md Installs TensorFlow version 1.15.x, required for training agents. Choose either CPU or GPU version. ```bash python3 -m pip install --upgrade pip setuptools wheel python3 -m pip install tensorflow==1.15.* python3 -m pip install tensorflow-gpu==1.15.* ``` -------------------------------- ### Install GFootball on macOS Source: https://github.com/google-research/football/blob/master/README.md Installs GFootball and its dependencies on macOS using Homebrew and pip. Ensure Homebrew is installed first. ```shell brew install git python3 cmake sdl2 sdl2_image sdl2_ttf sdl2_gfx boost boost-python3 python3 -m pip install --upgrade pip setuptools psutil wheel ``` -------------------------------- ### Clone and Install GFootball from Source Source: https://github.com/google-research/football/blob/master/gfootball/colabs/gfootball_example_from_scratch.ipynb Clone the GFootball repository and install it using pip. Ensure you specify the correct branch using the -b flag. ```bash ! git clone -b v2.9 https://github.com/google-research/football.git ! cd football && python3 -m pip install . ``` -------------------------------- ### Install in Development Mode Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Installs the Google Research Football package in editable mode, allowing in-place edits without reinstallation. ```shell python3 -m pip install -e . ``` -------------------------------- ### Build the GFootball Game Environment Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Installs the GFootball package and its dependencies using pip within the activated virtual environment. This step compiles and sets up the game environment. ```shell python3 -m pip install . ``` -------------------------------- ### Start GFootball Docker Container Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md Start the GFootball Docker container, enabling GPU access, passing the DISPLAY environment variable, and mounting X11 Unix domain sockets for rendering. It runs bash interactively inside the container. ```bash docker run --gpus all -e DISPLAY=$DISPLAY -it -v /tmp/.X11-unix:/tmp/.X11-unix:rw gfootball bash ``` -------------------------------- ### Install/Upgrade Python Packages in Virtual Environment Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Upgrades pip, setuptools, and wheel, and installs the psutil package within the activated virtual environment. This ensures necessary tools and libraries are available. ```shell python3 -m pip install --upgrade pip setuptools wheel python3 -m pip install psutil ``` -------------------------------- ### Run PPO Experiment Source: https://github.com/google-research/football/blob/master/README.md Executes a PPO experiment on a specified GFootball level. Use `--dump_full_episodes=True` and `--render=True` to save detailed replays. ```bash python3 -m gfootball.examples.run_ppo2 --level=academy_empty_goal_close python3 -m gfootball.examples.run_ppo2 --level=academy_pass_and_shoot_with_keeper python3 -m gfootball.examples.run_ppo2 --dump_full_episodes=True --render=True ``` -------------------------------- ### Create Main Shared Library and Link Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Creates the main shared library `${OUTPUT_LIB_NAME}` using core sources and headers, and then links it with the previously defined list of libraries. ```cmake add_library(${OUTPUT_LIB_NAME} SHARED ${CORE_SOURCES} ${CORE_HEADERS} ${AI_HEADERS} ${AI_SOURCES}) target_link_libraries(${OUTPUT_LIB_NAME} ${LIBRARIES}) ``` -------------------------------- ### Play Against a Pre-trained PPO Agent Source: https://github.com/google-research/football/blob/master/README.md Enables playing against a pre-trained PPO agent. Replace `$YOUR_PATH` with the actual path to the agent's checkpoint. ```bash python3 -m gfootball.play_game --players "keyboard:left_players=1;ppo2_cnn:right_players=1,checkpoint=$YOUR_PATH" ``` -------------------------------- ### Standard Environment Methods Source: https://github.com/google-research/football/blob/master/gfootball/doc/api.md These methods provide the core functionality for interacting with the environment, similar to the GYM API. ```APIDOC ## reset() ### Description Resets the environment to its initial state. ### Method `reset()` ### Parameters None ### Response Returns the initial observation of the environment. ``` ```APIDOC ## step(action) ### Description Performs a single step in the environment by applying the given action. ### Method `step(action)` ### Parameters - **action** (object) - The action to perform in the environment. ### Response Returns a tuple containing: `observation`, `reward`, `done`, `info`. ``` ```APIDOC ## observation() ### Description Returns the current observation of the environment without performing a step. ### Method `observation()` ### Parameters None ### Response Returns the current observation. ``` ```APIDOC ## render(mode) ### Description Enables continuous rendering of the episode. Pixels will be available in the observation. Note: this significantly slows down the `step` method. ### Method `render(mode)` ### Parameters - **mode** (string) - The rendering mode. Supported values: `human`, `rgb_array`. ### Response None ``` ```APIDOC ## disable_render() ### Description Disables rendering that was previously enabled with the `render` call. ### Method `disable_render()` ### Parameters None ### Response None ``` ```APIDOC ## close() ### Description Releases environment resources. ### Method `close()` ### Parameters None ### Response None ``` -------------------------------- ### Build Docker Image (No GPU) Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md Build a Docker image for GFootball using a standard Ubuntu base, without GPU training support. The image is tagged as 'gfootball'. ```bash docker build --build-arg DOCKER_BASE=ubuntu:20.04 . -t gfootball ``` -------------------------------- ### Build Docker Image (With GPU) Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md Build a Docker image for GFootball with GPU training support, using a TensorFlow base image. The image is tagged as 'gfootball'. ```bash docker build --build-arg DOCKER_BASE=tensorflow/tensorflow:1.15.2-gpu-py3 . -t gfootball ``` -------------------------------- ### Configure Docker for Rendering (Linux) Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md Allow Docker containers to access the X server for rendering the game on Linux systems. This command needs to be executed after each reboot or added to /etc/profile for persistence. ```bash xhost +"local:docker@" ``` -------------------------------- ### Play Against Downloaded Checkpoints Source: https://github.com/google-research/football/blob/master/README.md Runs the game to observe pre-trained checkpoints playing. Ensure TensorFlow 1.15 is used. Replace `$CHECKPOINT` and `$LEVEL` with appropriate values. ```bash python3 -m gfootball.play_game --players "ppo2_cnn:left_players=1,policy=gfootball_impala_cnn,checkpoint=$CHECKPOINT" --level=$LEVEL ``` -------------------------------- ### Run GFootball Environment Source: https://github.com/google-research/football/blob/master/gfootball/colabs/gfootball_example_from_prebuild.ipynb Creates and runs a GFootball environment with random actions. It prints the reward at specified steps and the final reward upon episode completion. ```python import gfootball.env as football_env env = football_env.create_environment(env_name="academy_empty_goal_close", stacked=False, logdir='/tmp/football', write_goal_dumps=False, write_full_episode_dumps=False, render=False) env.reset() steps = 0 while True: obs, rew, done, info = env.step(env.action_space.sample()) steps += 1 if steps % 100 == 0: print("Step %d Reward: %f" % (steps, rew)) if done: break print("Steps: %d Reward: %.2f" % (steps, rew)) ``` -------------------------------- ### Include SDL2 Extension Directories Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Includes the directories for the SDL2 image, ttf, and gfx libraries, making their headers available for compilation. ```cmake include_directories(${SDL2_IMAGE_DIRS}) include_directories(${SDL2_TTF_DIRS}) include_directories(${SDL2_GFX_DIRS}) ``` -------------------------------- ### Unix Build Configuration Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Sets the output library name to 'game' and adds the CMakeModules directory to the module path for Unix-like systems. ```cmake else() # UNIX set(OUTPUT_LIB_NAME game) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules") endif() ``` -------------------------------- ### Update pip on Windows Source: https://github.com/google-research/football/blob/master/README.md Updates pip, setuptools, psutil, and wheel on Windows. Use 'python' instead of 'python3' in the command line. ```command python -m pip install --upgrade pip setuptools psutil wheel ``` -------------------------------- ### Copy Precompiled Gameplay Engine Source: https://github.com/google-research/football/blob/master/gfootball/colabs/gfootball_example_from_scratch.ipynb This command copies the precompiled GRF gameplay engine shared object file to a specified directory. This is a necessary step for using precompiled binaries. ```bash ! cp /usr/local/lib/python3.6/dist-packages/gfootball_engine/_gameplayfootball.so /root/prebuilt_gameplayfootball ``` -------------------------------- ### Additional Environment Methods Source: https://github.com/google-research/football/blob/master/gfootball/doc/api.md These methods provide extended functionality for state management and debugging. ```APIDOC ## get_state() ### Description Provides the current environment's state, including random number generator state, player models, and physics. ### Method `get_state()` ### Parameters None ### Response Returns an opaque object representing the current state. ``` ```APIDOC ## set_state(state) ### Description Restores the environment's state to a previously snapshotted state using `get_state()`. ### Method `set_state(state)` ### Parameters - **state** (object) - The state object obtained from `get_state()`. ### Response None ``` ```APIDOC ## write_dump(name) ### Description Writes a dump of the current scenario to the disk. The dump contains observations for each step and can be used for offline analysis. ### Method `write_dump(name)` ### Parameters - **name** (string) - The name for the dump file. ### Response None ``` -------------------------------- ### Find OpenGL and SDL2 Libraries Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Locates and includes directories for OpenGL and SDL2 libraries, essential for graphics and window management. ```cmake FIND_PACKAGE(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) ``` ```cmake FIND_PACKAGE(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) ``` -------------------------------- ### Windows Build Configuration Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Configures build settings for Windows, including checking for required environment variables like VCPKG_ROOT and PY_VERSION, and setting the vcpkg toolchain file and target triplet based on CMAKE_GENERATOR_PLATFORM. ```cmake if(WIN32) # Check for required Environment variables if(NOT DEFINED CMAKE_GENERATOR_PLATFORM) message(FATAL_ERROR "CMAKE_GENERATOR_PLATFORM is not defined. Add -Ax64 or -AWin32 to cmake command") elseif(NOT DEFINED ENV{VCPKG_ROOT}) message(FATAL_ERROR "VCPKG_ROOT is not defined. Set the location of vcpkg") elseif(NOT DEFINED ENV{PY_VERSION}) # PY_VERSION has to be X.Y, e.g. 3.9 message(FATAL_ERROR "PY_VERSION is not defined. Define Python version that will be used, e.g. 3.9") endif() if(${CMAKE_GENERATOR_PLATFORM} STREQUAL Win32) set(VCPKG_TARGET_TRIPLET "x86-windows") elseif(${CMAKE_GENERATOR_PLATFORM} STREQUAL x64) set(VCPKG_TARGET_TRIPLET "x64-windows") else() message(FATAL_ERROR "Unsupported Generator Platform, only Win32 or x64 are supported") endif() set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") set(VCPKG_MANIFEST_DIR "${CMAKE_SOURCE_DIR}/vcpkg_manifests/py$ENV{PY_VERSION}") set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) # Windows requires the library to have the same name as the module set(OUTPUT_LIB_NAME _gameplayfootball) else() # UNIX set(OUTPUT_LIB_NAME game) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules") endif() ``` -------------------------------- ### Activate Virtual Environment Source: https://github.com/google-research/football/blob/master/README.md Activates a Python virtual environment named 'football-env'. This is optional but recommended for managing dependencies. ```shell python3 -m venv football-env source football-env/bin/activate ``` -------------------------------- ### Clone GFootball Repository Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md Clone the GFootball git repository and navigate into the directory. This is the initial step before building or running any Docker images. ```bash git clone https://github.com/google-research/football.git cd football ``` -------------------------------- ### Train Against a Checkpoint Source: https://github.com/google-research/football/blob/master/README.md Configures training to include a pre-trained agent as an opponent. The `extra_players` argument specifies the agent's configuration. ```python extra_players='ppo2_cnn:right_players=1,policy=gfootball_impala_cnn,checkpoint=$CHECKPOINT' ``` -------------------------------- ### Run GFootball Play Game Source: https://github.com/google-research/football/blob/master/gfootball/doc/docker.md Execute the GFootball play game module within the Docker container to interact with the environment directly. Requires the 'full' action set. ```bash python3 -m gfootball.play_game --action_set=full ``` -------------------------------- ### Find Boost Libraries Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Finds the required Boost libraries, including thread, system, filesystem, and the determined Boost.Python version. This ensures all necessary Boost components are available. ```cmake FIND_PACKAGE(Boost REQUIRED COMPONENTS thread system filesystem ${BOOST_PYTHON_VERSION}) include_directories(${Boost_INCLUDE_DIRS}) ``` -------------------------------- ### Configure Boost.Python for Linux Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Handles the varying naming conventions of Boost.Python libraries across different Linux distributions. It attempts to find the correct library name by trying a list of common prefixes. ```cmake set(BOOST_PYTHON_PREFIXES python python3-py python-py) foreach(BP_PREFIX ${BOOST_PYTHON_PREFIXES}) set(BOOST_PYTHON_NAME ${BP_PREFIX}${Python_VERSION_MAJOR}${Python_VERSION_MINOR}) string(TOUPPER ${BOOST_PYTHON_NAME} BOOST_PYTHON_NAME_UPPER) FIND_PACKAGE(Boost COMPONENTS ${BOOST_PYTHON_NAME}) if(Boost_${BOOST_PYTHON_NAME_UPPER}_FOUND) set(BOOST_PYTHON_VERSION ${BOOST_PYTHON_NAME}) break() endif() message("${BOOST_PYTHON_NAME} not found. Trying other names.") endforeach() if(NOT DEFINED BOOST_PYTHON_VERSION) message(FATAL_ERROR "Boost Python not found") endif() ``` -------------------------------- ### Configure Python Paths Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Sets the Python include directories and libraries based on the detected Python version. This is crucial for linking against the Python interpreter. ```cmake string(REPLACE "." ";" VERSION_LIST $ENV{PY_VERSION}) list(GET VERSION_LIST 0 Python_VERSION_MAJOR) list(GET VERSION_LIST 1 Python_VERSION_MINOR) set(Python_INCLUDE_DIRS "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/include/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}") set(Python_LIBRARIES "${CMAKE_BINARY_DIR}/vcpkg_installed/${VCPKG_TARGET_TRIPLET}/lib/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.lib") ``` -------------------------------- ### Include Project Source Directories Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Includes the main source directory and its cmake subdirectory. This makes project headers and CMake modules available during the build process. ```cmake include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(${PROJECT_SOURCE_DIR}/src/cmake) ``` -------------------------------- ### Create and Activate Conda Virtual Environment Source: https://github.com/google-research/football/blob/master/gfootball/doc/compile_engine.md Creates a Conda virtual environment named 'football-env' with Python 3.9 and activates it. This is an alternative to venv for managing dependencies. ```shell conda create --name football-env python=3.9 -y conda activate football-env ``` -------------------------------- ### Find SDL2 Extensions on Windows Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt On Windows, this block finds additional SDL2 extension libraries: image, ttf, and gfx. ```cmake if(WIN32) FIND_PACKAGE(SDL2-image REQUIRED) FIND_PACKAGE(SDL2-ttf REQUIRED) FIND_PACKAGE(SDL2-gfx REQUIRED) else() # Unix FIND_PACKAGE(SDL2_image REQUIRED) FIND_PACKAGE(SDL2_ttf REQUIRED) FIND_PACKAGE(SDL2_gfx REQUIRED) endif() ``` -------------------------------- ### Define Base Libraries Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Defines several static libraries for different engine components like baselib, systemsgraphicslib, loaderslib, typeslib, scenelib, utilslib, and gui2lib. These are compiled as OBJECT libraries. ```cmake add_library(baselib OBJECT ${BASE_SOURCES} ${BASE_HEADERS} ${BASE_GEOMETRY_HEADERS} ${BASE_MATH_HEADERS}) add_library(systemsgraphicslib OBJECT ${SYSTEMS_GRAPHICS_SOURCES} ${SYSTEMS_COMMON_HEADERS} ${SYSTEMS_GRAPHICS_HEADERS} ${SYSTEMS_GRAPHICS_OBJECTS_HEADERS} ${SYSTEMS_GRAPHICS_RESOURCES_HEADERS} ${SYSTEMS_GRAPHICS_RENDERING_HEADERS}) add_library(loaderslib OBJECT ${LOADERS_SOURCES} ${LOADERS_HEADERS} ${MANAGERS_HEADERS}) add_library(typeslib OBJECT ${TYPES_SOURCES} ${TYPES_HEADERS}) add_library(scenelib OBJECT ${SCENE_SOURCES} ${SCENE_HEADERS} ${SCENE2D_HEADERS} ${SCENE3D_HEADERS} ${SCENE_OBJECTS_HEADERS} ${SCENE_RESOURCES_HEADERS}) add_library(utilslib OBJECT ${UTILS_SOURCES} ${UTILS_HEADERS} ${UTILS_EXT_HEADERS}) add_library(gui2lib OBJECT ${UTILS_GUI2_SOURCES} ${UTILS_GUI2_HEADERS} ${UTILS_GUI2_WIDGETS_HEADERS}) ``` -------------------------------- ### SDL2 Library Configuration Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Configures the SDL2 libraries based on the operating system. For UNIX, it concatenates various SDL2 related libraries. For Windows, it uses imported targets. ```cmake if(UNIX) set(SDL2_LIBS_ALL ${SDL2_IMAGE_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2_GFX_LIBRARIES} ${SDL2_LIBRARIES}) elseif(WIN32) set(SDL2_LIBS_ALL SDL2::SDL2 SDL2::SDL2_image SDL2::SDL2_ttf SDL2::SDL2_gfx SDL2::SDL2main) endif() ``` -------------------------------- ### Compile Core Libraries Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Compiles several core libraries: blunted2, gamelib, menulib, and datalib. `blunted2` is compiled using the aggregated object libraries. ```cmake add_library(blunted2 ${BLUNTED_CORE_SOURCES} ${BLUNTED_CORE_HEADERS} ${OWN_LIBRARIES}) add_library(gamelib ${GAME_SOURCES} ${GAME_HEADERS}) add_library(menulib ${MENU_SOURCES} ${MENU_HEADERS}) add_library(datalib ${DATA_SOURCES} ${DATA_HEADERS}) ``` -------------------------------- ### Link Libraries for Main Target Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Defines the final list of libraries to be linked to the main output library. This includes game libraries, Boost libraries, Python targets, SDL2 libraries, EGL, and OpenGL. ```cmake set(LIBRARIES gamelib menulib datalib blunted2 Boost::filesystem Boost::system Boost::thread Boost::${BOOST_PYTHON_VERSION} ${Py_TARGETS} ${SDL2_LIBS_ALL} ${EGL_LIBRARIES} ${OPENGL_LIBRARIES}) ``` -------------------------------- ### Find EGL Library on Unix Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Conditionally finds the EGL library on Unix systems (excluding macOS), which is used for managing OpenGL contexts. ```cmake if(UNIX AND NOT APPLE) FIND_PACKAGE(EGL REQUIRED) include_directories(${EGL_INCLUDE_DIR}) endif() ``` -------------------------------- ### Set Windows Specific Suffix Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Sets the file suffix to ".pyd" for the output library when building on Windows. This is typical for Python extensions on Windows. ```cmake if(WIN32) set_target_properties(${OUTPUT_LIB_NAME} PROPERTIES SUFFIX ".pyd") endif() ``` -------------------------------- ### Find Python Development Components Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Finds Python development components, using 'FindPython' for CMake versions 3.12+ and 'FindPythonLibs' for older versions or specific distributions. ```cmake if(UNIX) if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12") find_package(Python COMPONENTS Development REQUIRED) else() # Starting from CMake 3.12 FindPythonLibs was deprecated in favour of FindPython. # But Ubuntu 18.04 and other older distributions are shipped with CMake version < 3.12, # so we have to support the old behaviour for some time. find_package(PythonLibs 3 REQUIRED) string(REPLACE "." ";" VERSION_LIST ${PYTHONLIBS_VERSION_STRING}) list(GET VERSION_LIST 0 Python_VERSION_MAJOR) list(GET VERSION_LIST 1 Python_VERSION_MINOR) set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) set(Python_LIBRARIES ${PYTHON_LIBRARIES}) endif() elseif(WIN32) # find_package (Python COMPONENTS Development) # FindPython package searches for system-wide python installations first. # It was improved only recently (Jan 2021), so we can't use it for earlier py versions: ``` -------------------------------- ### C++ Standard and Compiler Flags Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Sets the C++ standard to C++14 and defines compiler flags for both C and C++ on Unix systems, including optimization and position-independent code. ```cmake set(CMAKE_CXX_STANDARD 14) if(UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -fPIC -g -O3") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -O3 -g") set(OpenGL_GL_PREFERENCE GLVND) endif(UNIX) ``` -------------------------------- ### Aggregate Object Libraries Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Aggregates the object libraries defined previously into a single variable `OWN_LIBRARIES`. This is used for linking. ```cmake set(OWN_LIBRARIES $ # $ $ $ $ $ $ $) ``` -------------------------------- ### Determine Python Target Source: https://github.com/google-research/football/blob/master/third_party/gfootball_engine/CMakeLists.txt Sets the Py_TARGETS variable based on the CMake version and operating system. This determines how Python modules are linked. ```cmake if(NOT WIN32 AND ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.15") set(Py_TARGETS Python::Module) else() set(Py_TARGETS ${Python_LIBRARIES}) endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.