[CMake] using variables in ExternalProject_Add arguments

Kris Thielemans kris.f.thielemans at gmail.com
Sat Jun 22 05:53:29 EDT 2019


Dear all

 

I've managed to resolve this. My mistake was to use quotes:

 

WRONG:

  set(HDF5_CMAKE_ARGS

    "-DHDF5_ROOT:PATH=${HDF5_ROOT}

     -DHDF5_INCLUDE_DIRS:PATH=${HDF5_INCLUDE_DIRS}

     -DHDF5_FIND_DEBUG:BOOL=ON"

  )

 

CORRECT:

  set(HDF5_CMAKE_ARGS

     -DHDF5_ROOT:PATH=${HDF5_ROOT}

     -DHDF5_INCLUDE_DIRS:PATH=${HDF5_INCLUDE_DIRS}

     -DHDF5_FIND_DEBUG:BOOL=ON

  )

 

 

WRONG:

set(PATCH_COMMAND "${GIT} apply ${PATCHFILE}")

 

CORRECT:

set(PATCH_COMMAND ${GIT} apply ${PATCHFILE})

 

Kris

 

From: Kris Thielemans <kris.f.thielemans at gmail.com> 
Sent: 21 June 2019 16:19
To: 'CMake Mail List' <cmake at cmake.org>
Subject: using variables in ExternalProject_Add arguments

 

Dear all

 

We have a Superbuild https://github.com/CCPPETMR/SIRF-SuperBuild. I'm trying
to introduce variables to reduce duplication. However, I'm getting weird
errors. 2 examples below. Any ideas? (I'm running this on Windows 10 at
present with CMake 3.13.2).

 

Many thanks

Kris

 

1.	Use of a variable for CMAKE_ARGS

 

ExternalProject_Add(${proj}

    ${${proj}_EP_ARGS}

    GIT_REPOSITORY ${${proj}_URL}

    GIT_TAG ${${proj}_TAG} 

    CMAKE_ARGS 

            ${HDF5_CMAKE_ARGS}

            -DBOOST_ROOT=${BOOST_ROOT}

    INSTALL_DIR ${ISMRMRD_Install_Dir}

 

With 

HDF5_CMAKE_ARGS=-DHDF5_ROOT:PATH=C:/Users/krisf/Documents/devel/build-VC/SIR
F-SuperBuild/INSTALL

 
-DHDF5_INCLUDE_DIRS:PATH=C:/Users/krisf/Documents/devel/build-VC/SIRF-SuperB
uild/INSTALL/include

       -DHDF5_FIND_DEBUG:BOOL=ON

 

Error:

5>  Performing configure step for 'ISMRMRD'

5>CUSTOMBUILD : CMake error : The source directory
"C:/Users/krisf/Documents/devel/build-VC/SIRF-SuperBuild/builds/ISMRMRD/buil
d" does not appear to contain CMakeLists.txt.

 

Indeed, that directory is where we sk the SuperBuild to build. The sources
sit in .SIRF-SuperBuild/sources/ISMRMRD. Why does it go to the build
directory? 

All works ok  when commenting out the HDF5_CMAKE_ARGS line, or by putting
its value directly in the ExternalProject_Add.

 

 

2.	Use of a variable for PATCH_COMMAND

 

find_program(GIT "git")

set(PATCH_COMMAND "${GIT} apply ${PATCHFILE}")

 

  ExternalProject_Add(${proj}

    ${${proj}_EP_ARGS}

    URL ${${proj}_URL}

    URL_HASH MD5=${${proj}_MD5}

    PATCH_COMMAND ${PATCH_COMMAND}

    ...

   )

 

Error:

2>  Performing patch step for 'HDF5'

2>  The filename, directory name, or volume label syntax is incorrect.

 

Everything works fine if I use

   PATCH_COMMAND ${GIT} apply ${PATCHFILE}

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190622/182b36c4/attachment.html>


More information about the CMake mailing list