[CMake] External library dependency

Weatherby,Gerard gweatherby at uchc.edu
Thu Sep 19 13:31:37 EDT 2013


We have an external library which is not easily "cmakeable" and takes a long time to compile. We have a static copy of the source in our SCCS, so we don't need to fetch etc.

What we'd like to have happen is have the code compile if and only if the output libraries are not present.  The best I've come up with is:
               add_custom_command(OUTPUT ${CHOMBO_LIBS_2D}
                              PRE_BUILD
                              COMMAND ${CHOMBO_BUILD_CMD}
#                            DEPENDS don't add depends line ... causes recompiling of Chombo every time
                              WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/Chombo/lib
               )
               # include the Chombo libraries as "source" file to trigger building them via "add_custom_command"
               # if they don't exist
               add_executable(${EXE_2D} ${CHOMBO_LIBS_2D} ${SRC_FILES})

where CHOMBO_LIBS_2D are the libraries generated by CHOMBO_BUILD_CMD. The libraries link in the source tree.

This works, mostly. It doesn't work with parallel builds (make -j9)

I tried looking at ExternalProject_Add but didn't seem how to tell it what output is generated by the command (and hence I'm not sure how / if it can be used to only make if the libraries are missing).

Gerard Weatherby
Appllication Architect
Virtual Cell, Center for Cell Analysis and Modeling (CCAM)
University of Connecticut Health Center
860-679-2065

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130919/40c88b3a/attachment.htm>


More information about the CMake mailing list