I’m updating my build chain (new compilers, updated 3rd party versions and such) and I want to clean up some of the cruft of our original naive implementations.
I have at least 3 different ways external packages are integrated, and I’d like to enforce some consistency. One of my least supported approaches was a package called mpsse. Previously, I downloaded the .tar.gz file, unpacked it out of my project, modified the Makefile to get it to compile, and installed it in my VM.
Now, I want to build it as part of my project. I added the modified source tree to my git repo in external (a new directory I created for the 3rd party packages).
The CMakeLists.txt file in external looks like this:
include(ExternalProject)
# MPSSE
ExternalProject_Add(mpsse
# download step -- skipped since it is here
DOWNLOAD_COMMAND ""
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libmpsse-1.3/src
# configure step
CONFIGURE_COMMAND <SOURCE_DIR>/configure --disable-python
# build step
BUILD_IN_SOURCE 1
BUILD_COMMAND make
# install step -- don't install it; just use it
INSTALL_COMMAND ""
)
This seems to build fine.
When I try to use it in another CMakeLists.txt file, like this:
target_link_libraries( ${myTarget}
mpsse -lftdi1 -lusb-1.0
)
I get an error:
CMake Error at src/gpio/CMakeLists.txt:30 (target_link_libraries):
Target "mpsse" of type UTILITY may not be linked into another target. One
may link only to INTERFACE, OBJECT, STATIC or SHARED libraries, or to
executables with the ENABLE_EXPORTS property set.
Clearly I’m missing something, but I don’t know how to properly integrate this thing into my project. I’m open to anything, no matter how invasive. Now is the time to get this right (and learn a thing or two in the process)
Clarification
I ran CMake before changing the dependent target, and the external project built fine. Once I made mpsse
a dependency of another project, CMake is no longer happy. So I’m still broken, but not the way I thought I was.
Similar To Intended way to interface with external targets(?)