[CMake] Setting the argument of INCLUDE_DIRECTORIES from the command line

David Cole david.cole at kitware.com
Sat Oct 20 10:09:23 EDT 2012


On Sat, Oct 20, 2012 at 9:54 AM, Rolf Eike Beer <eike at sf-mail.de> wrote:
> Olumide wrote:
>> Hi -
>>
>> The CMakeLists.txt file of the project that I am trying to build has the
>> following
>>
>> INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src)
>> INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/ga)
>> INCLUDE_DIRECTORIES(${EO_SOURCE_DIR}/src/utils)
>>
>> Is it possible to set ${EO_SOURCE_DIR} from the command line, when
>> running cmake?
>
> Sure: cmake -D EO_SOURCE_DIR=/foo/bar/baz /path/to/sources
>
> Eike
> --
>
> --
>
> 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

Yes, but if it also has a "project(EO)" then CMake will define
EO_SOURCE_DIR automatically at that point to be the same as the
directory that contains the CMakeLists that has that "project(EO)" in
it...

You wouldn't want to try to override that with something different,
because the writer of the CMakeLists file is counting on the value of
it.

Also, if there is a "set(EO_SOURCE_DIR "some_value")" in there, then
the value in the CMakeLists file will locally override whatever you
pass in on the command line.


HTH,
David


More information about the CMake mailing list