dascandy / evoke

Magic build tool
Apache License 2.0
166 stars 17 forks source link

CMake generation not working properly with subcomponents #69

Closed PenguinLemma closed 4 years ago

PenguinLemma commented 5 years ago

Describe the bug In the case of having submodules/subcomponents in a project, it is not possible to build our project with cmake using the cmakelists generated by evoke.

There seem to be two reasons for this: 1) Subdirectories for subcomponents comp/subcomp are added using the subcomponent name comp_subcomp instead of the path comp/subcomp. 2) All subcomponents are treated as system libraries (evokesystem...) and even when correcting add_subdirectories parameters, the build will fail because files #included won't be found.

To Reproduce Steps to reproduce the behavior:

  1. Run git clone https://github.com/PenguinLemma/evoke_examples.git in an empty folder.
  2. Run `cd evoke_examples/3_subcomponents
  3. Run evoke -v -cm
  4. Run mkdir build && cd build
  5. Run cmake ..
  6. Run make See the error. This time it is related to 3_subcomponents/CMakeLists.txt's add_subdirectories(sequences_base_sequence) and similar.
  7. Edit 3_subcomponents/CMakeLists.txt changing sequences_* by sequences/* inside add_subdirectories. See the error. Now it's complaining that base_sequence.cpp can not be found when included from any of the other two sequences.

Expected behavior Subdirectories are added correctly as component/subcomponent and submodules are not treated as system libraries (unless they are indeed). 3_subcomponents can be built with cmake using the cmakelists generated by evoke.

Screenshots/Logs First error can be found here: cmake_output.txt Second error can be reproduced, as stated above (I seem to not have saved the output in a file, sorry!)

System (please complete the following information):

Proposed solution While trying to find out if this was a problem of the example project or not, and trying to understand the error, I found a way to solve this. Which is the following:

1) Add cmake_subdir_name to a component (in the case of comp/subcom, the name of the component will be "comp_subcomp" and cmake_subdir_name = "comp/subcom". 2) Refactor slightly Project::IsSystemComponent so that it receives a component and checks for both names (component.name and component.cmake_subdir_name). 3) Adapt CMakeProjectExporter::LookupLibraryName accordingly.

I will add a pull-request for this, please let me know of any possible side effects that I might have overlooked or any changes you consider pertinent.

PenguinLemma commented 4 years ago

PR #71 fixes this issue