Unable to call Subproject from toplevel project
srini2174 opened this issue · 6 comments
I am trying to create a project following the structure shown below
MyWorkspace
|
|
|____ MyFramework1
| |
| |__Module1
| |
| |Module2
|
| MyFramework2
|
|___Module1
|
|___Module2
I have created the following equivalent BasisProject structure
TopLevelProject
|
|
|____ Subproject1
| |
| |Module1
| | | BasisProject.cmake
| |
| |Module2
| | | BasisProject.cmake
|
| Subproject2
| |
| |__Module1
| | | BasisProject.cmake
| |
| |__Module2
| | BasisProject.cmake
|
|___________BasisProject.cmake
|
|___________CMakeLists.txt
But there is no way the subproject is called from the toplevel project.
I tried adding basis_add_subdirectory(Subproject1) in the CMakeLists.txt of the toplevelproject. I get the error " Module Subproject1 specified DEFAULT_MODULES, but a module cannot have itself modules."
I tried adding add_subdirectory(Subproject1) in the CMakeLists.txt of the toplevelproject. I get the error
"CMake Error at config/basis-modules/InstallationTools.cmake:456 (add_custom_target): add_custom_target cannot create target "uninstall" because another target with the same name already exists. The existing target is a custom target"
What is the right way to call the subproject from the toplevel project?
I apologize for the very very late response! Though I assume this answer may be too late, here some information as future reference for others. I suggest a look at my other project called MIRTK that uses BASIS with submodules.
You could add Subproject1/Module1
, Subproject1/Module2
,... to the MODULE_DIRS
defined by the top-level project BasisProject.cmake
file as done for MIRTK here.
I had followed exactly the way it is done in MIRTK, but I still get the error
CMake Error at CMake/Basis/ProjectTools.cmake:358 (message):
[cmake] Module PluginItf specified DEFAULT_MODULES, but a module cannot have itself
[cmake] modules.
The subprojects are only treated as modules of the top level project and they are not treated as a subproject.
Thanks for following up. In that case, I would say the error message is probably quite specific and may not actually be relating to the fact that your top-level project has modules. Rather, do you have an entry DEFAULT_MODULES
in your SubprojectX/ModuleY/BasisProject.cmake
files? If so, please remove. Only the TopLevelProject/BasisProject.cmake
file should contain a DEFAULT_MODULES
option as part of the basis_project
command.
Otherwise, please post the content of the top-level BasisProject.cmake
file and the PluginItf/BasisProject.cmake
, for example.
I have removed the DEFAULT_MODULES option in the BasisProject.cmake file. Now the configuration is done. When I build it Ninja gives the message "No work to do".
As I understand SUBPROJECTS can have modules under them. I have all the sources as a module of the subproject. Since I have removed the DEFAULT_MODULES option no module under the subproject is included/built.
Can you list the default subproject modules with DEFAULT_MODULES
in the TopLevelProject/BasisProject.cmake
file (but not SubprojectX/ModuleY/BasisProject.cmake
)? That's how it is also done in MIRTK if you want to have another look to double check.
Thanks. I was able to get the configuration done, but I felt that it is counter intuitive. One of my team member works on the sub-project with all the modules. So by default all the modules are on. Finally during the integration I will have to remove all the DEFAULT_MODULES option from all the sub-project and also add the sub-project and all the modules under the sub-project in the toplevel project once again. If I have many modules and many sub-projects this becomes very difficult.
Further I am also having some issues in getting the dependency between sub-projects.