A sample project demonstrating modern CMake best practices using targets for a library and executable.
Modern CMake Sample is an example project that illustrates best practices for using CMake in a contemporary, target-oriented way. It provides a dummy library and an executable to demonstrate proper dependency management, installation, and packaging techniques. The project addresses common pitfalls in CMake configuration by promoting modular and maintainable build scripts.
C++ developers and software engineers who want to learn or improve their CMake skills, especially those transitioning from legacy CMake patterns to modern target-based approaches.
Developers choose this project because it offers a clear, hands-on example of modern CMake conventions, helping them write cleaner, more portable build configurations. It serves as a practical reference for structuring real-world projects with external dependencies and installation requirements.
Example library that shows best practices and proper usage of CMake by using targets
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Employs target-based CMake commands like add_library and target_link_libraries, which improve maintainability by avoiding legacy global variables, as shown in the project structure.
Supports both traditional system installation and CMake's User Package Registry, enabling development workflows without root access, detailed in the installation section.
Demonstrates integration with third-party libraries like Boost and RapidJSON using find_package, simplifying dependency management in CMake projects.
Includes built-in test targets via CMake, allowing easy test execution with commands like 'cmake --build build -- test', enhancing code quality.
Only covers a simple library and executable example, lacking advanced scenarios like cross-compilation, packaging for distributions, or complex multi-project setups.
Requires specific minimum versions (e.g., CMake >=3.13, Boost >=1.65), which may cause compatibility issues in environments with older or fixed toolchains.
Uninstalling relies on manually deleting files from install_manifest.txt, a process that can be error-prone and cumbersome, as noted in the linked FAQ.