Luca Pasini
Luca Pasini

Reputation: 149

Cmake issue. Copying dll post build

I'm struggling again with cmake. What I'm trying to achieve is this: I have a project, say ProjectA, which contains a submodule with a CMakeLists.txt, say ProjectB. ProjectA adds ProjectB as subdirectory. ProjectB outputs a shared library (.dll).

ProjectA has a post build script that copies the dll into its output directory in order to use it. The problem is that when i change a few things inside ProjectB, this one gets built, but since no modifications are made in ProjectA, it wont build nor copy the dll.

The solution would be to move the post build script inside ProjectB, but if i do that my submodule will be incompatible in other scenarios and tied to ProjectA implementation (what I mean is that the Cmakelists file of projectB should copy the dll in a folder outside it's directory, which is something I want to avoid).

I can't really find a way to avoid manually rebuilding the whole project every time.

To make the situation more clear, the project hierarchy is something like

The First CMakeLists.txt adds Project B as subdirectory. This cmakelists file also apply a post build script to the target in project A that copies content of ProjectB/bin (dll).

Upvotes: 0

Views: 213

Answers (1)

Luca Pasini
Luca Pasini

Reputation: 149

I managed to solve this by myself. For those who has the same issue and want to find a good solution, just do not use a post build script. Instead you can add a second parameter to add_subdirectory specifying the build folder of the subproject.

Upvotes: 0

Related Questions