[CMake] Howto to work with variables from central makefiles....
Eric Noulard
eric.noulard at gmail.com
Wed Nov 17 10:37:39 EST 2010
2010/11/17 Thomas Lehmann <t.lehmann at rtsgroup.net>
>
> Hi all,
>
>
>
> for an automatically forced include I have provided an
>
> option like this:
>
>
>
> set(WIN32_SPEC ${CMAKE_CURRENT_SOURCE_DIR}/../../libs/global/win32_spec.h)
May you could use an absolute reference using
${PROJECT_SOURCE_DIR}/libs/global/win32_spec.h
if your project is name TOTO
(from the PROJECT(TOTO CXX) statement)
you use
${TOTO_SOURCE_DIR}/libs/global/win32_spec.h.
>
> add_definitions(-FI ${WIN32_SPEC})
>
>
> But when including this central file (find_package) the variable CMAKE_CURRENT_SOURCE_DIR
> changes and then the path and filename of the header is wrong.
>
>
>
> How to proceed best?
> Can I avoid that for those “set” statement the variable is not overwritten by those
> files including this central makefile?
You may use a CACHED variable
set(WIN32_SPEC ${PROJECT_SOURCE_DIR}/libs/global/win32_spec.h CACHE
FILEPATH "Central Include")
the first calling this will set the value then other set will be ignored.
If you want to override a CACHE var value you'll have to use FORCE set option.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list