How do I create a CMakeLists.txt for gmock to configure only once?
I tried:
ADD_CUSTOM_TARGET( gmock DEPENDS ${CMAKE_CURRENT_LIST_DIR}/gmock-1.6.0/lib/.libs/libgmock.a COMMAND cd ${CMAKE_CURRENT_LIST_DIR}/gmock-1.6.0 && ./confi开发者_StackOverflow中文版gure && make )
but this will do a ./configure every single time, even when I really only need to run it once.
As an aside, I'm open to using FIND_PACKAGE(), etc... for the long run so I don't need to make changes when updating gtest, but at this point, I'm just trying to get it to build without configuring every single time.
Do you want to have a build dependency on gtets or gmock source? If so, this thread on gtest mailing list may help. In short, simply ADD_DIRECTORY
with your gtest or gmock source code and then you can depend on public library targets defined there.
Split the configure and the make call of gmock into two separate custom_targets and don't forget to add a dependency to each of them.
That is for the configure-target maybe the configure.in or any other file from gmock which makes it necessary to re-run configure and the configure-target to the make-target.
Then the make-target should be in dependency to one of your targets and not to the libgmock.a (which is generated by the make call).
HTH
精彩评论