Tyler Roscoe wrote:
On Tue, Mar 24, 2009 at 09:18:01AM +0100, Nadir SOUALEM wrote:
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'm not sure I understand this question, but that solution looks
reasonable. Maybe what you want is more like:

if (WITH_OPENGL)
    add_definitions (-DOPENGL)
else (WITH_OPENGL)
    add_definitions (-DNO_OPENGL)
endif (WITH_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)

In my projects I do something like:

set (MyExe_LINK_LIBS
    A
    B
    C)

if (WITH_OPENGL)
    set (MyExe_LINK_LIBS
        ${MyExe_LINK_LIBS}
        GL
        GLU
        GLUT)
endif (WITH_OPENGL)

target_link_libraries(MyExe ${MyExe_LINK_LIBS})


hth,
tyler
Thank you Tyler , i use the same method for linking, but i thought there was a better way than:

if (WITH_OPENGL)
add_definitions (-DOPENGL)
else (WITH_OPENGL)
add_definitions (-DNO_OPENGL)
endif (WITH_OPENGL)

for preprocessing vars ....

Thank You Tyler

--
Nadir SOUALEM
Ingénieur INRIA - Équipe SAGE
INRIA-IRISA . campus de Beaulieu . F - 35 042 Rennes Cedex Tel: 02 99 84 71 47

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to