CMake ExternalProject options
CMake manpages are about the most verbose manpages on the planet.
All I wanted to do was import an external project and customise the build options without having to go and add files into the child project / patch them / whatever. Many disgusting options, including one which literally sed’d the set()
options, were considered.
In the end, the solution was delightfully simple:
Include(ExternalProject)
list(APPEND CMAKE_ARGS "-DOPTION_ONE=OFF")
list(APPEND CMAKE_ARGS "-DOPTION_TWO=ON")
ExternalProject_Add(
Foo
GIT_REPOSITORY https://github.com/foobar/foo.git
GIT_TAG v0
STEP_TARGETS build
CMAKE_ARGS "${CMAKE_ARGS}"
)
Note I’m not a CMake aficionado so if there’s a more CMake-esque way of doing this please let me know …