CMake: How to create a CMakeLists.txt that runs ./configure once?


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 && ./configure && 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.