-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CMakeLists.txt for Mbed CLI v2 #35
Open
Oxore
wants to merge
3
commits into
ARMmbed:master
Choose a base branch
from
Oxore:cmakelists-for-cli-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright (c) 2021 ARM Limited. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_library(mbed-mqtt INTERFACE) | ||
|
||
target_include_directories(mbed-mqtt | ||
INTERFACE | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/ | ||
./paho_mqtt-sn_embedded_c/MQTTSNClient/src/ | ||
./paho_mqtt_embedded_c/MQTTPacket/src/ | ||
./paho_mqtt_embedded_c/MQTTClient/src/ | ||
./paho_mqtt_embedded_c/MQTTClient/src/mbed/ | ||
./src/ | ||
) | ||
|
||
target_sources(mbed-mqtt | ||
INTERFACE | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNSerializePublish.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNSubscribeServer.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNUnsubscribeServer.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNPacket.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNConnectServer.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNSearchClient.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNUnsubscribeClient.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNSubscribeClient.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNSearchServer.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNConnectClient.c | ||
./paho_mqtt-sn_embedded_c/MQTTSNPacket/src/MQTTSNDeserializePublish.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTSerializePublish.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTConnectServer.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTConnectClient.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTDeserializePublish.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTUnsubscribeServer.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTPacket.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTUnsubscribeClient.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTSubscribeClient.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTSubscribeServer.c | ||
./paho_mqtt_embedded_c/MQTTPacket/src/MQTTFormat.c | ||
./src/MQTTClientMbedOs.cpp | ||
) | ||
|
||
target_link_libraries(mbed-mqtt | ||
INTERFACE | ||
mbed-os | ||
mbed-netsocket | ||
mbed-greentea | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a license header
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be an interface? I suspect STATIC would work for this library (no weak linking symbols) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this license header be sufficient? No names, just copyright, and SPDX identifier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right. Give me a couple more days and I will figure it out how to make it compile being
STATIC
. I'm not really competent neither withcmake
nor with mbed-os'CMakeLists.txt
files organization.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed my mind. Here is the reason why I think this library should be declared as
INTERFACE
:When it is declared as
STATIC
, it anyways turns out to be built alongside with mbed-os in any project. Therefore it uses all the same macros passed to the compiler on invocation. Consider an example when I havembedtls-config-changes.h
file in the root of my project and I pass it as"MBEDTLS_USER_CONFIG_FILE=\"mbedtls-config-changes.h\""
inmbed_app.json
. ThisMBEDTLS_USER_CONFIG_FILE
macro is passed to mbed-mqtt sources too when it is being built and this config header file cannot be found, because mbed-mqtt is being built separately as a static library and it is not aware of my project's root directory where the file is located. To mitigate this error I have to declare something like this in my project's rootCMakeLists.txt
:target_include_directories(mbed-mqtt PRIVATE .)
. When mbed-mqtt declared asINTERFACE
there is no such problems.When it is declared as
STATIC
, all mbed-mqtt dependencies are built separately from the project and number of files to be compiled becomes almost twice as many than if it was declared asINTERFACE
- 868 files whenINTERFACE
vs 1717 whenSTATIC
in my case. Basically the whole OS is being built twice. This is inconvenient.I have no evidence of any library for mbed-os declared as
STATIC
- they all are declared asINTERFACE
. Why mbed-mqtt should not be declared asINTERFACE
?