[CMake] Command line cmake not picking up variable that gets picked up in the GUI

Yuri Timenkov yuri at timenkov.ru
Sun Dec 2 11:25:27 EST 2012


You should put this variable into cache one way or another. (e.g.
explicitly set with CACHE option or use in some find_* command).

The most straight-forward approach is to add to your
CMakeLists.txtsomething like:
set(CODE_BUILD_DIR "${CODE_BUILD_DIR}" CACHE PATH "Path to CODE package")

But beware that behavior depends on whether you specify this flag in
successive CMake invocations.

If you build nested project by yourself I suggest using find_package in
config mode. Once config file found, CMake puts appropriate directory into
cache and on successive runs reads package config file immediately. If that
project is also build with CMake I suggest looking at exporting targets and
registering exports locally.

On Fri, Nov 30, 2012 at 12:44 AM, katie outram <katie.outram at gmail.com>wrote:

> I am trying to automate my build process and before going down this path,
> I set up findMYCODE script that requires a variable CODE_BUILD_DIR that the
> user defines.    This variable is the build directory for another code base
> that my current code base is dependent on.   When I run CMAKE  in the gui,
> and define the variable, the find script locates the necessary path/items
> and this value is populated in the CMakeCache file.    In the CMakeCache
> file my variable is listed as
>
> CODE_BUILD_DIR:PATH=C:/builddir/Win64/VC10/bin/Release
>
> However ,when I go to the command line and try to pass the needed
> build parameter via the command line, my value is not getting picked up and
> so my solution does not get generated.   In order to get my solution I must
> have this variable defined.
>
> From the build directory where I am trying to complete the build I execute
> the following command:
>
> cmake -G "Visual Studio 10 Win64"
> -DCODE_BUILD_DIR:PATH=C:/builddir/Win64/VC10/bin/Release c:\mysource
>
> The variable CODE_BUILD_DIR int he above line is the first build directory
> for another code base that my current code is dependent on.
>
> I have tried several variations of this command line option and passing
> the -D variable, with and without escaping my path, however I am not having
> any success.   Without this parameter defined,* *I am unable to locate
> the necessary libraries that I must use to link into my current code.
>
> I am thinking that I am possibly missing something in my find script, or
> maybe I'm not escaping the characters in my path correctly.
>
> Does anyone have any suggestions?
>
> Thanks
>
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121202/9e28fe64/attachment.htm>


More information about the CMake mailing list