[CMake] Pass value from CMake to source file?
Wojciech Migda
wojtek.golf at interia.pl
Sun Oct 4 06:00:49 EDT 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eric Noulard pisze:
> 2009/10/4 motes motes <mort.motes at gmail.com>:
>> Is it possible to send a user specified path from CMake to the final
>> application (make it visible)? Depending on which machine I build my
>> application on the path to some images may vary. I was therefore
>> thinking to specify this path when building with CMake like:
>>
>> FIND_PATH(IMAGE_DIR REQUIRED)
>>
>> and then in my application do:
>>
>> #include<string>
>> int main(){
>>
>> std::string img0 = IMAGE_DIR + "image0.png";
>> return 0;
>>
>> }
>
> You should use CONFIGURE_FILE for that.
>
> Look for example this section of the Wiki:
> http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks
My personal favourite would be preprocessor macro:
FIND_PATH(IMAGE_DIR REQUIRED)
ADD_DEFINITIONS( -DIMAGE_DIR=${IMAGE_DIR} )
- -Wojciech
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFKyHJR0iFl+nAyImcRAhy/AKCE4AbpCTP7hfvylG2cr+nJAScpJQCcDZHl
iJ/ur6pjOCllzZKFxzHfbqs=
=TA6d
-----END PGP SIGNATURE-----
---------------------------------------------------------------
Zapytaj wró¿kê!
Kliknij >>> http://link.interia.pl/f238d
More information about the CMake
mailing list