[CMake] external project add and configure

Owen Hogarth II gurenchan at gmail.com
Tue Dec 15 11:53:44 EST 2015


In response to myself I've figure it out with using add_step function and
calling some commands.

Full source for what's working building both external libraries.

include(ExternalProject)

ExternalProject_Add(sdl
    HG_REPOSITORY http://hg.libsdl.org/SDL
    UPDATE_COMMAND hg pull -u http://hg.libsdl.org/SDL

    CMAKE_ARGS -DSDL_STATIC:BOOL=FALSE
    -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}

    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDL

    INSTALL_DIR ${CMAKE_BINARY_DIR}
    )

ExternalProject_Get_Property(sdl install_dir)
SET(SDL_INSTALL_DIR ${install_dir})

ExternalProject_Add(sdl_image
    DEPENDS sdl
    HG_REPOSITORY http://hg.libsdl.org/SDL_image/
    UPDATE_COMMAND hg pull -u http://hg.libsdl.org/SDL_image/
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image/./autogen.sh #this works

    CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image/./configure
                      --prefix=${SDL_INSTALL_DIR}

    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image

    INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
    )
ExternalProject_Get_Property(sdl_image install_dir)
SET(SDL_IMAGE_INSTALL_DIR ${install_dir})

this installs the sdl things in
build-tree/lib
build-tree/include
build-tree/share

but even if I try to hardcode the path's they don't get picked up. The
other libraries not build with external project add cannot find those
files. How do I get those files to be picked up by the regular cmake build?

Also I have one further question though they might be related and can be
solved at the same time.

I would like to add this to my external projects, their include directories
are located in
TARGET_INCLUDE_DIRECTORIES(sdl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)



On Tue, Dec 15, 2015 at 8:47 PM, Owen Hogarth II <gurenchan at gmail.com>
wrote:

> I was able to build the external project that required cmake like this:
> include(ExternalProject)
>
> ExternalProject_Add(sdl
>     HG_REPOSITORY http://hg.libsdl.org/SDL
>     UPDATE_COMMAND hg pull -u http://hg.libsdl.org/SDL
>
>     CMAKE_ARGS -DSDL_STATIC:BOOL=FALSE
>     -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/lib
>
>     SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDL
>
>     INSTALL_DIR ${CMAKE_BINARY_DIR}
>     )
> ExternalProject_Get_Property(sdl install_dir)
> SET(SDL_INSTALL_DIR ${install_dir})
>
>
> now this second file uses ./configure to set up it's environment.
> I can build it by going into the folder first running ./autogen.sh then
> ./configure ...
>
> or If I use this external project script below
> ExternalProject_Add(sdl_image
>     DEPENDS sdl
>     HG_REPOSITORY http://hg.libsdl.org/SDL_image/
>     UPDATE_COMMAND hg pull -u http://hg.libsdl.org/SDL_image/
>
>     # MAKE_COMMAND make
>     CONFIGURE_COMMAND  ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image/./configure
>     --prefix=${SDL_INSTALL_DIR}/lib
> #adding this prefix I get further in my build then I get an error
>
>     SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/SDL_image
>
>     INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}
>     )
>
> error:
> missing: line 81: aclocal-1.13:
>  command not found
> WARNING: 'aclocal-1.13' is missing on your system.
>          You should only need it if you modified 'acinclude.m4' or
>          'configure.ac' or m4 files included by 'configure.ac'.
>          The 'aclocal' program is part of the GNU Automake package:
>          <http://www.gnu.org/software/automake>
>          It also requires GNU Autoconf, GNU m4 and Perl in order to run:
>          <http://www.gnu.org/software/autoconf>
>          <http://www.gnu.org/software/m4/>
>          <http://www.perl.org/>
>
> I can't actually get cmake to run the autogen script for me. If I leave
> and manually go run ./autogen.sh and then re-run this cmake command things
> will built correctly.
>
> How can I run the autogen.sh command from within that
> "ExternalProject_Add(sdl_image ..)" block?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151216/24c65590/attachment.html>


More information about the CMake mailing list