[CMake] Way to use precompilation directive on cmake and conditionnal linking

Nadir SOUALEM nadir.soualem at irisa.fr
Tue Mar 24 04:18:01 EDT 2009


I would like to use precompilation directive such NO_OPENGL
Is there a way to use it with this command line ?
cmake -DCMAKE_BUILD_TYPE=Debug

or must i use something like:
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_OPENGL=0

with an if statement:
if(NOT WITH_OPENGL)
ADD_DEFINITIONS(-DNO_OPENGL)
endif

I would like to use a conditional linking, on our clusters there's no 
X11, no Opengl ...
How to make a conditional linking, for example if NO_OPENGL


TARGET_LINK_LIBRARIES(MyExe
A
B
C)

else

TARGET_LINK_LIBRARIES(MyExe
A
B
C
GL
GLU
GLUT)

What is the best and properly way to do that ?

Thank you for your anwsers.





Thank you.


More information about the CMake mailing list