Grouping Components into directories

30 views
Skip to first unread message

Ugo Levi

unread,
May 28, 2021, 5:49:57 AM5/28/21
to F´ Community Group

Hello,

I am currently configuring a project that I created with fprime.
I started by removing my project from the fprime folder and build it separately, so far no problem my project is working fine.

I would now like to be able to make folders including my components, example:
- my_project/MathComponents/MathTypes/
- my_project/MathComponents/MathPorts/
- my_project/MathComponents/MathReceiver/

I created a test.cmake in the MathComponents folder which calls the CMakeList of each component (MathTypes, MathPorts, ...) and which is called itself (test.cmake) by the CMakeList.txt at the root of my project.

My CMake at the root calls test.cmake using "include("${CMAKE_CURRENT_LIST_DIR}/MathComponents/test.cmake")".

test.cmake calls the CMake of my components using: "add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MathTypes")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MathPorts")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MathReceiver")".


When executing the command some errors appears, I think it's a path problem but I haven't found a solution to fix it.

problem.png

What should I put in my test.cmake so that I can recursively call CMake to have a tree structure as stated above?

-Ugo

lestarch

unread,
May 28, 2021, 2:00:28 PM5/28/21
to F´ Community Group
Typically we'd do this by making a "CMakeList.txt" in MathComponents (instead of test.cmake) and include it using add_subdirectory() (instead of include).  In CMake include is different from add_subdirectory, so use add_subdirectory when making a hierarchy of code.

If this doesn't help, try a full path without spaces.  Sometimes that causes problems too.  If that is the issue, please report it as a bug, as it should not be an issue.


-Michael

Ugo Levi

unread,
Jun 3, 2021, 3:12:32 AM6/3/21
to F´ Community Group
Hello,

Thank you very much for your answer. I did manage to group my components in subfolders.

Here is my solution if someone encounters the problem one day:

In the main CMake you have to replace
add_fprime_subdirectory(...)' by 'add_subdirectory("link_to_your_sub_directory" "link_to_build_directory")'

Then you can add another CMake in the subdirectory which will redirect to the CMake of our component

-Ugo
Reply all
Reply to author
Forward
0 new messages