[CMake] Execute CMake process not working: source directory confusion

Michael Powell mwpowellhtx at gmail.com
Thu Sep 28 12:18:56 EDT 2017


On Thu, Sep 28, 2017 at 12:06 PM, Michael Powell <mwpowellhtx at gmail.com> wrote:
> ---------- Forwarded message ----------
> From: Michael Powell <mwpowellhtx at gmail.com>
> Date: Thu, Sep 28, 2017 at 12:06 PM
> Subject: Execute CMake process not working: source directory confusion
> To: cmake at cmake.org
>
>
> 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


More information about the CMake mailing list