mirror of
https://github.com/Perlmint/glew-cmake.git
synced 2024-11-29 18:07:08 +00:00
Cleanup CMakeLists
This commit is contained in:
parent
5a59fc7d94
commit
cc5cfff738
230
CMakeLists.txt
230
CMakeLists.txt
@ -1,128 +1,150 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
|
cmake_minimum_required(VERSION 2.6)
|
||||||
PROJECT( "glew" )
|
project("glew")
|
||||||
|
|
||||||
SET( SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src )
|
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
SET( INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include )
|
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
SET( RC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build )
|
set(RC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/build)
|
||||||
|
|
||||||
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||||
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
|
||||||
OPTION( glew-cmake_BUILD_SHARED "Build the shared glew library" ON )
|
option(glew-cmake_BUILD_SHARED "Build the shared glew library" ON)
|
||||||
OPTION( glew-cmake_BUILD_STATIC "Build the static glew library" ON )
|
option(glew-cmake_BUILD_STATIC "Build the static glew library" ON)
|
||||||
OPTION( glew-cmake_BUILD_SINGLE_CONTEXT "Build the single context glew library" ON )
|
option(glew-cmake_BUILD_SINGLE_CONTEXT "Build the single context glew library" ON)
|
||||||
OPTION( glew-cmake_BUILD_MULTI_CONTEXT "Build the multi context glew library" ON )
|
option(glew-cmake_BUILD_MULTI_CONTEXT "Build the multi context glew library" ON)
|
||||||
|
option(USE_GLU "Use GLU" OFF)
|
||||||
|
option(ONLY_LIBS "Do not build executables" OFF)
|
||||||
|
|
||||||
|
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/config/version _VERSION_MAJOR_STRING REGEX "GLEW_MAJOR[ ]*=[ ]*[0-9]+.*")
|
||||||
|
string(REGEX REPLACE "GLEW_MAJOR[ ]*=[ ]*([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_MAJOR ${_VERSION_MAJOR_STRING})
|
||||||
|
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/config/version _VERSION_MINOR_STRING REGEX "GLEW_MINOR[ ]*=[ ]*[0-9]+.*")
|
||||||
|
string(REGEX REPLACE "GLEW_MINOR[ ]*=[ ]*([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_MINOR ${_VERSION_MINOR_STRING})
|
||||||
|
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/config/version _VERSION_PATCH_STRING REGEX "GLEW_MICRO[ ]*=[ ]*[0-9]+.*")
|
||||||
|
string(REGEX REPLACE "GLEW_MICRO[ ]*=[ ]*([0-9]+)" "\\1" CPACK_PACKAGE_VERSION_PATCH ${_VERSION_PATCH_STRING})
|
||||||
|
set(GLEW_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
|
||||||
|
|
||||||
SET( LIBGLEW_SRCS ${SRC_DIR}/glew.c )
|
set(LIBGLEW_SRCS ${SRC_DIR}/glew.c)
|
||||||
|
|
||||||
IF( WIN32 )
|
set(DEFINITIONS)
|
||||||
ADD_DEFINITIONS( -DWIN32_MEAN_AND_LEAN -DVC_EXTRALEAN -D_CRT_SECURE_NO_WARNINGS )
|
if(WIN32)
|
||||||
ENDIF( )
|
list(APPEND DEFINITIONS -DWIN32_MEAN_AND_LEAN -DVC_EXTRALEAN -D_CRT_SECURE_NO_WARNINGS)
|
||||||
|
endif()
|
||||||
|
|
||||||
IF( MSVC )
|
if(MSVC)
|
||||||
LIST( APPEND LIBGLEW_SRCS ${RC_DIR}/glew.rc )
|
list(APPEND LIBGLEW_SRCS ${RC_DIR}/glew.rc)
|
||||||
ENDIF( )
|
endif()
|
||||||
|
|
||||||
IF( NOT USE_GLU )
|
find_package(OpenGL REQUIRED)
|
||||||
ADD_DEFINITIONS( -DGLEW_NO_GLU )
|
|
||||||
ENDIF( )
|
|
||||||
|
|
||||||
IF( WIN32 )
|
if(NOT USE_GLU)
|
||||||
SET( GL_LIBRARY opengl32 )
|
list(APPEND DEFINITIONS -DGLEW_NO_GLU)
|
||||||
ELSEIF( APPLE )
|
set(pc_requires)
|
||||||
FIND_LIBRARY( GL_LIBRARY OpenGL )
|
else()
|
||||||
FIND_LIBRARY( AGL_LIBRARY AGL )
|
set(pc_requires REQUIRES glu)
|
||||||
SET( PLATFORM_SPECIFIC_LIBRARIES ${AGL_LIBRARY} )
|
list(APPEND LIBRARIES OpenGL::GLU)
|
||||||
ELSE( )
|
if(NOT OPENGL_GLU_FOUND)
|
||||||
SET( GL_LIBRARY GL )
|
message(FATAL_ERROR "GLU is not found. but GLU option is enabled")
|
||||||
SET( PLATFORM_SPECIFIC_LIBRARIES X11 dl Xext )
|
endif()
|
||||||
ENDIF( )
|
endif( )
|
||||||
|
|
||||||
IF ( glew-cmake_BUILD_STATIC )
|
if(WIN32)
|
||||||
IF ( glew-cmake_BUILD_SINGLE_CONTEXT )
|
list(APPEND LIBRARIES opengl32)
|
||||||
ADD_LIBRARY( libglew_static STATIC ${LIBGLEW_SRCS} )
|
elseif(APPLE)
|
||||||
|
find_library(GL_LIBRARY OpenGL)
|
||||||
|
find_library(AGL_LIBRARY AGL)
|
||||||
|
list(APPEND LIBRARIES ${GL_LIBRARY} ${AGL_LIBRARY})
|
||||||
|
else()
|
||||||
|
list(APPEND LIBRARIES GL X11 dl Xext)
|
||||||
|
endif()
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES( libglew_static PROPERTIES
|
if(glew-cmake_BUILD_STATIC)
|
||||||
ARCHIVE_OUTPUT_NAME "glew"
|
if(glew-cmake_BUILD_SINGLE_CONTEXT)
|
||||||
DEBUG_POSTFIX d )
|
add_library(libglew_static STATIC ${LIBGLEW_SRCS})
|
||||||
TARGET_INCLUDE_DIRECTORIES( libglew_static PUBLIC ${INCLUDE_DIR} )
|
|
||||||
TARGET_COMPILE_DEFINITIONS( libglew_static PUBLIC GLEW_STATIC )
|
|
||||||
TARGET_LINK_LIBRARIES( libglew_static ${GL_LIBRARY} ${PLATFORM_SPECIFIC_LIBRARIES} )
|
|
||||||
INSTALL( TARGETS libglew_static ARCHIVE DESTINATION lib )
|
|
||||||
ENDIF ( )
|
|
||||||
|
|
||||||
IF ( glew-cmake_BUILD_MULTI_CONTEXT )
|
set_target_properties(libglew_static PROPERTIES
|
||||||
ADD_LIBRARY( libglewmx_static STATIC ${LIBGLEW_SRCS} )
|
OUTPUT_NAME "glew"
|
||||||
|
DEBUG_POSTFIX d)
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES( libglewmx_static PROPERTIES
|
target_include_directories(libglew_static PUBLIC ${INCLUDE_DIR})
|
||||||
ARCHIVE_OUTPUT_NAME "glewmx"
|
target_compile_definitions(libglew_static PUBLIC GLEW_STATIC ${DEFINITIONS})
|
||||||
DEBUG_POSTFIX d )
|
target_link_libraries(libglew_static ${LIBRARIES} )
|
||||||
TARGET_COMPILE_DEFINITIONS( libglewmx_static INTERFACE GLEW_MX)
|
set_target_properties(libglew_static PROPERTIES VERSION ${GLEW_VERSION})
|
||||||
TARGET_INCLUDE_DIRECTORIES( libglewmx_static PUBLIC ${INCLUDE_DIR} )
|
install(TARGETS libglew_static ARCHIVE DESTINATION lib)
|
||||||
TARGET_COMPILE_DEFINITIONS( libglewmx_static PUBLIC GLEW_STATIC )
|
endif()
|
||||||
TARGET_LINK_LIBRARIES( libglewmx_static ${GL_LIBRARY} ${PLATFORM_SPECIFIC_LIBRARIES} )
|
|
||||||
INSTALL( TARGETS libglewmx_static ARCHIVE DESTINATION lib )
|
|
||||||
ENDIF ( )
|
|
||||||
ENDIF ( )
|
|
||||||
|
|
||||||
IF ( glew-cmake_BUILD_SHARED )
|
if(glew-cmake_BUILD_MULTI_CONTEXT)
|
||||||
IF ( glew-cmake_BUILD_SINGLE_CONTEXT )
|
add_library(libglewmx_static STATIC ${LIBGLEW_SRCS})
|
||||||
ADD_LIBRARY( libglew_shared SHARED ${LIBGLEW_SRCS} )
|
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES( libglew_shared PROPERTIES
|
set_target_properties(libglewmx_static PROPERTIES
|
||||||
RUNTIME_OUTPUT_NAME "glew"
|
OUTPUT_NAME "glewmx"
|
||||||
LIBRARY_OUTPUT_NAME "glew"
|
DEBUG_POSTFIX d)
|
||||||
DEBUG_POSTFIX d )
|
|
||||||
|
|
||||||
TARGET_INCLUDE_DIRECTORIES( libglew_shared PUBLIC ${INCLUDE_DIR} )
|
target_compile_definitions(libglewmx_static INTERFACE GLEW_MX PUBLIC GLEW_STATIC ${DEFINITIONS})
|
||||||
TARGET_COMPILE_DEFINITIONS( libglew_shared PUBLIC GLEW_BUILD )
|
target_include_directories(libglewmx_static PUBLIC ${INCLUDE_DIR})
|
||||||
TARGET_LINK_LIBRARIES( libglew_shared ${GL_LIBRARY} ${PLATFORM_SPECIFIC_LIBRARIES} )
|
target_link_libraries(libglewmx_static ${LIBRARIES})
|
||||||
INSTALL( TARGETS libglew_shared ARCHIVE DESTINATION lib
|
set_target_properties(libglewmx_static PROPERTIES VERSION ${GLEW_VERSION})
|
||||||
LIBRARY DESTINATION lib
|
install(TARGETS libglewmx_static ARCHIVE DESTINATION lib)
|
||||||
RUNTIME DESTINATION bin )
|
endif()
|
||||||
ENDIF ( )
|
endif()
|
||||||
|
|
||||||
IF ( glew-cmake_BUILD_MULTI_CONTEXT )
|
if(glew-cmake_BUILD_SHARED)
|
||||||
ADD_LIBRARY( libglewmx_shared SHARED ${LIBGLEW_SRCS} )
|
if(glew-cmake_BUILD_SINGLE_CONTEXT)
|
||||||
|
add_library(libglew_shared SHARED ${LIBGLEW_SRCS})
|
||||||
|
|
||||||
SET_TARGET_PROPERTIES( libglewmx_shared PROPERTIES
|
set_target_properties(libglew_shared PROPERTIES
|
||||||
RUNTIME_OUTPUT_NAME "glewmx"
|
OUTPUT_NAME "glew"
|
||||||
LIBRARY_OUTPUT_NAME "glewmx"
|
DEBUG_POSTFIX d)
|
||||||
DEBUG_POSTFIX d )
|
|
||||||
|
|
||||||
TARGET_COMPILE_DEFINITIONS( libglewmx_shared INTERFACE GLEW_MX)
|
target_compile_definitions(libglew_shared PUBLIC GLEW_BUILD ${DEFINITIONS})
|
||||||
TARGET_INCLUDE_DIRECTORIES( libglewmx_shared PUBLIC ${INCLUDE_DIR} )
|
target_include_directories(libglew_shared PUBLIC ${INCLUDE_DIR})
|
||||||
TARGET_COMPILE_DEFINITIONS( libglewmx_shared PUBLIC GLEW_BUILD )
|
target_link_libraries(libglew_shared ${LIBRARIES})
|
||||||
TARGET_LINK_LIBRARIES( libglewmx_shared ${GL_LIBRARY} ${PLATFORM_SPECIFIC_LIBRARIES} )
|
set_target_properties(libglew_shared PROPERTIES VERSION ${GLEW_VERSION})
|
||||||
INSTALL( TARGETS libglewmx_shared ARCHIVE DESTINATION lib
|
install(TARGETS libglew_shared
|
||||||
LIBRARY DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
RUNTIME DESTINATION bin )
|
LIBRARY DESTINATION lib
|
||||||
ENDIF ( )
|
RUNTIME DESTINATION bin)
|
||||||
ENDIF ( )
|
endif()
|
||||||
|
|
||||||
FILE( GLOB PUBLIC_HEADERS "include/GL/*.h" )
|
if(glew-cmake_BUILD_MULTI_CONTEXT)
|
||||||
INSTALL( FILES ${PUBLIC_HEADERS} DESTINATION include/GL/ )
|
add_library(libglewmx_shared SHARED ${LIBGLEW_SRCS})
|
||||||
|
|
||||||
IF( ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} AND NOT ONLY_LIBS )
|
set_target_properties(libglewmx_shared PROPERTIES
|
||||||
SET( GLEWINFO_SRCS ${SRC_DIR}/glewinfo.c )
|
OUTPUT_NAME "glewmx"
|
||||||
SET( VISUALINFO_SRCS ${SRC_DIR}/visualinfo.c )
|
DEBUG_POSTFIX d)
|
||||||
IF( MSVS )
|
|
||||||
LIST( APPEND GLEWINFO_SRCS ${RC_DIR}/glewinfo.rc )
|
|
||||||
LIST( APPEND VISUALINFO_SRCS ${RC_DIR}/visualinfo.rc )
|
|
||||||
ENDIF( )
|
|
||||||
|
|
||||||
ADD_EXECUTABLE( glewinfo ${GLEWINFO_SRCS} )
|
target_compile_definitions(libglewmx_shared PUBLIC GLEW_BUILD ${DEFINITIONS} INTERFACE GLEW_MX)
|
||||||
ADD_EXECUTABLE( visualinfo ${VISUALINFO_SRCS} )
|
target_include_directories(libglewmx_shared PUBLIC ${INCLUDE_DIR})
|
||||||
|
target_link_libraries(libglewmx_shared ${LIBRARIES})
|
||||||
|
set_target_properties(libglewmx_shared PROPERTIES VERSION ${GLEW_VERSION})
|
||||||
|
install(TARGETS libglewmx_shared
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
RUNTIME DESTINATION bin)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
IF ( glew-cmake_BUILD_STATIC )
|
file(GLOB PUBLIC_HEADERS "include/GL/*.h")
|
||||||
TARGET_LINK_LIBRARIES( glewinfo libglew_static )
|
install(FILES ${PUBLIC_HEADERS} DESTINATION include/GL/)
|
||||||
TARGET_LINK_LIBRARIES( visualinfo libglew_static )
|
|
||||||
ELSE ( )
|
|
||||||
TARGET_LINK_LIBRARIES( glewinfo libglew_shared )
|
|
||||||
TARGET_LINK_LIBRARIES( visualinfo libglew_shared )
|
|
||||||
ENDIF ( )
|
|
||||||
|
|
||||||
INSTALL( TARGETS glewinfo visualinfo DESTINATION bin )
|
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR} AND NOT ONLY_LIBS)
|
||||||
ENDIF( )
|
set(GLEWINFO_SRCS ${SRC_DIR}/glewinfo.c)
|
||||||
|
set(VISUALINFO_SRCS ${SRC_DIR}/visualinfo.c)
|
||||||
|
if(MSVS)
|
||||||
|
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})
|
||||||
|
|
||||||
|
if(glew-cmake_BUILD_STATIC)
|
||||||
|
target_link_libraries(glewinfo libglew_static)
|
||||||
|
target_link_libraries(visualinfo libglew_static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(glewinfo libglew_shared)
|
||||||
|
target_link_libraries(visualinfo libglew_shared)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS glewinfo visualinfo DESTINATION bin)
|
||||||
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user