I'm using cmake to build a set of libraries that then gets packaged and shipped to other groups that are also using cmake to use the library. Since I use google mock to mock my libraries, and the downstreams also want to mock my library I just provide the mock header for their use. This works, but there are some quirks of google mock that make it not work well.
It turns out the it takes a significant amount of time to build the constructor and destructor for a mock class. So we have moved those to a separate .cpp file that is compiled and exported into another library to link against. INSTALL(FILES MyMock.h DESTINATION include/) INSTALL(TARGETS ${PROJECT_NAME} EXPORT my-target LIBRARY DESTINATION lib COMPONENT ${MY_COMPONENT}) Now I'm looking at upgrading the version of google mock I compile against, but I cannot force my down streams to upgrade (I expect that they will, but politically I cannot force it). The new version is not binary compatible with the old version, even though the headers are source compatible. What I want to do is INSTALL(FILES MyMock.h DESTINATION include/) INSTALL(FILES MyMock.cpp DESTINATION src/) INSTALL(TARGETS MyLibraryMock EXPORT my-target SOURCE_LIBRARY DESTINATION src COMPONENT ${MY_COMPONENT}) Then when the downstreams have TARGET_LINK_LIBRARIES(THEIR_PROJECT MyLibraryMock) Cmake knows to build MyLibraryMock, but if they don't link to the mock (I none of their tests use it) don't build it. Does anyone have any idea on how I might be able to achieve that?
-- 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