Frank Blabu
Frank Blabu

Reputation: 201

CMake: Download and unpack multiple files in ExternalProject_Add

I would like to compile OpenSSL automatically on Windows using the ExternalProject features of CMake. In the configuration, I can specify one download URL. But I need multiple additional files which I'd like to be unpacked into the same source directory. So this is the intention:

ExternalProject_Add ( ${CMAKE_PROJECT_NAME}    
    PREFIX              ${CMAKE_COMPILE_ROOT}/3rd/${CMAKE_PROJECT_NAME}
    URL                 //sw-storage/3rd/src/${OPENSSL_NAME}/jom.zip
    URL                 //sw-storage/3rd/src/${OPENSSL_NAME}/nasm-2.14.02-win64.zip
    URL                 //sw-storage/3rd/src/${OPENSSL_NAME}/strawberry-perl-5.30.0.1-64bit.zip
    URL                 //sw-storage/3rd/src/${OPENSSL_NAME}/openssl-1.1.1c.tar.gz
    CONFIGURE_COMMAND   perl Configure VC-WIN64A no-idea no-mdc2 no-rc5 --prefix=${INSTALL_DIR} --openssldir=${INSTALL_DIR}/ssl
    BUILD_IN_SOURCE     1
    BUILD_COMMAND       jom.exe
    INSTALL_COMMAND     jom.exe install

This does not seem to be possible. Specifying multiple URL entries leads to the following error message:

CMake Error at C:/build/cmake-3.13.4/share/cmake-3.13/Modules/ExternalProject.cmake:2455 (message): 
At least one entry of URL is a path (invalid in a list)

Is there a way to do this in CMake ?

Upvotes: 2

Views: 1645

Answers (1)

duncan
duncan

Reputation: 6283

CMake documentation states that when more than one URL is specified, they are fall-backs of each-other.

List of paths and/or URL(s) of the external project’s source. When more than one URL is given, they are tried in turn until one succeeds.

URL_HASH is specified only once, therefore CMake expects all URLs to point to the same file.

In this case, you would need individual projects, and the DEPENDS option of ExternalProject to control dependencies, or try any of the CMake based OpenSSL builds out there, add it with ExternalProject and check if those take care of the dependencies already.

Upvotes: 1

Related Questions