Reputation: 990
I have a CMakeLists.txt
that builds some c++ plugin and another CMakeLists.txt that builds application that should load this plugin. Before launching application I need to copy plugin file into some path, relative to the application binary (say path_to_executable/Plugins
).
plugin's CMakeLists.txt
:
...
add_library(plugin SHARED lib.cpp)
...
application's CMakeLists.txt
:
...
target_sources(app PRIVATE main.cpp)
add_subdirectory(plugin_subfolder)
add_dependencies(app plugin)
???
How can I create rule that will insure plugin file is in correct place before compiling target app
?
Upvotes: 0
Views: 133
Reputation: 13718
You can produce you library directly to the place you need w/o any 2 step process of first creating it somewhere and then copying (which is also possible). To achieve this you can set the LIBRARY_OUTPUT_DIRECTORY property on your library:
set_target_properties(plugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY
"path_to_executable/Plugins")
Upvotes: 1