The Zen of integrating 3rd party packages

So I guess Zen will have to wait. As my favorite fortune cookie says,

Pragmatics must take precedence over elegance, for Nature is not impressed.

I was trying to avoid actually installing this project, because that’s kind of destructive. Everything else I’ve built in CMake, I can just use within my project. But, since I’m building in a Docker container, I can tolerate it, and the project must move forward.

This got me working:

include(ExternalProject)


# MPSSE
ExternalProject_Add(mpsse
  DOWNLOAD_DIR mpsse
  SOURCE_DIR mpsse/libmpsse-1.3/src
  INSTALL_DIR /usr/local

  # download step
  DOWNLOAD_COMMAND unzip -u ${CMAKE_CURRENT_SOURCE_DIR}/libmpsse-1.3.zip

  # configure step
  CONFIGURE_COMMAND <SOURCE_DIR>/configure --disable-python --prefix <INSTALL_DIR> --libdir <INSTALL_DIR>/lib64

  # build step
  BUILD_IN_SOURCE 1
  BUILD_COMMAND make
)

I had to explicitly do the unzip because if I just pass a URL, CMake insists on adding intervening directories in the <SOURCE_DIR> path. With the explicit unzip I had more control. The challenge with this particular build is that the zipfile has an enclosing directory that has doc and src subdirectories. I couldn’t figure out how to get configure to run in the same directory it is in. When I controlled <SOURCE_DIR>, it worked.

I’d like to understand the proper way to expose the products of this build for CMake, but I think in the long run, I’ll be better off just writing a CMake file for it. It’s a trivial project and that would probably have been less work than this has cost me.