CMake updates:

- 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: https://svn.code.sf.net/p/freeglut/code/trunk@1098 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2012-03-10 11:08:44 +00:00
parent 429507ee23
commit 5cc61b4c30

View File

@ -89,7 +89,11 @@ OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
FIND_PACKAGE(OpenGL REQUIRED) FIND_PACKAGE(OpenGL REQUIRED)
INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
LIST(APPEND LIBS ${OPENGL_gl_LIBRARY}) 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) IF(WIN32)
MESSAGE(WARNING "Insecure CRT warnings hidden (might want to fix these)") 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 PROPERTIES VERSION 3.9.0 SOVERSION 3 OUTPUT_NAME glut)
SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut) SET_TARGET_PROPERTIES(freeglut_static PROPERTIES OUTPUT_NAME glut)
ENDIF() ENDIF()
TARGET_LINK_LIBRARIES(freeglut ${LIBS}) IF(BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(freeglut_static ${LIBS}) TARGET_LINK_LIBRARIES(freeglut ${LIBS})
ENDIF()
IF(BUILD_STATIC_LIBS)
TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
ENDIF()
IF(BUILD_SHARED_LIBS) IF(BUILD_SHARED_LIBS)
INSTALL(TARGETS freeglut DESTINATION lib) INSTALL(TARGETS freeglut DESTINATION lib)
@ -180,17 +188,22 @@ INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL)
option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON ) option( FREEGLUT_BUILD_DEMOS "Build FreeGLUT demos." ON )
SET(DEMO_LIBS ${OPENGL_glu_LIBRARY} ${LIBS}) 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) MACRO(ADD_DEMO name)
if( FREEGLUT_BUILD_DEMOS ) IF( FREEGLUT_BUILD_DEMOS )
ADD_EXECUTABLE(${name} ${ARGN}) IF(BUILD_SHARED_LIBS)
IF(BUILD_SHARED_LIBS) ADD_EXECUTABLE(${name} ${ARGN})
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut) TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut)
ELSE() ENDIF()
TARGET_LINK_LIBRARIES(${name} ${DEMO_LIBS} freeglut_static) IF(BUILD_STATIC_LIBS)
ENDIF() ADD_EXECUTABLE(${name}_static ${ARGN})
endif() TARGET_LINK_LIBRARIES(${name}_static ${DEMO_LIBS} freeglut_static)
ENDIF()
ENDIF()
ENDMACRO() ENDMACRO()
ADD_DEMO(CallbackMaker progs/demos/CallbackMaker/CallbackMaker.c) ADD_DEMO(CallbackMaker progs/demos/CallbackMaker/CallbackMaker.c)