Re: [CMake] error executing script with cmake -P

2019-10-17 Thread Edoardo Pasca
Hi Tom,

I thought ${testdata} was going to be filled in by the actual
patch_script.cmake at this line.

file (STRINGS TestData.py testdata NEWLINE_CONSUME)

 So it appears that this command doesn't quite work.

I'll try also Alan's suggestion.

Thanks

Edo

On Tue, Oct 15, 2019 at 7:00 PM Tom Finegan  wrote:

> It looks like you aren't passing the $testdata variable down to the
> script. From your message it looks like you need to add the following to
> your PATCH_COMMAND:
>
> -Dtestdata=${testdata}
>
> You must explicitly pass $testdata (and any other variables defined in the
> calling script) to patch_script.cmake via -D parameters on the command
> line. Also note that the -Dvar=value args must precede the -P 

[CMake] error executing script with cmake -P

2019-10-14 Thread Edoardo Pasca
Dear all,

I am using external project. I would like to patch a source file. I came
out with a cmake script that does the string replacement I'm interested in.

I tested in a standalone project, with the following CMakeLists.txt

cmake_minimum_required(VERSION 3.4)
project(patching_string)
file (STRINGS TestData.py testdata NEWLINE_CONSUME)
string(REPLACE "sys.prefix" "os.environ[\'SIRF_INSTALL_PATH\']" patched
${testdata})
file( WRITE ${CMAKE_CURRENT_SOURCE_DIR}/TestData.py ${patched} )

and as a matter of facts this does the string replacement I'm interested in.

Good, now I would like to use this to the project I'm really interested in
which uses the ExternalProject_Add machinery. I added the patch step:



file (WRITE ${CMAKE_BINARY_DIR}/patch_script.cmake "
file (STRINGS
${${proj}_SOURCE_DIR}/Wrappers/Python/ccpi/framework/TestData.py testdata
NEWLINE_CONSUME)
string(REPLACE \"sys.prefix\" \"os.environ[\\\'SIRF_INSTALL_PATH\\\']\"
patched \${testdata})
file( WRITE
${${proj}_SOURCE_DIR}/Wrappers/Python/ccpi/framework/TestData.py
\${patched} ) ")
ExternalProject_Add(
...

PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/patch_script.cmake

... )



Notice that I write the patch_script.cmake before the ExternalProject_Add


Now, all of this WORKS. Or at least I get the patch_script.cmake file in
the proper directoty, with the content I want. However, execution with
cmake -P patch_script.cmake doesn't work as expected.

I get
CMake Error at build/patch_script.cmake:3 (string):
  string sub-command REPLACE requires at least four arguments.

Given that the patch_script.cmake has the same content of the standalone
CMakeLists.txt above (without the first 2 lines), I don't know where things
don't go well, except that I execute the script with cmake -P

cmake version 3.15.2

Thanks for any help.

Edo


-- 
Edo
I know you think you understand what you thought I said, but I'm not sure
you realize that what you heard is not what I meant (prob. Alan Greenspan)
:wq
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


Re: [CMake] external project CONFIGURE_COMMAND adds quotation to arguments

2019-09-04 Thread Edoardo Pasca
Brilliant!

your suggestion has worked!

Thank you so much

Edo

On Wed, Sep 4, 2019 at 11:23 AM Eric Doenges  wrote:

> On 04.09.2019 11:55, Edoardo Pasca wrote:
>
> Dear all,
>
> I'm using ExternalProjectAdd to build an external package.
>
> On the CONFIGURE_COMMAND I have to pass some variables to the configure
> script in this form:
>
> configure CPPFLAGS="-I/dir/include -L/dir/lib"
>
> To do this I use
>
> CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/configure
> CPPFLAGS="-I/dir/include -L/dir/lib"
>
> However, when cmake issues that command (you can see that with make
> VERBOSE=1) it wraps the CPPFLAGS parameters with quotation marks (as below)
> and the configure script fails
>
> configure "CPPFLAGS=\"-I/dir/include -L/dir/lib\""
>
> Below you can find a minimal CMakeLists.txt to test this.
>
> I'd appreciate any help on how I'd remove those quotation marks.
>
> Thanks
>
> Edo
>
>
> What I do is let CMake handle this itself by defining a (list) variable
> for the configure command:
>
> set(cmd "${CMAKE_BINARY_DIR}/configure")
> list(APPEND cmd "CPPFLAGS=-I/dir/include -L/dir/lib")
> ExternalProject_Add(...
>   CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${cmd}
>   ...)
>
> Since cmd is a list, CMake knows that the -L/dir/lib belongs to the
> CPPFLAGS=-I/dir/include part, and puts double quotes around the entire
> thing, e.g. the actual command line will look something like this:
>
> /configure "CPPFLAG=-Idir/include -L/dir/lib"
> This works with GNU autoconf. I've found that in general, dealing with
> quoting in ExternalProject_Add is a gigantic pain, so if the method above
> is not sufficient, I use configure_file or file(WRITE) to generate a shell
> script (Linux) or batch file (Windows) with the correct parameters and call
> that instead.
>
> With kind regards,
> Eric Dönges
>
> *Dr. Eric Dönges *
> Senior Software Engineer
>
> MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
> doen...@mvtec.com | Tel: +49 89 457 695-0 | www.mvtec.com
>
>  Sign up <http://www.mvtec.com/newsletter> for our MVTec Newsletter!
>
> Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
> Amtsgericht München HRB 114695
>
>
> [image: MVTec Software GmbH Logo]
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> https://cmake.org/mailman/listinfo/cmake
>


-- 
Edo
I know you think you understand what you thought I said, but I'm not sure
you realize that what you heard is not what I meant (prob. Alan Greenspan)
:wq
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


[CMake] external project CONFIGURE_COMMAND adds quotation to arguments

2019-09-04 Thread Edoardo Pasca
Dear all,

I'm using ExternalProjectAdd to build an external package.

On the CONFIGURE_COMMAND I have to pass some variables to the configure
script in this form:

configure CPPFLAGS="-I/dir/include -L/dir/lib"

To do this I use

CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/configure
CPPFLAGS="-I/dir/include -L/dir/lib"

However, when cmake issues that command (you can see that with make
VERBOSE=1) it wraps the CPPFLAGS parameters with quotation marks (as below)
and the configure script fails

configure "CPPFLAGS=\"-I/dir/include -L/dir/lib\""

Below you can find a minimal CMakeLists.txt to test this.

I'd appreciate any help on how I'd remove those quotation marks.

Thanks

Edo



cmake_minimum_required(VERSION 3.9.0)

project(libACE)
include(ExternalProject)

#create a configure script
file(WRITE ${CMAKE_SOURCE_DIR}/configure
"
#! /bin/bash

echo $0 received $# parameters

for arg
do echo $arg
done
")
file(COPY ${CMAKE_SOURCE_DIR}/configure
 DESTINATION ${CMAKE_BINARY_DIR}
 FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)
ExternalProject_Add(
  external_test
  GIT_REPOSITORY https://github.com/paskino/libace-conda
  GIT_TAG origin/master

  CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env ${CMAKE_BINARY_DIR}/configure
NVCCFLAGS="-Idir -Ldir" CPPFLAGS="-Idirc -Ldirl"

  BUILD_COMMAND ""
  INSTALL_COMMAND ""

  LOG_INSTALL 1
  BINARY_DIR ${CMAKE_BINARY_DIR}/build/
  INSTALL_DIR ${CMAKE_BINARY_DIR}/install
  STAMP_DIR ${CMAKE_BINARY_DIR}/stamp
  TMP_DIR ${CMAKE_BINARY_DIR}/tmp
  DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/download
  SOURCE_DIR ${CMAKE_BINARY_DIR}/source
)

-- 
Edo
I know you think you understand what you thought I said, but I'm not sure
you realize that what you heard is not what I meant (prob. Alan Greenspan)
:wq
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake