Function portal_read_settings¶
Reads and processes a Portal Engine settings file, configuring the target based on its contents and preparing it for installation.
This function reads a JSON settings file, extracts engine configuration and resource references, sets up automatic resource copying, and configures the settings file as an install target for deployment.
Synopsis¶
portal_read_settings(<target_name>)
Arguments¶
<target_name>Name of the target to configure. The target must have the
PORTAL_SETTINGS_PATHproperty set (typically by portal_add_game).
Behavior¶
The function performs the following operations:
Settings Validation: Retrieves the settings file path from the target’s
PORTAL_SETTINGS_PATHproperty and validates that the file exists.Installation Setup: Creates a custom command to copy the settings file to
$<TARGET_FILE_DIR:target>/<filename>usingcopy_if_differentfor efficient incremental builds.Display Name: Reads
project.namefrom the settings JSON to set thePORTAL_DISPLAY_NAMEtarget property, defaulting to the target name on error.Configuration Parsing: Reads and parses the JSON settings file to extract resource entries from
project.resources.Resource Configuration: For each resource entry in the settings:
Extracts the
typeandpathfields from the resource objectValidates that the path is relative (absolute paths are skipped)
Creates custom targets to copy resource directories to the runtime output
Registers resources with the
PORTAL_RESOURCESproperty for installation
Target Dependencies: Ensures the settings file and resources are copied during the build process by adding appropriate target dependencies.
Example Usage¶
Typically called internally by portal_add_game:
# Set the settings path property
set_target_properties(my-game PROPERTIES
PORTAL_SETTINGS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/settings.json")
# Read, configure, and prepare for installation
portal_read_settings(my-game)
Notes¶
This is an internal function typically called by portal_add_game
Uses
copy_if_differentto avoid unnecessary rebuildsOnly relative resource paths are processed
Resources are tracked via
PORTAL_RESOURCESfor installationTODO: Future versions will validate engine version compatibility
See Also¶
portal_add_game: Creates Portal Engine game executables
portal_install_game: Install game with settings and resources
portal_add_resources: Manually add resource directories