Lines Matching +full:- +full:- +full:set +full:- +full:upstream
1 .. _module-pw_build-cmake:
5 .. pigweed-module-subpage::
13 To run upstream Pigweed's CMake build use the ``pw build`` command:
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
42 libraries. This is meant for use in downstream projects as upstream Pigweed
44 * ``pw_add_library`` -- Add an upstream Pigweed library.
45 * ``pw_add_facade_generic`` -- The base helper used to instantiate facade
46 libraries. This is meant for use in downstream projects as upstream Pigweed
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.
51 This is meant for use in downstrema projects as upstream Pigweed modules are
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 --------------------
79 :ref:`facades<docs-module-structure-facades>` and backends. Cache variables are
80 similar to GN's build args set with ``gn args``. Unlike GN, CMake does not
81 support multi-toolchain builds, so these variables have a single global value
87 persist accross CMake invocations. These variables should be set in one of the
95 Zephyr developers do not need to do this, backends can be set automatically
98 * Call ``pw_set_backend`` to set backends appropriate for the target in the
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``.
114 If the backend is set to a build target that does not exist, there will be an
117 .. code-block::
128 ---------------
130 in the `CMake documentation <https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html>`_.
131 These variables are typically set in a toolchain CMake file passed to ``cmake``
132 with the ``-D`` option (``-DCMAKE_TOOLCHAIN_FILE=path/to/file.cmake``).
133 For Pigweed embedded builds, set ``CMAKE_SYSTEM_NAME`` to the empty string
136 Toolchains may set the ``pw_build_WARNINGS`` variable to a list of ``INTERFACE``
137 libraries with compilation options for Pigweed's upstream libraries. This
138 defaults to a strict set of warnings. Projects may need to use less strict
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
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
157 is recommended to set these in one of the following ways:
159 * Set with the CMake ``set`` function in the toolchain file or a
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
192 .. code-block:: cmake
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`