Instruction file imported from canonical/mir (
.github/instructions/cmake.instructions.md). Copyright stays with the author.
CMake conventions
- No GLOB for sources: All source files are listed explicitly in
add_library()/target_sources(). Never usefile(GLOB ...)for source files. - Test registration (in
tests/): Usemir_add_test()andmir_discover_tests()fromcmake/MirCommon.cmake— not rawadd_test(). (Exception:doc/CMakeLists.txtand similar non-test build infrastructure may use rawadd_test()for custom verification steps.) - Test binaries: Use
mir_add_wrapped_executable(target_name NOINSTALL ...)for test executables. - Wayland protocol wrappers: Use
mir_generate_protocol_wrapper(target prefix xml_file)— not rawadd_custom_command. - Rust/CXX integration: Use
add_rust_cxx_library()fromcmake/RustLibrary.cmake. - ABI version variables: Each library defines
set(LIB_ABI N)locally (e.g.,MIRAL_ABI,MIRCORE_ABI,MIRWAYLAND_ABI,MIRSERVER_ABI). Bump these when breaking ABI — see the ABI & symbols instructions for the full procedure.