Grantlee Gems: Customizing plugin build output directory

I wanted to be able to to run all the Grantlee unit tests from the build directory without having to go through the install step. As the whole system is plugin based though, the plugins need to be sought and found in specified directories following a certain pattern. The pattern is ${Something}/grantlee/${version}/ For example, the default plugin in version 0.1 would be searched for in ${Something}/grantlee/0.1/ for each value of ${Something} in the list QCoreApplication::libraryPaths.

That’s fine for running the tests against installed plugins. Well known library paths are searched for plugins. However, the output build directory for the tests is ${CMAKE_BINARY_DIR}/tests, and the output build directory for plugins is something like ${CMAKE_BINARY_DIR}/pluginname/ That doesn’t match the pattern /grantlee/${version}/, so my initial solution was to use the CMake install() command to install the plugins to a location inside the build directory. That unfortunately caused problems with packaging tools when testing with the OpenSUSE build service, and it wasn’t really an elegant solution.

The correct solution is to specify the directory the plugins should be built in. Instead of building the plugin to ${CMAKE_BINARY_DIR}/pluginname/, it should be built to ${CMAKE_BINARY_DIR}/grantlee/${version}/

The magic to do that is to specify the ${LIBRARY_OUTPUT_DIRECTORY}. On Windows it’s ${RUNTIME_OUTPUT_DIRECTORY} in the set_target_properties command.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: