Skip to content
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

Unable to call Subproject from toplevel project #628

Open
srini2174 opened this issue Mar 10, 2019 · 6 comments
Open

Unable to call Subproject from toplevel project #628

srini2174 opened this issue Mar 10, 2019 · 6 comments
Assignees
Labels

Comments

@srini2174
Copy link

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?

@schuhschuh schuhschuh self-assigned this Apr 5, 2020
@schuhschuh
Copy link
Contributor

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.

@srini2174
Copy link
Author

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.

@schuhschuh
Copy link
Contributor

schuhschuh commented Apr 7, 2020

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.

@schuhschuh schuhschuh reopened this Apr 7, 2020
@srini2174
Copy link
Author

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.

@schuhschuh
Copy link
Contributor

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.

@srini2174
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants