-
Notifications
You must be signed in to change notification settings - Fork 18
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
Adding header references to interface library #393
Comments
Hmm... assuming main.h is in your project root directory, it might be easiest to just include it by relative path in PinNames.h: #include "../main.h" Though this should also work: target_include_directories(mbed-hmc20 INTERFACE
"${APP_SOURCE_PATH}"
) If it's not working, perhaps the APP_SOURCE_PATH variable is not defined at this point in the build script? Also, keep in mind that doing it this way means that every Mbed source file will include main.h, which may or not be what you want. main.h must be includable from C, and any change to main.h will rebuild the entire project. Last but not least, for the future, since this is not an actual issue with Mbed CE, this kind of thing would be better as a discussion than an issue. OK for now, just remember for next time! Hope this is helpful, let me know if that works! |
This is working now. I think there was an older issue where I defined global functions in my main.h and if you include then main.h over multiple compilation units you have double function definitions because they are not methods in a class. The strange thing here is that you need at least one empty c file PeripheralPins.c that is doing the three includes as mentioned above and PinName.h is separate but imported via the include_directories into the mbed-stm32u575xg with target_link_libraries. Is that right? This looks a bit odd but it's the only way to get it working. |
That sounds more or less right, but I'm surprised you need an empty PeripheralPins.c. Not having that .c file should still let the build work, as long as the actual peripheral pins arrays that are supposed to go there are declared somewhere else. If that's not it's behaving, please post your project in a discussion and we will take a look! |
It's not working after a full compile I get a message for each part that is using PinNames.h:
And it's a whole series ... CMakeLists.txt is:
|
It's working now. Indeed I have to put APP_SOURCE_PATH before the add_subdirectory(HMC20), and not in the subdirectory source where the HMC20 subdir was already added:
|
I have a folder where I gather all my specific files for my target:
The CMakeLists.txt looks like:
PeripheralPins.c has:
In PinNames.h I define the pins and a bit further I use a MACRO:
But I want STDOUT_USB to define in my main.h file in my source code, where other settings are.
Normally I could do something like:
But this is not working because mbed-hmc20 is an interface library, just to let 'mbed-stm32u575xg' know that there are some extra files to compile.
If I put #include "main.h" in PinNames.h is is not found and if I put app_source_path I get:
and with INTERFACE I get:
How can I avoid having to put my setting MACRO's in PinNames.h?
The text was updated successfully, but these errors were encountered: