CMake updates:
authorDiederick Niehorster <dcnieho@gmail.com>
Sat, 10 Mar 2012 11:08:44 +0000 (11:08 +0000)
committerDiederick Niehorster <dcnieho@gmail.com>
Sat, 10 Mar 2012 11:08:44 +0000 (11:08 +0000)
- no longer trying to link with m.lib (tht maths for linux)
- now building demos for static and for shared library, depending on
  which libraries are created
- TARGET_LINK_LIBRARIES statement conditional on whether the relevant
  shared/static library is built

git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1098 7f0cb862-5218-0410-a997-914c9d46530a

CMakeLists.txt

index e17cd60..4f28280 100644 (file)
@@ -89,7 +89,11 @@ OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
 FIND_PACKAGE(OpenGL REQUIRED)
 INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
 LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
-LIST(APPEND LIBS m)
+
+# lib m for math, not needed on windows
+IF (NOT WIN32)
+    LIST(APPEND LIBS m)
+ENDIF()
 
 IF(WIN32)
        MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)")
@@ -163,8 +167,12 @@ ELSE()
        SET_TARGET_PROPERTIES(freeglut PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
        SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
 ENDIF()
-TARGET_LINK_LIBRARIES(freeglut ${LIBS})
-TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
+IF(BUILD_SHARED_LIBS)
+    TARGET_LINK_LIBRARIES(freeglut ${LIBS})
+ENDIF()
+IF(BUILD_STATIC_LIBS)
+    TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
+ENDIF()
 
 IF(BUILD_SHARED_LIBS)
        INSTALL(TARGETS freeglut DESTINATION lib)
@@ -180,17 +188,22 @@ INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
 option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
 
 SET(DEMO_LIBS ${OPENGL_glu_LIBRARY} ${LIBS})
-LIST(APPEND DEMO_LIBS m)
+# lib m for math, not needed on windows
+IF (NOT WIN32)
+    LIST(APPEND DEMO_LIBS m)
+ENDIF()
 
 MACRO(ADD_DEMO name)
-       if( FREEGLUT_BUILD_DEMOS )
-               ADD_EXECUTABLE(${name} ${ARGN})
-               IF(BUILD_SHARED_LIBS)
-                       TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
-               ELSE()
-                       TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static)
-               ENDIF()
-       endif()
+    IF( FREEGLUT_BUILD_DEMOS )
+        IF(BUILD_SHARED_LIBS)
+            ADD_EXECUTABLE(${name} ${ARGN})
+            TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
+        ENDIF()
+        IF(BUILD_STATIC_LIBS)
+            ADD_EXECUTABLE(${name}_static ${ARGN})
+            TARGET_LINK_LIBRARIES(${name}_static ${DEMO_LIBS} freeglut_static)
+        ENDIF()
+    ENDIF()
 ENDMACRO()
 
 ADD_DEMO(CallbackMaker   progs/demos/CallbackMaker/CallbackMaker.c)