C++ Cross Platform Development
14 May 2021
[
c++
cross
]
Build
- Combination of variants
- The variant combination should be build int own directory
- A variant may be:
- Base OS
- Processor architecture
- GUI
- Build tools and runtime libraries
- Facilities
- Versions (of OS, …)
- Other …
- Base OS
- Processor Architecture
- GUI
- Build tools and runtime libraries
Hiding behind API
- Define internal API with different implementations
- Place different implementations in different directories
Target hierarchies
- Classify - common/, arch/, os/, gui/ toolset/, etc.
- Arrange source to reflect classification os/win/ce/3.0/src
- Specify target attributes to build system as hierarchy OS=win/ce/3.0
Depth override
- Search for target-specific version of the source file
- Search in defined order, common last
- If file is not found, drop attribute element from the right of hierarchy and try again
- More specific code is foudn further right of the tree
Considerations
- Plan to let it evolve
- Be prepared to refactor code
- Write code at the leaves and push up - easy to identify portability work
- Regular automated build/test for all platforms - find problems quickly
Code
- Specify category order
- Subcategories can have elements removed until empty
- Don’t allow duplicate locations
Build Systems
CMake
Common configuration
Dependency management
- No automation and reproducible dependency management
- System package managers: apt
- Build system specific package managers: NuGet
- Language specific package managers: vcpkg
- Conan -> recommended for C++ cross platform development
Debugging
- Multiple platform specific debugging tools
- GUI vs Command driven interface
- Core dumb debugging
- Debugging crashes on CI
References