Function portal_setup_config_pch¶
Sets up configuration precompiled headers for a Portal module.
This function generates and configures a precompiled header that includes all configuration headers from the module and its Portal dependencies.
Synopsis¶
portal_setup_config_pch(<module_name>
[GAME]
[COMPILE_CONFIG_FILE <file>]
[DEPENDENT_CONFIG_HEADERS <header>...])
Arguments¶
<module_name>Name of the module (without
portal-prefix) to set up config PCH for.GAMEOptional flag indicating this is a game target rather than a Portal module. Changes the target name from
portal-<module_name>to just<module_name>and adjusts the PCH output path accordingly.COMPILE_CONFIG_FILE <file>Optional. Path to the module’s own configuration header file. This will be added to the
PORTAL_CONFIG_HEADERSproperty and included in the generated PCH.DEPENDENT_CONFIG_HEADERS <header>...Optional. List of configuration headers from Portal dependencies. These are typically collected from
PORTAL_CONFIG_HEADERSproperties of dependent modules.
Behavior¶
The function performs the following operations:
Property Setup: Sets the
PORTAL_CONFIG_HEADERStarget property with all config headers (both dependent and module-specific) and marks it for export.PCH Generation: Creates an auto-generated precompiled header file at:
For Portal modules:
${CMAKE_CURRENT_BINARY_DIR}/portal/<module_name>/config_pch.hFor game targets (
GAMEflag):${CMAKE_CURRENT_BINARY_DIR}/<module_name>/config_pch.h
PCH Content: The generated header includes:
#pragma onceguard#includedirectives for all configuration headersAuto-generation comment
Target Configuration: Adds the generated header as a PUBLIC precompiled header to the target, making it available to all dependent targets.
Example Usage¶
Setting up config PCH with module’s own config file:
portal_setup_config_pch(core
COMPILE_CONFIG_FILE portal/core/config.h)
Setting up config PCH with dependent configuration headers:
portal_setup_config_pch(engine
COMPILE_CONFIG_FILE portal/engine/config.h
DEPENDENT_CONFIG_HEADERS
portal/core/config.h
portal/application/config.h)
Setting up for a game target:
portal_setup_config_pch(my_game
GAME
DEPENDENT_CONFIG_HEADERS portal/engine/config.h)
Notes¶
The
PORTAL_CONFIG_HEADERSproperty is exported to allow consumers to access configuration headers when the module is importedConfig headers from dependencies are automatically collected by portal_add_module
The generated PCH is PUBLIC, propagating to all dependent targets
This function is automatically called by portal_add_module
See Also¶
portal_add_module: Main module creation function that calls this
portal_configure_pch: Alternative PCH configuration for non-config headers