diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-02-23 17:56:48 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2019-06-06 18:27:03 +0200 |
commit | 6cb904de7b771f25580a17eff52c32ad0602452f (patch) | |
tree | ca26933a0230b4c7aefe9274caffd07ae36502a7 /docs/markdown/snippets | |
parent | 3d7c50d1092bb6f00842f73248650e0af1266050 (diff) | |
download | meson-6cb904de7b771f25580a17eff52c32ad0602452f.zip meson-6cb904de7b771f25580a17eff52c32ad0602452f.tar.gz meson-6cb904de7b771f25580a17eff52c32ad0602452f.tar.bz2 |
cmake: Added docs
Diffstat (limited to 'docs/markdown/snippets')
-rw-r--r-- | docs/markdown/snippets/cmake_subprojects.md | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/markdown/snippets/cmake_subprojects.md b/docs/markdown/snippets/cmake_subprojects.md new file mode 100644 index 0000000..94f68a1 --- /dev/null +++ b/docs/markdown/snippets/cmake_subprojects.md @@ -0,0 +1,34 @@ +## CMake subprojects + +Meson can now directly consume CMake based subprojects. Using CMake +subprojects is almost identical to using the "normal" meson subprojects: + +```meson +sub_proj = subproject('libsimple_cmake', method : 'cmake') +``` + +The `method` key is optional if the subproject only has a `CMakeList.txt`. +Without specifying a method meson will always first try to find and use a +`meson.build` in the subproject. + +Project specific CMake options can be added with the new `cmake_options` key. + +The returned `sub_proj` supports the same options as a "normal" subproject. +Meson automatically detects build targets, which can be retrieved with +`get_variable`. Meson also generates a dependency object for each target. + +These variable names are generated based on the CMake target name. + +```cmake +add_library(cm_exe SHARED ${SOURCES}) +``` + +For `cm_exe`, meson will then define the following variables: + +- `cm_exe` The raw library target (similar to `cm_exe = library('cm_exe', ...)` in meson) +- `cm_exe_dep` The dependency object for the target (similar to `declare_dependency()` in meson) +- `cm_exe_inc` A meson include directory object, containing all include irectories of the target. + +It should be noted that not all projects are guaranteed to work. The +safest approach would still be to create a `meson.build` for the +subprojects in question. |