[cmake-developers] [PATCH] ExternalProject_Add: Allow generator expressions in CMAKE_CACHE_ARGS

Andrey Pokrovskiy wonder.mice at gmail.com
Fri Apr 17 00:55:32 EDT 2015


In current implementation of ExternalProject_Add generator expressions
are supported in CMAKE_ARGS (probably by coincidence), but not in
CMAKE_CACHE_ARGS. This patch will enable generators expressions in
CMAKE_CACHE_ARGS.

Use case:
set(LIBEV_LIBRARIES $<TARGET_FILE:ev>)
ExternalProject_Add(
    ...
    CMAKE_CACHE_ARGS
         -DLIBEV_LIBRARIES=${LIBEV_LIBRARIES}
    ...)

---
 Modules/ExternalProject.cmake | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 0c73d41..1c7cf51 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1126,10 +1126,7 @@ function(_ep_write_initial_cache target_name
script_filename script_initial_cach
   # Replace location tags.
   _ep_replace_location_tags(${target_name} script_initial_cache)
   # Write out the initial cache file to the location specified.
-  if(NOT EXISTS "${script_filename}.in")
-    file(WRITE "${script_filename}.in" "\@script_initial_cache\@\n")
-  endif()
-  configure_file("${script_filename}.in" "${script_filename}")
+  file(GENERATE OUTPUT "${script_filename}" CONTENT "${script_initial_cache}")
 endfunction()


-- 
2.3.2 (Apple Git-55)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ExternalProject_Add-Allow-generator-expressions-in-C.patch
Type: application/octet-stream
Size: 1080 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20150416/2c6fdd03/attachment-0001.obj>


More information about the cmake-developers mailing list