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

Michael Powell mwpowellhtx at gmail.com
Thu Sep 28 12:06:16 EDT 2017


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


More information about the CMake mailing list