[CMake] ExternalProject + Patch command

Johan Björk phb at spotify.com
Wed Mar 23 02:28:58 EDT 2011


Thanks guys.

I ended up with a different (hack) way:

To recap, my issue was that my patch would be applied twice when
building with multi-configuration generators.

Since I am always building the external project with a release
configuration, the following worked fine to disable the
multi-configuration code for the external project.

   SET(_backup ${CMAKE_CONFIGURATION_TYPES})
   SET(CMAKE_CONFIGURATION_TYPES "" CACHE STRING "" FORCE)
   ExternalProject_Add(foo
   ….
   )
  ExternalProject_Get_Property(....)
SET(CMAKE_CONFIGURATION_TYPES "${_backup}" CACHE STRING "" FORCE)

/Johan

On Wed, Mar 16, 2011 at 6:26 PM, Luigi Calori <l.calori at cineca.it> wrote:
> On 16/03/2011 17.37, David Cole wrote:
>>
>> It would be nice (as a future feature addition) to be able to support
>> sharing the download/update/patch/source_dir aspects of an
>> ExternalProject target among multiple configurations and avoid the
>> multiple runs of these things that are exactly the same independent of
>> the config.
>>
>> Until that dream becomes reality, though.....
>
> I had once modified the External to include support for <SRC_STAMP_DIR>
> #    [SRCSTAMP_DIR dir]          # Directory to store source step timestamps
>
> I still have the file but i unfortunated did not kept it up to date with
> recent mods
>>
>> You could run a script as the PATCH_COMMAND, and put some sort of "has
>> this patch already been applied to this source tree" logic into the
>> script, and only actually do the patch command if not already applied.
>>
>> It's a work-around, and might be ugly, but it should work.
>
> Another way is to split the project in two:
>
> one build the source and the other do the config,build,install like
>
> ExternalProject_Add(
>    ${PACKAGE}-GetSource
>    SOURCE_DIR ${Package_Source_Dir}
>    STAMP_DIR ${Package_Source_Stamp_Dir}
> <----------------------------------------------- I set this in a place
> "near" the sources, so can remove the build without re-patch
>    SVN_REPOSITORY ........................
>    PATCH_COMMAND <----- your patch--->
>    UPDATE_COMMAND ""
>    CONFIGURE_COMMAND ""
>    BUILD_COMMAND ""
>    INSTALL_COMMAND ""
> )
>
> if(Package_current_dependencies_effective_line)
>    set( Package_current_dependencies_effective_line
> ${Package_current_dependencies_effective_line} ${PACKAGE}-GetSource)
> else()
>    set(Package_current_dependencies_effective_line DEPENDS
> ${PACKAGE}-GetSource)
> endif()
>
>
>
> ExternalProject_Add(
>    ${PACKAGE}
>    SOURCE_DIR ${Package_Source_Dir}
>    DOWNLOAD_COMMAND "" <--------------------------------------this is
> important
>    BUILD_DIR ......
>   INSTALL_DIR ............
>    CMAKE_COMMAND ${CMAKE_COMMAND}
>    CMAKE_ARGS
>        ${Package_std_cmake_args}
>        ${Package_additional_cmake_args}
>    BUILD_COMMAND ........
>    INSTALL_COMMAND ....................
>    ${Package_current_dependencies_effective_line} <------------------------
> add ${PACKAGE}-GetSource to your dependencies
>    STEP_TARGETS configure build
>
> )
>
> HTH
>                Luigi
>
>
>>
>> HTH,
>> David
>>
>>
>> On Wed, Mar 16, 2011 at 11:40 AM, Johan Björk<phb at spotify.com>  wrote:
>>>
>>> Hi everyone,
>>>
>>>
>>> I'm using an SVN repository and a PATCH command. It seems to work
>>> fine, but when I'm selecting a different build configuration, all
>>> steps will be executed again (as expected), but it results in my patch
>>> being applied twice.
>>>
>>> Any ideas how to work around this?
>>>
>>> My externalProject command for reference:
>>>
>>>    ExternalProject_Add(Breakpad
>>>      SVN_REPOSITORY http://google-breakpad.googlecode.com/svn/trunk/
>>>      UPDATE_COMMAND ""
>>>      CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
>>> -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
>>> -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
>>>      PATCH_COMMAND patch<
>>> ${CMAKE_CURRENT_LIST_DIR}/other/patches/breakpad.patch
>>>    )
>>>
>>> Thanks
>>> /Johan
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the CMake FAQ at:
>> http://www.cmake.org/Wiki/CMake_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>



-- 
Johan Björk
Team Lead, Development Tools
Spotify AB
Address: Birger Jarlsgatan 6, 114 46 Stockholm, Sweden
Phone:+46 (0)709 22 59 02
This e-mail (including any attachments) may contain information that is
confidential and/or privileged. It is intended only for the recipient(s).
If you have reason to believe that you are not the intended recipient of
this e-mail, please contact the sender immediately and delete the e-mail
from your computer.


More information about the CMake mailing list