Function portal_setup_compile_configs¶
Generates a single implementation file providing definitions for application configuration constants declared across all dependent Portal modules.
This function creates a C++ source file that defines compile-time constants for application
metadata (display name, settings file, icon file). These definitions satisfy the extern const
declarations that each Portal module creates via portal_setup_config_pch in their respective
config PCHs. This allows a single implementation to serve all dependent modules.
Synopsis¶
portal_setup_compile_configs(<target_name>
<settings_file>
<icon_file>)
Arguments¶
<target_name>Name of the executable target to add the configuration definitions to.
<settings_file>Filename of the settings file (e.g., “settings.json”). Becomes the definition for the
portal::PORTAL_SETTINGS_FILE_NAMEconstant declared in each module’s config PCH.<icon_file>Filename of the icon file (e.g., “icon.png”). Becomes the definition for the
portal::PORTAL_ICON_FILE_NAMEconstant declared in each module’s config PCH.
Behavior¶
The function performs the following operations:
Template Generation: Creates a C++ source file template containing definitions for
PORTAL_SETTINGS_FILE_NAME, andPORTAL_ICON_FILE_NAMEasconstexpr std::string_viewin theportalnamespace.CMake Configuration: Writes the template to
config_impl.incin the build directory, then usesconfigure_file()to substitute@VARIABLE@placeholders with the provided values, producingconfig_impl.cpp.Source Integration: Adds the generated
config_impl.cppto the target’s private sources, providing a single set of definitions that satisfy the declarations from all dependent Portal modules.
Multi-Module Declaration Pattern¶
Each Portal module (core, application, engine, etc.) that has a config file calls
portal_setup_config_pch during its build, which generates declarations for these
constants in the module’s config PCH:
// In portal-application/config.h (also generated by portal_setup_config_pch)
namespace portal {
extern constexpr std::string_view PORTAL_SETTINGS_FILE_NAME;
}
// In portal-engine/config.h (also generated by portal_setup_config_pch)
namespace portal {
extern constexpr std::string_view PORTAL_ICON_FILE_NAME;
}
The application then calls portal_setup_compile_configs once to provide the single
implementation that all modules will link against:
// In build/config_impl.cpp (generated by portal_setup_compile_configs)
namespace portal {
constexpr std::string_view PORTAL_SETTINGS_FILE_NAME = "settings.json";
constexpr std::string_view PORTAL_ICON_FILE_NAME = "icon.png";
}
Example Usage¶
Typically called internally by portal_add_game:
# Each Portal module has already called portal_setup_config_pch during their build
# Application calls this once to provide the definitions
portal_setup_compile_configs(my-game "settings.json" "icon.png")
Notes¶
This is an internal function typically called by portal_add_game
Provides a single implementation for declarations across all dependent Portal modules
See Also¶
portal_setup_config_pch: Generates config PCH with variable declarations (called per module)
portal_add_game: Creates Portal Engine game executables
portal_read_settings: Reads and processes settings files