# cmakeLearningCode **Repository Path**: long-xu/cmake-learning-code ## Basic Information - **Project Name**: cmakeLearningCode - **Description**: 专注于CMake学习与实践的代码仓库,涵盖基础教程、实例代码和高级技巧,助力开发者掌握CMake构建系统。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2025-03-19 - **Last Updated**: 2026-03-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # CMake Learning Code This is a code repository focused on CMake learning and practice, helping developers master the CMake build system through a series of progressive examples (recipes). ## Project Introduction This project contains CMake usage examples ranging from basic to advanced levels. Each example focuses on specific CMake features or use cases. Through these examples, you can learn: - Basic CMake syntax and project structure - Library creation and linking (static, shared, and OBJECT libraries) - CMake control structures (foreach, if, while, etc.) - Compilation options and configuration - Cross-platform and architecture detection - Object-oriented CMake project organization - More advanced CMake features ## Directory Structure The project includes the following main examples: - `recipe_01`: Basic CMake project example, showing the simplest CMake configuration - `recipe_05_libs`: Demonstrates how to create and use libraries - `recipe_05_OBJECT`: Shows the use of OBJECT libraries - `recipe_06_foreach`: Using foreach loops to handle multiple source files - `recipe_06_if`: Example of conditional statements - `recipe_06_while`: Example of while loop usage - `recipe_07_option`: Basic usage of CMake options - `recipe_07_dependent_option`: Usage of dependent options - `recipe_08_compiler`: Compiler-related configurations - `recipe_08_compiler_option`: Setting compilation options - `recipe_10`: Object-oriented CMake project example - `recipe_12_checkOS`: Operating system detection - `recipe_12_platform`: Platform-specific features - `recipe_13_detect_arch`: Architecture detection example ## Usage 1. Clone the repository: ```bash git clone ``` 2. Choose an example to study and enter its directory: ```bash cd recipe_XX ``` 3. Create and enter the build directory: ```bash mkdir build && cd build ``` 4. Configure the project: ```bash cmake .. ``` 5. Build the project: ```bash cmake --build . ``` ## Requirements - CMake 3.5 or higher - C++ compiler (GCC, Clang, MSVC, etc.) - Basic command line knowledge ## Learning Suggestions 1. Follow the example numbers in order, starting with the basic recipe_01 2. Carefully read the CMakeLists.txt file and related code in each example 3. Try modifying configurations and observe the results 4. Practice each example to ensure understanding of each CMake feature ## Contributing 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/AmazingFeature`) 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) 4. Push to the branch (`git push origin feature/AmazingFeature`) 5. Open a Pull Request ## License This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details ## Contact If you have any questions or suggestions, feel free to: - Submit an Issue - Create a Pull Request Contributions to improve this CMake learning resource are welcome!