• Home
  • Raw
  • Download

Lines Matching +full:cache +full:- +full:dependency +full:- +full:path

1 .. _module-pw_build-cmake:
5 .. pigweed-module-subpage::
15 .. code-block:: console
17 pw build -r default_cmake
21 .. code-block:: text
24 19:36:58 INF [1/1] Run ==> pw --no-banner package install emboss
25 19:36:59 INF [1/1] Run ==> pw --no-banner package install nanopb
26 19:37:00 INF [1/1] Run ==> pw --no-banner package install boringssl
27--fresh --debug-output -DCMAKE_MESSAGE_LOG_LEVEL=WARNING -S . -B ./out/cmake -G Ninja -DCMAKE_TOOL…
28 …19:37:10 INF [1/1] Run ==> ninja -C out/cmake pw_apps pw_run_tests.modules pw_run_tests.pw_bluetoo…
30 :ref:`module-pw_watch` works with ``pw build`` as well. You can run the
33 .. code-block:: console
35 pw build -r default_cmake --watch
38 ---------------
41 * ``pw_add_library_generic`` -- The base helper used to instantiate CMake
44 * ``pw_add_library`` -- Add an upstream Pigweed library.
45 * ``pw_add_facade_generic`` -- The base helper used to instantiate facade
48 * ``pw_add_facade`` -- Declare an upstream Pigweed facade.
49 * ``pw_set_backend`` -- Set the backend library to use for a facade.
50 * ``pw_add_test_generic`` -- The base helper used to instantiate test targets.
53 * ``pw_add_test`` -- Declare an upstream Pigweed test target.
54 * ``pw_add_test_group`` -- Declare a target to group and bundle test targets.
55 * ``pw_target_link_targets`` -- Helper wrapper around ``target_link_libraries``
58 * ``pw_add_global_compile_options`` -- Applies compilation options to all
62 * ``pw_add_error_target`` -- Declares target which reports a message and causes
66 * ``pw_parse_arguments`` -- Helper to parse CMake function arguments.
67 * ``pw_rebase_paths`` -- Helper to update a set of file paths to be rooted on a
77 --------------------
78 The CMake build uses CMake cache variables for configuring
79 :ref:`facades<docs-module-structure-facades>` and backends. Cache variables are
81 support multi-toolchain builds, so these variables have a single global value
84 The ``pw_add_module_facade`` function declares a cache variable named
85 ``<module_name>_BACKEND`` for each facade. Cache variables can be awkward to
100 ``-DCMAKE_TOOLCHAIN_FILE=<toolchain file>``.
101 * Call ``pw_set_backend`` in the top-level ``CMakeLists.txt`` before other
103 * Set the backend variable at the command line with the ``-D`` option.
105 .. code-block:: sh
107 cmake -B out/cmake_host -S "$PW_ROOT" -G Ninja \
108 -DCMAKE_TOOLCHAIN_FILE=$PW_ROOT/pw_toolchain/host_clang/toolchain.cmake \
109 -Dpw_log_BACKEND=pw_log_basic
112 ``cmake-gui``.
117 .. code-block::
128 ---------------
130 in the `CMake documentation <https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html>`_.
132 with the ``-D`` option (``-DCMAKE_TOOLCHAIN_FILE=path/to/file.cmake``).
144 ---------------------
145 The CMake build includes third-party libraries similarly to the GN build. A
146 ``dir_pw_third_party_<library>`` cache variable is defined for each third-party
147 dependency. The variable must be set to the absolute path of the library in
149 (``if("${dir_pw_third_party_<library>}" STREQUAL "")``), the dependency is not
152 Third-party dependencies are not automatically added to the build. They can be
156 Third party variables are set like any other cache global variable in CMake. It
162 .. code-block:: cmake
164 set(dir_pw_third_party_nanopb ${CMAKE_CURRENT_SOURCE_DIR}/external/nanopb CACHE PATH "" FORCE)
166 * Set the variable at the command line with the ``-D`` option.
168 .. code-block:: sh
170 cmake -B out/cmake_host -S "$PW_ROOT" -G Ninja \
171 -DCMAKE_TOOLCHAIN_FILE=$PW_ROOT/pw_toolchain/host_clang/toolchain.cmake \
172 -Ddir_pw_third_party_nanopb=/path/to/nanopb
174 * Set the variable interactively with ``ccmake`` or ``cmake-gui``.
176 .. _module-pw_build-existing-cmake-project:
179 ------------------------------------------
180 To use Pigweed libraries form a CMake-based project, simply include the Pigweed
183 .. code-block:: cmake
185 add_subdirectory(path/to/pigweed pigweed)
192 .. code-block:: cmake
194 add_subdirectory(path/to/pigweed/pw_some_module pw_some_module)
195 add_subdirectory(path/to/pigweed/pw_another_module pw_another_module)
199 - :bdg-ref-primary-line:`module-pw_fuzzer-guides-using_fuzztest-toolchain`
200 - :bdg-ref-primary-line:`module-pw_protobuf_compiler-cmake`
201 - :bdg-ref-primary-line:`module-pw_unit_test-cmake`