-
Notifications
You must be signed in to change notification settings - Fork 918
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
How to use CMake functionality with other libraries that depend on SDK #1234
Comments
I'm sure Graham will be along with the "proper" answer later, but in the meantime I wonder if any if the comments in #924 help? 🤷♂️ |
So this compat.hpp is just needed for the fastled component? Most sdk libraries have a "_headers" version which should avoid your static lib compiling sdk source e.g. hardware_sync has a hardware_sync_headers library that adds the include paths (not that the develop branch has some improvements in this area) . As you've used PRIVATE I wouldn't expect that include compile option to be applied outside the static library. Is that not the case? |
Unless you deliberately wanted to use a static lib (which from your description, you don't), you should use
and
There is some more detail on this here https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-c-sdk.pdf As Peter says, we do have some better support for building static libraries in SDK1.5.0, but the cases you'd want to are pretty rare. |
If he doesn't use a static library, every source file in the sdk will have compat.hpp included at the top? |
oh - i guess i should read more closely - in all my years, i don't think i've ever noticed anyhoo, yes you could therefore use Alternatively you could stick with INTERFACE, and do
to just affect those files |
Thank you all so much for the input! I have a couple things to try and these look quite promising! 😀 The While I'm here, some questions I can answer: The As for |
I think I prefer the set_source_files_properties method to avoid using a static library. Static libraries can quickly cause weird build issues without you realising (in my experience). I agree that the CMake documentation about INTERFACE libraries is a bit confusing. Everything in the sdk is an INTERFACE library. I just think of them as instructions for building a final executable. So source files, compile definitions, include folders and other library dependencies etc are added to the the final executable. The upshot is when you compile your program, the whole sdk gets built. This can be a bit wasteful and it needs some care, e.g. to avoid header file name clashes but it's also quite powerful allowing you to configure the whole sdk how you want just by adding the right "link" libraries dependencies to your executable. |
I've been playing with this a bunch. I've also updated to SDK 1.5.0 (am on The main thing that got me working was the Moving onto the I found it builds mostly fine (more on this later) with or without However I cannot get
How do I define the sources of the library if not like this???
I see much talk of the SDK being an " Now, I've noticed something, that may be obvious to you all, likely caused by my misunderstanding of INTERFACE, but pico sources are getting built twice - in the FastLED library and for the main target. To boot, while I can call some FastLED functions (
The only place I've seen this is in #97 but I'm not using LTO... Maybe this is a symptom of building and linking some pico functions twice? And the linker is trying to reconcile the duplicates which breaks jumps because they're now too far?? Thanks for all the help. Please forgive any typos or confusing messages. It's late. Time for sleep. 🛌💤 |
In the version of cmake we're using, for an interface you have to add the sources in a separate line using target_sources, Not really sure about your error - it looks like a build issue? Check what command is being called by passing VERBOSE=1 to make, |
What do you mean by "version of cmake we're using"? Is this just fundamentally different in older versions? Thank you for the suggestion. Curiously, I found that that the I've got everything as However now I cannot get my set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/FastLED/src/colorpalettes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FastLED/src/colorutils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FastLED/src/FastLED.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FastLED/src/hsv2rgb.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FastLED/src/platforms.cpp
PROPERTIES
COMPILE_OPTIONS "-include compat.hpp") I've tried I've tried a bunch of other options too:
I found this one kind of works, but applies to all source files, which causes other issues. target_compile_options(FastLED INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-include compat.hpp>) So I'm trying to write a generator expression to filter for only source files in a certain path, but I haven't gotten quite to that working... target_compile_options(FastLED INTERFACE $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<...>>:-include compat.hpp>) Is there some other (easier) way to achieve the behavior (of |
I was thinking about this a bunch and think I found an easier way. I created a new #include "compat.hpp"
#include "FastLED/src/colorpalettes.cpp"
#include "FastLED/src/colorutils.cpp"
#include "FastLED/src/FastLED.cpp"
#include "FastLED/src/hsv2rgb.cpp"
#include "FastLED/src/platforms.cpp" I then tell CMake that is the only source file for this INTERFACE library and we're (basically) off to the races! The problem remains with this "Assembler messages" when compiling
I suspect this is a FastLED bug at this point. I'll probably start a new thread about getting this to work there. Until then I'm going to post my findings here. Any pointers would be greatly appreciated :) Manually building with ; ...
.syntax divided
@ 279 "../lib/FastLED/compat/../FastLED/src/platforms/arm/rp2040/../common/m0clockless.h" 1
loadleds3 ip, r4, #1 ,r3; loaddither7 r4, r5, r6, #1; dither5 r4, r5; scale4 r4, r6, #12, r3; adjdither7 r6,r5,#1,#4,r3; swapbbn1 r2, r4;
@ 0 "" 2
.thumb
.syntax unified
ldr r6, .L131 ; <------- Line 812: Error: invalid offset, value too big
movs r0, r2
str r6, [sp, #8]
ldr r6, [r6]
mov r2, ip
str r6, [sp]
b .L124
.L130:
cmp r1, #0
bne .LCB824
b .L129 @long jump
.LCB824:
.L124:
mov r10, r2
mov r7, r8
ldr r2, [sp, #4]
mov r6, r9
.syntax divided
; ... Note:
|
Later versions of cmake allow you to add sources on the same line. I think you should continue this discussion on the forum. |
I've got a basic simple program working with the SDK. I'm trying to add FastLED to control a string of pixels. I'm a little new to CMake so maybe I'm doing something silly, but I'm pretty familiar with other build chains so I know what needs to happen high level.
My
CMakeLists.txt
:Unfortunately, since FastLED doesn't directly support CMake, I need to make my own
lib/FastLED/CMakeLists.txt
for it:I can select the sources I want in
add_library
. However they don't compile without also adding the showntarget_link_libraries
. This makes sense to me - CMake is using this information to tell the compiler where pico-sdk'sinclude
directories are and we can build from there.The problem that comes up is that these dependencies are then built with the extra
target_compile_options
which breaks the compilation, notably of pico-sdk's Assembly sources:I thought by specifying the libraries at the top level it would force them to be compiled there with those options. It seems they do, but don't replace the similar compilation in the dependency.
I suspect I'm missing some simple option that means just "get the include directories of these dependencies". But I've tried many permutations of
target_link_libraries
's (and other functions') options to no avail.I've even tried manually specifying the include directories that are missing with something like:
That gets pretty far but breaks down at finding
version.h
, generated fromversion.h.in
.I've looked through the SDK documentation and examples but rarely found more detail on the pico sdk/cmake expects me to tell it what it needs to know. Any thoughts on moving forward here would be greatly appreciated.
For completeness
compat.hpp
:The text was updated successfully, but these errors were encountered: