CMake Examples
Zhuo's CMake based C/C++ project templates.
Currently in a refactor progress.
Features
- Modern: Use latest cmake, write target-oriented configurations.
- Modular: Formed into > 10 groups of examples, each group consists of strong related examples.
- Versatile: Extracted from practical, not restricted to simple tutorials.
Contents
There are above 100 examples now. Some of them are written in English, some in Chinese, but anyway, each of them are simple enough, just find your interested one, and run it!
You may search them in this page, you may search each of them in the following table:
0_helloworld
number | examples | directory |
---|---|---|
0 | executable_example | 0_helloworld/executable_example |
1 | find_package_example | 0_helloworld/find_package_example |
2 | static_library_example | 0_helloworld/static_library_example |
1_package_management
number | examples | directory |
---|---|---|
0 | auto_download_packages | 1_package_management/auto_download_packages |
1 | build_and_install_packages | 1_package_management/build_and_install_packages |
2 | manually_create_packages | 1_package_management/manually_create_packages |
3 | pack_and_install_packages | 1_package_management/pack_and_install_packages |
4 | use_installed_packages | 1_package_management/use_installed_packages |
2_global_and_target_settings
number | examples | directory |
---|---|---|
0 | build_type | 2_global_and_target_settings/build_type |
1 | c++_standard | 2_global_and_target_settings/c++_standard |
2 | cmake_options | 2_global_and_target_settings/cmake_options |
3 | compilation_database | 2_global_and_target_settings/compilation_database |
4 | configure_file | 2_global_and_target_settings/configure_file |
5 | debug_symbol_example | 2_global_and_target_settings/debug_symbol_example |
6 | define_c_c++_macros | 2_global_and_target_settings/define_c_c++_macros |
7 | flags_and_properties | 2_global_and_target_settings/flags_and_properties |
8 | fPIC | 2_global_and_target_settings/fPIC |
9 | include_directories | 2_global_and_target_settings/include_directories |
10 | link_libraries | 2_global_and_target_settings/link_libraries |
11 | postfix | 2_global_and_target_settings/postfix |
12 | sanitizers | 2_global_and_target_settings/sanitizers |
13 | specify_output_name | 2_global_and_target_settings/specify_output_name |
14 | vs_debugger_working_directory | 2_global_and_target_settings/vs_debugger_working_directory |
3_cross_compilation
number | examples | directory |
---|---|---|
0 | arm-linux-gnueabihf_example | 3_cross_compilation/arm-linux-gnueabihf_example |
1 | arm-none-eabi_example | 3_cross_compilation/arm-none-eabi_example |
2 | arm_neon_example | 3_cross_compilation/arm_neon_example |
3 | arm_neon_example2 | 3_cross_compilation/arm_neon_example2 |
4 | generator_example | 3_cross_compilation/generator_example |
5 | linux-32bit_example | 3_cross_compilation/linux-32bit_example |
6 | neon_intrinsics_example | 3_cross_compilation/neon_intrinsics_example |
7 | ohos_ndk_example | 3_cross_compilation/ohos_ndk_example |
8 | presets-example | 3_cross_compilation/presets-example |
9 | rtos-test | 3_cross_compilation/rtos-test |
4_post_processing
number | examples | directory |
---|---|---|
0 | copy_directory_example | 4_post_processing/copy_directory_example |
1 | copy_dll_example | 4_post_processing/copy_dll_example |
2 | copy_files_example | 4_post_processing/copy_files_example |
3 | dll_path_example | 4_post_processing/dll_path_example |
4 | download_example | 4_post_processing/download_example |
5 | glob_example | 4_post_processing/glob_example |
6 | glslc_example | 4_post_processing/glslc_example |
7 | run_python | 4_post_processing/run_python |
5_testing_and_coverage
number | examples | directory |
---|---|---|
0 | clang_coverage_example | 5_testing_and_coverage/clang_coverage_example |
1 | ctest_example | 5_testing_and_coverage/ctest_example |
2 | ctest_example2 | 5_testing_and_coverage/ctest_example2 |
3 | doctest_example | 5_testing_and_coverage/doctest_example |
4 | gcc_coverage_example | 5_testing_and_coverage/gcc_coverage_example |
5 | gtest_ctest_example | 5_testing_and_coverage/gtest_ctest_example |
6 | gtest_ctest_example2 | 5_testing_and_coverage/gtest_ctest_example2 |
7 | gtest_example | 5_testing_and_coverage/gtest_example |
8 | gtest_example2 | 5_testing_and_coverage/gtest_example2 |
9 | gtest_example3 | 5_testing_and_coverage/gtest_example3 |
10 | gtest_filter | 5_testing_and_coverage/gtest_filter |
11 | test_coverage_example | 5_testing_and_coverage/test_coverage_example |
12 | test_coverage_example2 | 5_testing_and_coverage/test_coverage_example2 |
6_bindings_and_documentation
7_debugging
number | examples | directory |
---|---|---|
0 | debug_dependencies | 7_debugging/debug_dependencies |
1 | sleek | 7_debugging/sleek |
2 | vscode_debug_C++ | 7_debugging/vscode_debug_C++ |
8_cmake_language
number | examples | directory |
---|---|---|
0 | copy_dll_as_function | 8_cmake_language/copy_dll_as_function |
1 | function_example1 | 8_cmake_language/function_example1 |
2 | list_remove_example | 8_cmake_language/list_remove_example |
3 | regex_replace_example | 8_cmake_language/regex_replace_example |
9_misc
number | examples | directory |
---|---|---|
0 | cmake_format_usage | 9_misc/cmake_format_usage |
1 | find_package_examples | 9_misc/find_package_examples |
2 | generate_assemble_example | 9_misc/generate_assemble_example |
3 | masm_example | 9_misc/masm_example |
4 | modules | 9_misc/modules |
5 | umake | 9_misc/umake |
Search
You may also use ./search.sh
for specific search, e.g. search target
as keyword:
bash ./search.sh target
And get result:
./2_global_and_target_settings/compilation_database
./2_global_and_target_settings/postfix
./2_global_and_target_settings/flags_and_properties
./2_global_and_target_settings/flags_and_properties/msvc_runtime_mt_md_example
./2_global_and_target_settings/flags_and_properties/hpc_compute
./2_global_and_target_settings/flags_and_properties/compile_flag_example1
./2_global_and_target_settings/link_libraries
./2_global_and_target_settings/c++_standard
./2_global_and_target_settings/fPIC
./2_global_and_target_settings/configure_file
./2_global_and_target_settings/include_directories
./2_global_and_target_settings/sanitizers
./2_global_and_target_settings/sanitizers/thread_sanitizer_example
./2_global_and_target_settings/sanitizers/address_sanitizer_example
./2_global_and_target_settings/specify_output_name
./2_global_and_target_settings/cmake_options
./2_global_and_target_settings/cmake_options/option_example2
./2_global_and_target_settings/cmake_options/cmake_dependent_option
./2_global_and_target_settings/cmake_options/options_via_txt_example
./2_global_and_target_settings/cmake_options/option_example
./2_global_and_target_settings/build_type
./2_global_and_target_settings/debug_symbol_example
./2_global_and_target_settings/define_c_c++_macros
♥️ Thanks
If you like this project, welcome Star. You may also watch this project for updated notifications in the first time!
References
- More Modern CMake
- Modern CMake
- CMake Cookbook, 中文翻译
- Effective Modern CMake
- 13 valuable things I learned using CMake
- CMake Workshop
LICENSE
Acknowledgement
Proudly to gain one year license for all products from JetBrains.