From 0e35fbec4ebd8f4563434e2b09896d46dac71934 Mon Sep 17 00:00:00 2001 From: Andy Stanton Date: Tue, 22 Apr 2014 20:55:22 +0100 Subject: [PATCH] add options --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d300917..4dd509a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib ) SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib ) SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin ) +OPTION( glew-cmake_BUILD_SHARED "Build the shared glew library" ON) +OPTION( glew-cmake_BUILD_STATIC "Build the static glew library" ON) + INCLUDE_DIRECTORIES( ${INCLUDE_DIR} ) SET( LIBGLEW_SRCS ${SRC_DIR}/glew.c ) @@ -26,8 +29,12 @@ IF( NOT USE_GLU ) ADD_DEFINITIONS( -DGLEW_NO_GLU ) ENDIF( ) -ADD_LIBRARY( libglew_static STATIC ${LIBGLEW_SRCS} ) -ADD_LIBRARY( libglew_shared SHARED ${LIBGLEW_SRCS} ) +IF ( glew-cmake_BUILD_STATIC ) + ADD_LIBRARY( libglew_static STATIC ${LIBGLEW_SRCS} ) +ENDIF ( ) +IF ( glew-cmake_BUILD_SHARED ) + ADD_LIBRARY( libglew_shared SHARED ${LIBGLEW_SRCS} ) +ENDIF ( ) IF( WIN32 ) SET( GL_LIBRARY opengl32 ) @@ -37,16 +44,21 @@ ELSE( ) SET( GL_LIBRARY GL ) ENDIF( ) -SET_PROPERTY( TARGET libglew_static PROPERTY ARCHIVE_OUTPUT_NAME "glew" ) -SET_PROPERTY( TARGET libglew_static PROPERTY DEBUG_POSTFIX d ) -IF( WIN32 ) - SET_PROPERTY( TARGET libglew_shared PROPERTY RUNTIME_OUTPUT_NAME "glew" ) -ELSE( ) - SET_PROPERTY( TARGET libglew_shared PROPERTY LIBRARY_OUTPUT_NAME "glew" ) -ENDIF( ) -SET_PROPERTY( TARGET libglew_shared PROPERTY DEBUG_POSTFIX d ) +IF ( glew-cmake_BUILD_STATIC ) + SET_PROPERTY( TARGET libglew_static PROPERTY ARCHIVE_OUTPUT_NAME "glew" ) + SET_PROPERTY( TARGET libglew_static PROPERTY DEBUG_POSTFIX d ) +ENDIF ( ) -TARGET_LINK_LIBRARIES( libglew_shared ${GL_LIBRARY} ) +IF ( glew-cmake_BUILD_SHARED ) + IF( WIN32 ) + SET_PROPERTY( TARGET libglew_shared PROPERTY RUNTIME_OUTPUT_NAME "glew" ) + ELSE( ) + SET_PROPERTY( TARGET libglew_shared PROPERTY LIBRARY_OUTPUT_NAME "glew" ) + ENDIF( ) + SET_PROPERTY( TARGET libglew_shared PROPERTY DEBUG_POSTFIX d ) + + TARGET_LINK_LIBRARIES( libglew_shared ${GL_LIBRARY} ) +ENDIF ( ) IF( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} AND NOT ONLY_LIBS ) SET( GLEWINFO_SRCS ${SRC_DIR}/glewinfo.c ) @@ -55,10 +67,13 @@ IF( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} AND NOT ONLY_LIBS ) LIST( APPEND GLEWINFO_SRCS ${RC_DIR}/glewinfo.rc ) LIST( APPEND VISUALINFO_SRCS ${RC_DIR}/visualinfo.rc ) ENDIF( ) + ADD_EXECUTABLE( glewinfo ${GLEWINFO_SRCS} ) ADD_EXECUTABLE( visualinfo ${VISUALINFO_SRCS} ) - TARGET_LINK_LIBRARIES( glewinfo libglew_static ${GL_LIBRARY} ) - TARGET_LINK_LIBRARIES( visualinfo libglew_static ${GL_LIBRARY} ) + IF ( glew-cmake_BUILD_STATIC ) + TARGET_LINK_LIBRARIES( glewinfo libglew_static ${GL_LIBRARY} ) + TARGET_LINK_LIBRARIES( visualinfo libglew_static ${GL_LIBRARY} ) + ENDIF ( ) ENDIF( )