[CMake] Compile CMakeCache.txt into shared library

Hänel Nikolaus Valentin valentin.haenel at epfl.ch
Wed Feb 8 09:32:15 EST 2012


* Johannes Zarl <johannes.zarl at jku.at> [120208]:
> Hi,
> 
> I'm not sure if I understand you correctly, but I would guess that in most 
> cases you don't need to know _all_ cmake cache variables at runtime.
> 
> If you really just need to know some specific variables, you would be much 
> better off using a generated header file. See the documentation for configure_file 
> for details on this.
> 
> In short, you'd make a headerfile config.h.in with lines like this:
> #cmakedefine @my_magic_variable@
> 
> And in cmakeLists:
> configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
>                        ${CMAKE_CURRENT_BINARY_DIR}/config.h )
> 
> Afterwards, you can include config.h in your shared library and you can use the 
> value there...

Ah, yes. Thats great! Thanks!

V-


More information about the CMake mailing list