<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Compile part of a matter application as static library</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114870/compile-part-of-a-matter-application-as-static-library</link><description>This question is analog to but related to a Matter application. In this case, I&amp;#39;d like to separate the compilation of all Matter/CHIP related application parts from my own application code, e.g., to use strict compiler flags for my own code which fail</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Sep 2024 10:15:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114870/compile-part-of-a-matter-application-as-static-library" /><item><title>RE: Compile part of a matter application as static library</title><link>https://devzone.nordicsemi.com/thread/503545?ContentTypeID=1</link><pubDate>Tue, 24 Sep 2024 10:15:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5ae4a4ce-892b-48ac-87cd-43fa125b4533</guid><dc:creator>mlampacher</dc:creator><description>&lt;p&gt;Works for my current use-case, yes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compile part of a matter application as static library</title><link>https://devzone.nordicsemi.com/thread/503471?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2024 21:57:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9836ba9-cb4d-4915-a6cb-d4da4b5e9bf7</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you fix the issue?&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compile part of a matter application as static library</title><link>https://devzone.nordicsemi.com/thread/503225?ContentTypeID=1</link><pubDate>Fri, 20 Sep 2024 09:11:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de01feac-a9a0-4fa7-9364-7bec3f87315c</guid><dc:creator>mlampacher</dc:creator><description>&lt;p&gt;After stumbling through include and linking order problems, this is what I&amp;#39;ve come up with.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;cmake_minimum_required(VERSION 3.20.0)
set(CHIP_CFLAGS -DDUMMY_VALUE=0xDEADBEEF)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(
    Empty
    VERSION 0.1
    DESCRIPTION &amp;quot;empty matter application.&amp;quot;
)
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/config/nrfconnect/app/enable-gnu-std.cmake)
include(${ZEPHYR_CONNECTEDHOMEIP_MODULE_DIR}/src/app/chip_data_model.cmake)

set(zap_file    &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/src/zap/template.zap&amp;quot;)
set(zap_gen_pwd &amp;quot;${CMAKE_CURRENT_SOURCE_DIR}/src&amp;quot;)
set(zap_gen_dir &amp;quot;${zap_gen_pwd}/zap-generated&amp;quot;)

target_sources(app PRIVATE src/main.cpp ...)
target_include_directories(app PRIVATE include src)

target_compile_options(
    app
    PRIVATE
    # TODO: required since i&amp;#39;m using Matter/CHIP in my &amp;quot;app&amp;quot; files too ...
    &amp;quot;-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=&amp;lt;lib/address_resolve/AddressResolve_DefaultImpl.h&amp;gt;&amp;quot;
)

add_library(app-chip OBJECT &amp;quot;&amp;quot;)
target_include_directories(app-chip PRIVATE ${zap_gen_pwd})
target_link_libraries(
    app-chip
    PUBLIC
    zephyr
    chip
)

chip_configure_data_model(
    app-chip
    INCLUDE_SERVER
    BYPASS_IDL
    GEN_DIR ${zap_gen_dir}
    ZAP_FILE ${zap_file}
)

target_link_libraries(app PUBLIC app-chip)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Sadly, this doesn&amp;#39;t help my use case since compiler errors are propagated through includes. And since C++ uses header files for implementation, and since I&amp;#39;m still using Matter/CHIP includes in my sources the compiler screams at me for stuff that I&amp;#39;m not responsible for (shadowed variables, unused parameters, etc.).&lt;/p&gt;
&lt;p&gt;The cleanest solution would of course still be to separate the Matter/CHIP parts into a module or somehow else _completely_ decouple Matter/CHIP from other more strict implementation parts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>