(Added list back to copy)

On 28 September 2017 at 18:53, Michael Powell <[email protected]> wrote:

> [...]
> >>
> >> Curious CMake would "see" the ENTIRE argument string as
> >> "path-to-source" though. Not sure quite what's going on with that,
> >> though.
> >
> >
> > That's because you're constructing CPPNNG_NNG_CMAKE_OPTIONS as a single
> > string containing spaces. Spaces *in strings* do not delimit CMake
> > arguments, even if spaces in CMake file syntax do. In other words:
> >
> >  foo(a b c)
> >
> > calls 'foo' with 3 arguments: "a", "b", and "c".
> >
> >  set(args a b c)
> >  foo(${args})
> >
> > also calls 'foo' with these 3 arguments.
> >
> > However,
> >
> >   set(args "a b c")
> >   foo(${args})
> >
> > calls 'foo' with only ONE argument: the string "a b c".
> >
> > You need to drop one level of quoting inside your cppnng_nng_add_*
> macros.
> >
> [...]
>
> Thanks for that insight!
>
> I ended up with something like this:
>
> message (STATUS "Invoking CMake: \"${CMAKE_COMMAND}\"
> ${CPPNNG_NNG_CMAKE_OPTIONS} \"${GIT_SUBMODULE_NNG_REPO_DIR}\"")
>
> execute_process (
>     COMMAND "\"${CMAKE_COMMAND}\" ${CPPNNG_NNG_CMAKE_OPTIONS}
> \"${GIT_SUBMODULE_NNG_REPO_DIR}\""
>     WORKING_DIRECTORY "${GIT_SUBMODULE_NNG_REPO_DIR}"
>     RESULT_VARIABLE CPPNN_NNG_CONFIG_EC
>     OUTPUT_VARIABLE CPPNN_NNG_CONFIG_MSG
> )
>
> But which is now yielding an output message " (Access is denied)" (no EC).
>
> Console output:
>
> Invoking CMake: "C:/Dev/CMake/bin/cmake.exe" -G "Visual Studio 14 2015
> Win64" --build "G:/Source/Spikes/nanomsg/cppnngswig-testing/build/nng"
> -D CMAKE_CONFIGURATION_TYPES:STRING="Debug\;Release\;
> MinSizeRel\;RelWithDebInfo"
> -D CMAKE_INSTALL_PREFIX:STRING="G:/Source/Spikes/nanomsg/
> cppnngswig-testing/build/nng"
> -D NNG_ENABLE_COVERAGE:BOOL=OFF -D NNG_ENABLE_DOC:BOOL=OFF -D
> NNG_ENABLE_NNGCAT:BOOL=OFF -D NNG_ENABLE_TESTS:BOOL=OFF -D
> NNG_ENABLE_TOOLS:BOOL=OFF -D NNG_ENABLE_ZEROTIER:BOOL=OFF
> "G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng"
>

You're still putting quotes where there shouldn't be any. Look at this:

   COMMAND "\"${CMAKE_COMMAND}\" ${CPPNNG_NNG_CMAKE_OPTIONS}
\"${GIT_SUBMODULE_NNG_REPO_DIR}\""

Since the entire argument to COMMAND is in quotes, it's interpreted as the
*name* of the command you want to execute. What you want is to pass
multiple arguments to execute_process: one for the binary, and one for each
command-line argument to it. CMake will take care of proper escpaing for
you. So your code should look like this:

execute_process (
    COMMAND "${CMAKE_COMMAND}" ${CPPNNG_NNG_CMAKE_OPTIONS}
"${GIT_SUBMODULE_NNG_REPO_DIR}"
    WORKING_DIRECTORY "${GIT_SUBMODULE_NNG_REPO_DIR}"
    RESULT_VARIABLE CPPNN_NNG_CONFIG_EC
    OUTPUT_VARIABLE CPPNN_NNG_CONFIG_MSG
)

In fact, you can even drop the quotes around the variable dereferncing if
you want to; they're only necessary if the arguments can contain a
semi-colon (as that would split them into multiple CMake arguments). But
they're safe to keep.

Petr
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to