Problem: Installing an external project
I am looking to have CMake clone and build a git repository as an ExternalProject, then package in the resulting binary files with the main project.
The documentation for ExternalProject
mentions this:
Install Step Options:
…
The external project’s install rules are not part of the main project’s install rules, so if anything from the external project should be installed as part of the main build, these need to be specified in the main build as additionalinstall()
commands. The default install step builds theinstall
target of the external project
…
In a sample project I have created an External Project that also uses CMake as its install system, it has an install
command that looks like this:
# External project's install command
install (TARGETS extern_binary
# Literally "SomeDestination", I don't know what directory to put here.
RUNTIME DESTINATION "SomeDestination")
The ExternalProject_Add
command in my main project’s script looks like this:
# main project's ExternalProject_Add command
ExternalProject_Add(
"extern"
GIT_REPOSITORY "[my repository on github here]"
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
)
Unfortunately the executable file from the External Project is not getting packaged in by CPack. The executable file does not appear to be copied to anywhere the main project would know about, either.
Here’s my theories as to what’s happening:
ExternalProject_Add
is not set up to cause the main project to run the External Project’s install step- The main project does run the external project’s install step, but it can’t find the directory containing the built binary file and I need to specify that somewhere
ExternalProject_Add
alone can’t handle the install process automatically and I need to use something in addition to it
Here’s what I’ve found online:
- (1) There is a Linux specific solution, using an INSTALL_COMMAND that involves autotools or make install may work but I need to support Windows which won’t have these tools in our case.
- (2) This mailing list entry is similar but also seems to be Linux only
- (3) This bug report looks promising but if I have my External Project print out the value of
CMAKE_INSTALL_PREFIX
it gives mebuild/extern-prefix
. This is not what I expected, I suppose that I could do something like command cmake to go up a few directories and manually navigate to the right directory and copy the files there, but I’m hoping there’s a better way, because otherwise my External Project will have to be specially configured to work with my main build script.
Questions:
- Is there a parameter I could provide to
ExternalProject_Add
that would cause my external project’s files to be automatically included in the install process? - If this isn’t possible, what is the least intrusive way that I can use
install
commands to accomplish this?
I am hoping there’s a builtin command I missed that would work seamlessly on all platforms (Windows, Mac, and Linux). Let me know if there’s something I missed here.
Thanks,