[CMake] Anyone gotten OpenSSL to build as an external project?

Pau Garcia i Quiles pgquiles at elpauer.org
Fri Jan 14 16:41:58 EST 2011


On Fri, Jan 14, 2011 at 9:52 PM, David Cole <david.cole at kitware.com> wrote:
>> - Add a PATH parameter to ExternalProject_Add,
>> ExternalProject_Add_Step and execute_process. It should override the
>> default path. Adding new directories to the path would be possible by
>> doing PATH "$ENV{PATH}:/my/new/dir/in/path"
>
> Good suggestion. Actually, we've wanted to add a feature to specify
> environment variables to arbitrary calls to add_custom_command for quite a
> while, but there are some subtle details behind it, and we haven't found the
> time and funding to get that done yet. This would be an easy pass-through
> from ExternalProject to such a feature as soon as the underlying feature
> exists in add_custom_command.

What are those subtle details?

>> - Define variables for SOURCE_DIR, BINARY_DIR, etc even if EP_PREFIX
>> and EP_BASE are not set
>
> Not sure what you mean here?
>
> If you got a ExternalProject_Get_Property(${proj} source_dir) immediately
> after an ExternalProject_Add call you can retrieve the value of its source
> dir regardless of if you have EP_PREFIX or EP_BASE set, right? Those only
> control some of the default layouts that we had come up with when trying to
> organize things.

For OpenSSL, I need to know ExternalProject_Get_Property(${proj}
source_dir) *while* I am still in ExternalProject_Add. This is still
work in progress but here is what I am doing now:

ExternalProject_Add( openssl
    DEPENDS zlib
    DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/downloads
    URL http://openssl.org/source/openssl-1.0.0c.tar.gz
    PATCH_COMMAND ${PROJECT_SOURCE_DIR}/bin/patch.exe -p1 <
${PROJECT_SOURCE_DIR}/downloads/openssl-1.0.0c.patch
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ${CMAKE_COMMAND} -DWINST_DIR=${PROJECT_SOURCE_DIR}
-DOPENSSL_SOURCE_DIR=${PROJECT_BINARY_DIR}/openssl-prefix/src/openssl/
-DOPENSSL_GENASM_COMMAND=${OPENSSL_GENASM_COMMAND}
-DOPENSSL_CONFIGURE_COMMAND=${OPENSSL_CONFIGURE_COMMAND}
-DOPENSSL_BUILD_COMMAND=${OPENSSL_BUILD_COMMAND}
-DOPENSSL_INSTALL_COMMAND="${OPENSSL_BUILD_COMMAND} install" -P
${PROJECT_SOURCE_DIR}/configure-openssl.cmake
    BUILD_IN_SOURCE 1
    )

Where configure-openssl.cmake is generates the assembly code, runs
perl Configure, nmake and nmake install. The relevant part here is

-DOPENSSL_SOURCE_DIR=${PROJECT_BINARY_DIR}/openssl-prefix/src/openssl/

in BUILD_COMMAND. OpenSSL must be built in-tree, which means you need
to know where the source tree is while in the ExternalProject_Add
call.

>> - Allow for multiple CONFIGURE_COMMAND steps (I know, I can add my
>> custom step, but it's much more complex)
>
> How many would you like? Why not just run a script as the single configure
> command, and then have your script do the multiple steps needed?

That's what I'm currently doing, which is why I have the problem
above: I need to know the source directory, the build directory, etc
of that ExternalProject. That means you need to pass variables, set
PATH, etc. It'd be easier if an arbitrary number of CONFIGURE_COMMAND
would be run in order before the BUILD_COMMAND.

>> Another more issue I'm seeing with ExternalProject_Add is tarballs
>> with symlinks on Windows. The OpenSSL contains symlinks, which leads
>> to a broken source dir because CMake is unable to create some files.
>> Maybe CMake should pass libarchive some parameter? (if I extract the
>> OpenSSL tarball with WinRAR, it does not fail)
>
> What does WinRAR give you? Symlinks because the Windows you're using
> supports them? Or copies of the linked-to files in place of symlinks? Or
> something else?

Copies of the linked-to files in place of symlinks.

-- 
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


More information about the CMake mailing list