-
-
Notifications
You must be signed in to change notification settings - Fork 5
Customising the build system
While the default CMakeLists.txt
file is enough for most projects, some might require additional patches, for things like adding additional libraries.
You can configure variables and add custom functions inside the Config/cmake/<project name>.cmake
file. This file will get loaded before all other CMake scripts, so some functionality, like calling custom functions will have to be refactored into callbacks.
You can easily modify the include directories or other options that don't require a target inside the project.cmake
file. For example, if your project needs to include a library stored in the root directory, instead of in source, you can write the following code to set up the include directories:
include_directories(MyLibrary/include/)
link_directories(MyLibrary/lib/)
Since there are 2 or 3 binaries, 2 of which have a name, unique to the project, we have provided variables that you can use to reference the current project:
- UntitledImGuiFramework - There is no variable for the framework. You can just use the name
UntitledImGuiFramework
- Application library -
${APP_LIB_TARGET}
- Application executable -
${APP_TARGET}
We provide variables for providing custom headers and source files to any of the 3 binaries. They are the following:
- Framework:
- Headers:
${UIMGUI_CUSTOM_FRAMEWORK_HEADERS}
- Sources:
${UIMGUI_CUSTOM_FRAMEWORK_SOURCES}
- Headers:
- Application library:
- Headers:
${UIMGUI_CUSTOM_APP_HEADERS}
- Sources:
${UIMGUI_CUSTOM_APP_SOURCES}
- Headers:
- Application executable:
- Sources:
${UIMGUI_CUSTOM_EXEC_SOURCES}
- Sources:
You can simply append a list of files to any of these variables in variable ways. For, example you can recursively get all source and header files, like this:
file(GLOB_RECURSE UIMGUI_CUSTOM_APP_SOURCES "MyLibrary/src/*.cpp")
file(GLOB_RECURSE UIMGUI_CUSTOM_APP_HEADERS "MyLibrary/include/*.hpp")
There are 2 callback functions that are provided as part of the template. They can be used to properly set up certain parts of the project, since CMake functions are not position-independent.
The custom_setup_step
callback is called after all modules and framework libraries are set up. Here, you can do calls to functions, such as add_subdirectory
The custom_compile_step
callback is added after binaries are added for compilation and all modules and framework libraries' defines are set up.
Here you can add additional compiler definitions, linker options and link libraries to all targets.
You can use the following utility functions to make life easier.
The multicast
function takes a function name and a variadic arguments list, then calls the function for all targets, given that the current platform supports the given target(application libraries are not supported on Windows). For example, instead of writing:
target_link_options(UntitledImGuiFramework PRIVATE -fwasm-exceptions -sSUPPORT_LONGJMP=wasm)
if (NOT WIN32)
target_link_options(${APP_LIB_TARGET} PRIVATE -fwasm-exceptions -sSUPPORT_LONGJMP=wasm)
endif()
target_link_options(${APP_TARGET} PRIVATE -fwasm-exceptions -sSUPPORT_LONGJMP=wasm)
You can do a single call to multicast, like this:
multicast(target_link_options PRIVATE -fwasm-exceptions -sSUPPORT_LONGJMP=wasm)
This project is supported by all the people who joined our discord server and became beta testers. If you want to join the discord you can click here.
- Home
- Beginner content
- Install guide
- Creating and using the UI components
- The Instance
- The Init Info struct
- Textures
- Logging
- Unicode support
- Additional features
- Client-side bar
- Custom type definitions
- Memory management
- C API development
- Config files and Folders
- Interfaces
- Internal Event safety
- Customising the build system
- Modules system
- Collaborating with others
- Advanced content
- Developer and contributor resources
- Misc