> > The library linking against "originalLibraryForward" has to be > compiled from the original sources too. Actually performing the
linking step should be sufficient. Is there a way to accomplish that? > Object libraries are what you need here. See https://cmake.org/cmake/help/v3.7/manual/cmake-buildsystem.7.html#object-libraries . Essentially you'll do something like this: add_library(fooObj OBJECT ${foo_Common_Sources}) add_library(foo $<TARGET_OBJECTS:fooObj> ${foo_RealOnly_Sources}) add_library(fooMock $<TARGET_OBJECTS:fooObj> ${foo_MockOnly_Sources}) The function does not work when the library passed to > AddMockedLibrary() uses target_link_libraries() with IMPORTED targets > from, e. g. calls to find_package(). In order to make creating the > _MOCK-Library work I have to duplicate the original call to > find_package() before calling AddMockedLibrary(). Is there a way to > automate this as well? > You might be able to go down the route of creating an INTERFACE library with all of the common properties necessary for both the actual and mock libraries. You could then add the interface lib as a public dependency with target_link_libraries(foo PUBLIC fooInterface) and target_link_libraries(fooMock PUBLIC fooInterface). It's a bit convoluted but I think it could work well here for you. - Chuck
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake