Execute CMake process not working: source directory confusion

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Execute CMake process not working: source directory confusion

Michael Powell
Hello,

This is fairly long, but this is intentional. I message the "Invoking" message.

Invoking CMake: C:/Dev/CMake/bin/cmake.exe -G "Visual Studio 14 2015
Win64" -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

Prior to running:

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

Which is yielding:

CMake Error: The source directory
"G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/ -G "Visual
Studio 14 2015 Win64" -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" does not
exist.

The GIT_SUBMODULE_NNG_REPO_DIR is indeed set to
G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/, so how can
that not be the source directory? But further, how is it seeing the
rest of the options as "source directory"?

I only got to this point by doing what seems like extreme string
gymnastics just to arrive at what I think is an appropriate command.

i.e.

macro (cppnng_nng_add_cmake_generator GEN)
    set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -G \"${GEN}\"")
endmacro ()

macro (cppnng_nng_add_cmake_var OPT TYPE VALUE)
    set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -D
${OPT}:${TYPE}=${VALUE}")
endmacro ()

    cppnng_nng_add_cmake_generator ("${CMAKE_GENERATOR}")

    # This is like string GYMNASTICS in order to allow semi-colons to
properly pass through.
    string(REPLACE ";" "\;" REPLACED_TYPES "${CMAKE_CONFIGURATION_TYPES}")
    cppnng_nng_add_cmake_var ("CMAKE_CONFIGURATION_TYPES" STRING
"\"${REPLACED_TYPES}\"")

    cppnng_nng_add_cmake_var ("CMAKE_INSTALL_PREFIX" STRING
"\"${cppnng_SOURCE_DIR}/build/nng\"")
    cppnng_nng_add_cmake_var ("NNG_ENABLE_COVERAGE" BOOL OFF)
    cppnng_nng_add_cmake_var ("NNG_ENABLE_DOC" BOOL OFF)
    cppnng_nng_add_cmake_var ("NNG_ENABLE_NNGCAT" BOOL OFF)
    cppnng_nng_add_cmake_var ("NNG_ENABLE_TESTS" BOOL OFF)
    cppnng_nng_add_cmake_var ("NNG_ENABLE_TOOLS" BOOL OFF)
    # TODO: TBD: at the moment we do not care about ZeroTier, but this
could change moving forward.
    cppnng_nng_add_cmake_var ("NNG_ENABLE_ZEROTIER" BOOL OFF)

    # message (FATAL_ERROR "options: ${CPPNNG_NNG_CMAKE_OPTIONS}")

    # message (STATUS "${REPLACED_TYPES}")

    message (STATUS "Invoking CMake: " "${CMAKE_COMMAND}"
${CPPNNG_NNG_CMAKE_OPTIONS})

Cheers,

Michael Powell
--

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 | Threaded
Open this post in threaded view
|

Re: Execute CMake process not working: source directory confusion

Michael Powell
On Thu, Sep 28, 2017 at 12:06 PM, Michael Powell <[hidden email]> wrote:

> ---------- Forwarded message ----------
> From: Michael Powell <[hidden email]>
> Date: Thu, Sep 28, 2017 at 12:06 PM
> Subject: Execute CMake process not working: source directory confusion
> To: [hidden email]
>
>
> Hello,
>
> This is fairly long, but this is intentional. I message the "Invoking" message.

Ah, I figured it out!

From the help:

cmake [options] <path-to-source>

So I simply tacked on a "\"${GIT_SUBMODULE_NNG_REPO_DIR}\"" where
<path-to-source> was expected.

Curious CMake would "see" the ENTIRE argument string as
"path-to-source" though. Not sure quite what's going on with that,
though.

The outcome wasn't quite what I expected. How do I specify "path to
source", where the source CMakeLists.txt is, properly. And the path to
the build, where I want the build environment to land?

With this scenario, currently things are landing "in the source
directory", which is incorrect, not what I am expecting.

Probably my confusion over, prefix directory? Or is "source" directory
where things actually land?

Thanks!

> Invoking CMake: C:/Dev/CMake/bin/cmake.exe -G "Visual Studio 14 2015
> Win64" -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
>
> Prior to running:
>
> execute_process (
>     COMMAND "${CMAKE_COMMAND}" ${CPPNNG_NNG_CMAKE_OPTIONS}
>     WORKING_DIRECTORY "${GIT_SUBMODULE_NNG_REPO_DIR}"
>     RESULT_VARIABLE CPPNN_NNG_CONFIG_EC
>     OUTPUT_VARIABLE CPPNN_NNG_CONFIG_MSG
> )
>
> Which is yielding:
>
> CMake Error: The source directory
> "G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/ -G "Visual
> Studio 14 2015 Win64" -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" does not
> exist.
>
> The GIT_SUBMODULE_NNG_REPO_DIR is indeed set to
> G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/, so how can
> that not be the source directory? But further, how is it seeing the
> rest of the options as "source directory"?
>
> I only got to this point by doing what seems like extreme string
> gymnastics just to arrive at what I think is an appropriate command.
>
> i.e.
>
> macro (cppnng_nng_add_cmake_generator GEN)
>     set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -G \"${GEN}\"")
> endmacro ()
>
> macro (cppnng_nng_add_cmake_var OPT TYPE VALUE)
>     set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -D
> ${OPT}:${TYPE}=${VALUE}")
> endmacro ()
>
>     cppnng_nng_add_cmake_generator ("${CMAKE_GENERATOR}")
>
>     # This is like string GYMNASTICS in order to allow semi-colons to
> properly pass through.
>     string(REPLACE ";" "\;" REPLACED_TYPES "${CMAKE_CONFIGURATION_TYPES}")
>     cppnng_nng_add_cmake_var ("CMAKE_CONFIGURATION_TYPES" STRING
> "\"${REPLACED_TYPES}\"")
>
>     cppnng_nng_add_cmake_var ("CMAKE_INSTALL_PREFIX" STRING
> "\"${cppnng_SOURCE_DIR}/build/nng\"")
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_COVERAGE" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_DOC" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_NNGCAT" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_TESTS" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_TOOLS" BOOL OFF)
>     # TODO: TBD: at the moment we do not care about ZeroTier, but this
> could change moving forward.
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_ZEROTIER" BOOL OFF)
>
>     # message (FATAL_ERROR "options: ${CPPNNG_NNG_CMAKE_OPTIONS}")
>
>     # message (STATUS "${REPLACED_TYPES}")
>
>     message (STATUS "Invoking CMake: " "${CMAKE_COMMAND}"
> ${CPPNNG_NNG_CMAKE_OPTIONS})
>
> Cheers,
>
> Michael Powell
--

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 | Threaded
Open this post in threaded view
|

Re: Execute CMake process not working: source directory confusion

Petr Kmoch
Hi Michael.

On 28 September 2017 at 18:18, Michael Powell <[hidden email]> wrote:
On Thu, Sep 28, 2017 at 12:06 PM, Michael Powell <[hidden email]> wrote:
> ---------- Forwarded message ----------
> From: Michael Powell <[hidden email]>
> Date: Thu, Sep 28, 2017 at 12:06 PM
> Subject: Execute CMake process not working: source directory confusion
> To: [hidden email]
>
>
> Hello,
>
> This is fairly long, but this is intentional. I message the "Invoking" message.

Ah, I figured it out!

From the help:

cmake [options] <path-to-source>

So I simply tacked on a "\"${GIT_SUBMODULE_NNG_REPO_DIR}\"" where
<path-to-source> was expected.

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.
 

The outcome wasn't quite what I expected. How do I specify "path to
source", where the source CMakeLists.txt is, properly. And the path to
the build, where I want the build environment to land?

With this scenario, currently things are landing "in the source
directory", which is incorrect, not what I am expecting.

Once you solve the quoting issue, you should be able to pass what you want as the source directory. It's effectively the first non-option argument to 'cmake'.

The generated buildsystem lands in the working directory from which cmake was invoked. So what you want is this:

execute_process(
  ${CMAKE_COMMAND} ${CPPNNG_NNG_CMAKE_OPTIONS} ${GIT_SUBMODULE_NNG_REPO_DIR}
  WORKING_DIRECTORY wherever/you/want/the/buildystem/to/end/up
)

Petr
 

Probably my confusion over, prefix directory? Or is "source" directory
where things actually land?

Thanks!

> Invoking CMake: C:/Dev/CMake/bin/cmake.exe -G "Visual Studio 14 2015
> Win64" -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
>
> Prior to running:
>
> execute_process (
>     COMMAND "${CMAKE_COMMAND}" ${CPPNNG_NNG_CMAKE_OPTIONS}
>     WORKING_DIRECTORY "${GIT_SUBMODULE_NNG_REPO_DIR}"
>     RESULT_VARIABLE CPPNN_NNG_CONFIG_EC
>     OUTPUT_VARIABLE CPPNN_NNG_CONFIG_MSG
> )
>
> Which is yielding:
>
> CMake Error: The source directory
> "G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/ -G "Visual
> Studio 14 2015 Win64" -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" does not
> exist.
>
> The GIT_SUBMODULE_NNG_REPO_DIR is indeed set to
> G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/, so how can
> that not be the source directory? But further, how is it seeing the
> rest of the options as "source directory"?
>
> I only got to this point by doing what seems like extreme string
> gymnastics just to arrive at what I think is an appropriate command.
>
> i.e.
>
> macro (cppnng_nng_add_cmake_generator GEN)
>     set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -G \"${GEN}\"")
> endmacro ()
>
> macro (cppnng_nng_add_cmake_var OPT TYPE VALUE)
>     set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -D
> ${OPT}:${TYPE}=${VALUE}")
> endmacro ()
>
>     cppnng_nng_add_cmake_generator ("${CMAKE_GENERATOR}")
>
>     # This is like string GYMNASTICS in order to allow semi-colons to
> properly pass through.
>     string(REPLACE ";" "\;" REPLACED_TYPES "${CMAKE_CONFIGURATION_TYPES}")
>     cppnng_nng_add_cmake_var ("CMAKE_CONFIGURATION_TYPES" STRING
> "\"${REPLACED_TYPES}\"")
>
>     cppnng_nng_add_cmake_var ("CMAKE_INSTALL_PREFIX" STRING
> "\"${cppnng_SOURCE_DIR}/build/nng\"")
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_COVERAGE" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_DOC" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_NNGCAT" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_TESTS" BOOL OFF)
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_TOOLS" BOOL OFF)
>     # TODO: TBD: at the moment we do not care about ZeroTier, but this
> could change moving forward.
>     cppnng_nng_add_cmake_var ("NNG_ENABLE_ZEROTIER" BOOL OFF)
>
>     # message (FATAL_ERROR "options: ${CPPNNG_NNG_CMAKE_OPTIONS}")
>
>     # message (STATUS "${REPLACED_TYPES}")
>
>     message (STATUS "Invoking CMake: " "${CMAKE_COMMAND}"
> ${CPPNNG_NNG_CMAKE_OPTIONS})
>
> Cheers,
>
> Michael Powell
--

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


--

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 | Threaded
Open this post in threaded view
|

Re: Execute CMake process not working: source directory confusion

Alan W. Irwin
In reply to this post by Michael Powell
On 2017-09-28 12:18-0400 Michael Powell wrote:

> The outcome wasn't quite what I expected. How do I specify "path to
> source", where the source CMakeLists.txt is, properly. And the path to
> the build, where I want the build environment to land?
>
> With this scenario, currently things are landing "in the source
> directory", which is incorrect, not what I am expecting.
>
> Probably my confusion over, prefix directory? Or is "source" directory
> where things actually land?

The rule is the directory where you invoke cmake is always the
top-level directory of the build tree.  I would strongly advise that
should initially be an empty directory so you don't mix
cmake-generated files with anything else in that directory.

In my opinion, one of the warts of CMake is it allows you to invoke
cmake from the top-level directory of the source tree (e.g., using
"cmake ." which means the top-level directory of the build tree is
identical to the top-level directory of the source tree.  This
invocation (which unfortunately is often advocated by naive CMake
users, and, at least in the old days, by the CMake documentation
itself) scatters cmake-generated files all over your source tree which
makes it extremely difficult to restore your source tree to pristine
condition (without removing the whole source tree and starting over
with that using git clone, unpacking a tarball or whatever).  And, of
course, once you have designated the build-tree top-level, CMake
doesn't allow you to change it unless you start fresh.

In sum, to get out of this mess, you must both restore your source
tree to pristine condition, and invoke cmake from an initially empty
directory which will then become the top-level of your build tree
from then on.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--

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 | Threaded
Open this post in threaded view
|

Re: Execute CMake process not working: source directory confusion

Michael Powell
In reply to this post by Petr Kmoch
On Thu, Sep 28, 2017 at 12:53 PM, Michael Powell <[hidden email]> wrote:

> On Thu, Sep 28, 2017 at 12:36 PM, Petr Kmoch <[hidden email]> wrote:
>> Hi Michael.
>>
>> On 28 September 2017 at 18:18, Michael Powell <[hidden email]> wrote:
>>>
>>> On Thu, Sep 28, 2017 at 12:06 PM, Michael Powell <[hidden email]>
>>> wrote:
>>> > ---------- Forwarded message ----------
>>> > From: Michael Powell <[hidden email]>
>>> > Date: Thu, Sep 28, 2017 at 12:06 PM
>>> > Subject: Execute CMake process not working: source directory confusion
>>> > To: [hidden email]
>>> >
>>> >
>>> > Hello,
>>> >
>>> > This is fairly long, but this is intentional. I message the "Invoking"
>>> > message.
>>>
>>> Ah, I figured it out!
>>>
>>> From the help:
>>>
>>> cmake [options] <path-to-source>
>>>
>>> So I simply tacked on a "\"${GIT_SUBMODULE_NNG_REPO_DIR}\"" where
>>> <path-to-source> was expected.
>>>
>>> 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.
>>
>>>
>>>
>>> The outcome wasn't quite what I expected. How do I specify "path to
>>> source", where the source CMakeLists.txt is, properly. And the path to
>>> the build, where I want the build environment to land?
>>>
>>> With this scenario, currently things are landing "in the source
>>> directory", which is incorrect, not what I am expecting.
>>
>>
>> Once you solve the quoting issue, you should be able to pass what you want
>> as the source directory. It's effectively the first non-option argument to
>> 'cmake'.
>>
>> The generated buildsystem lands in the working directory from which cmake
>> was invoked. So what you want is this:
>>
>> execute_process(
>>   ${CMAKE_COMMAND} ${CPPNNG_NNG_CMAKE_OPTIONS} ${GIT_SUBMODULE_NNG_REPO_DIR}
>>   WORKING_DIRECTORY wherever/you/want/the/buildystem/to/end/up
>> )
>
> 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).

Out of curiosity, how strong is the file lock CMake is maintaining
internally? i.e. with allowance for shared read?

In this instance, I am running the parent CMake process from CMake
GUI, which it then invokes another instance of CMake on the submodule,
or at least that's the intention.

If that's a non-starter in its current form, no big deal; worst case
scenario I can take precautions to include the submodule source at
strategic points in my consumer solution.

> 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"
>
>> Petr
>>
>>>
>>>
>>> Probably my confusion over, prefix directory? Or is "source" directory
>>> where things actually land?
>>>
>>> Thanks!
>>>
>>> > Invoking CMake: C:/Dev/CMake/bin/cmake.exe -G "Visual Studio 14 2015
>>> > Win64" -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
>>> >
>>> > Prior to running:
>>> >
>>> > execute_process (
>>> >     COMMAND "${CMAKE_COMMAND}" ${CPPNNG_NNG_CMAKE_OPTIONS}
>>> >     WORKING_DIRECTORY "${GIT_SUBMODULE_NNG_REPO_DIR}"
>>> >     RESULT_VARIABLE CPPNN_NNG_CONFIG_EC
>>> >     OUTPUT_VARIABLE CPPNN_NNG_CONFIG_MSG
>>> > )
>>> >
>>> > Which is yielding:
>>> >
>>> > CMake Error: The source directory
>>> > "G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/ -G "Visual
>>> > Studio 14 2015 Win64" -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" does not
>>> > exist.
>>> >
>>> > The GIT_SUBMODULE_NNG_REPO_DIR is indeed set to
>>> > G:/Source/Spikes/nanomsg/cppnngswig-testing/repos/nng/, so how can
>>> > that not be the source directory? But further, how is it seeing the
>>> > rest of the options as "source directory"?
>>> >
>>> > I only got to this point by doing what seems like extreme string
>>> > gymnastics just to arrive at what I think is an appropriate command.
>>> >
>>> > i.e.
>>> >
>>> > macro (cppnng_nng_add_cmake_generator GEN)
>>> >     set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -G
>>> > \"${GEN}\"")
>>> > endmacro ()
>>> >
>>> > macro (cppnng_nng_add_cmake_var OPT TYPE VALUE)
>>> >     set (CPPNNG_NNG_CMAKE_OPTIONS "${CPPNNG_NNG_CMAKE_OPTIONS} -D
>>> > ${OPT}:${TYPE}=${VALUE}")
>>> > endmacro ()
>>> >
>>> >     cppnng_nng_add_cmake_generator ("${CMAKE_GENERATOR}")
>>> >
>>> >     # This is like string GYMNASTICS in order to allow semi-colons to
>>> > properly pass through.
>>> >     string(REPLACE ";" "\;" REPLACED_TYPES
>>> > "${CMAKE_CONFIGURATION_TYPES}")
>>> >     cppnng_nng_add_cmake_var ("CMAKE_CONFIGURATION_TYPES" STRING
>>> > "\"${REPLACED_TYPES}\"")
>>> >
>>> >     cppnng_nng_add_cmake_var ("CMAKE_INSTALL_PREFIX" STRING
>>> > "\"${cppnng_SOURCE_DIR}/build/nng\"")
>>> >     cppnng_nng_add_cmake_var ("NNG_ENABLE_COVERAGE" BOOL OFF)
>>> >     cppnng_nng_add_cmake_var ("NNG_ENABLE_DOC" BOOL OFF)
>>> >     cppnng_nng_add_cmake_var ("NNG_ENABLE_NNGCAT" BOOL OFF)
>>> >     cppnng_nng_add_cmake_var ("NNG_ENABLE_TESTS" BOOL OFF)
>>> >     cppnng_nng_add_cmake_var ("NNG_ENABLE_TOOLS" BOOL OFF)
>>> >     # TODO: TBD: at the moment we do not care about ZeroTier, but this
>>> > could change moving forward.
>>> >     cppnng_nng_add_cmake_var ("NNG_ENABLE_ZEROTIER" BOOL OFF)
>>> >
>>> >     # message (FATAL_ERROR "options: ${CPPNNG_NNG_CMAKE_OPTIONS}")
>>> >
>>> >     # message (STATUS "${REPLACED_TYPES}")
>>> >
>>> >     message (STATUS "Invoking CMake: " "${CMAKE_COMMAND}"
>>> > ${CPPNNG_NNG_CMAKE_OPTIONS})
>>> >
>>> > Cheers,
>>> >
>>> > Michael Powell
>>> --
>>>
>>> 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
>>
>>
--

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 | Threaded
Open this post in threaded view
|

Re: Execute CMake process not working: source directory confusion

Petr Kmoch
In reply to this post by Petr Kmoch
(Added list back to copy)

On 28 September 2017 at 18:53, Michael Powell <[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: Execute CMake process not working: source directory confusion

Michael Powell
On Thu, Sep 28, 2017 at 1:42 PM, Petr Kmoch <[hidden email]> wrote:

> (Added list back to copy)
>
> On 28 September 2017 at 18:53, Michael Powell <[hidden email]> 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:

Ah ok... I see it now. And the result is much MUCH better. Thanks!

> 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