[Cmake] use of cmake options in source code

Mónica Hernández Giménez mhg at posta . unizar . es
Thu, 28 Aug 2003 10:39:17 +0200


Hi all!

I defined a flag in my CMakeLists.txt file to compile my library with or 
without VTK:

OPTION(HAS_VTK "build with VTK" ON)
MARK_AS_ADVANCED(CLEAR HAS_VTK)

Now i would like to use this HAS_VTK in my source code this way:

int main(int argc, char **argv)
{

#ifdef HAS_VTK

cout<<"I can use VTK libraries"<<endl;

#else

cout<<"I can't use VTK libraries"<<endl;

#endif

}

Now the option HAS_VTK is set to ON in my CMakeLists.txt but the result of 
this program is cout<<"I can't use VTK libraries"<<endl;

How can the source code know that the option HAS_VTK is defined?

Thanks a lot.


------------------------------------------------------------------------------------------------------------------
Mónica Hernández Giménez
Departamento de Ingeniería Electrónica y Comunicaciones
Lab. 3.05
Centro Politécnico Superior. Universidad de Zaragoza
Phone. (+34) 976 76 27 05
Fax:    (+34) 976 76 21 11
e-mail: mhg at unizar . es
------------------------------------------------------------------------------------------------------------------