2015-02-04 20:27:12 +00:00
|
|
|
if ( NOT DEFINED CMAKE_BUILD_TYPE )
|
|
|
|
set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
|
|
|
|
endif ()
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-09 15:06:11 +00:00
|
|
|
project (glew)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
cmake_minimum_required (VERSION 2.4)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
if (COMMAND cmake_policy)
|
|
|
|
cmake_policy (SET CMP0003 NEW)
|
|
|
|
endif()
|
2014-12-01 10:13:15 +00:00
|
|
|
|
2015-02-06 08:33:39 +00:00
|
|
|
option (BUILD_UTILS "utilities" ON)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-19 11:44:16 +00:00
|
|
|
set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
|
|
|
|
2015-02-26 10:54:39 +00:00
|
|
|
# get version from config/version
|
|
|
|
file (STRINGS ${GLEW_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 ${GLEW_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 ${GLEW_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})
|
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
if (WIN32)
|
2015-02-06 08:33:39 +00:00
|
|
|
set (GLEW_LIB_NAME glew32)
|
2015-02-04 20:27:12 +00:00
|
|
|
else ()
|
2015-02-06 08:33:39 +00:00
|
|
|
set (GLEW_LIB_NAME GLEW)
|
|
|
|
set (DLL_PREFIX lib)
|
2015-02-04 20:27:12 +00:00
|
|
|
endif ()
|
2014-12-01 10:13:15 +00:00
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
find_package (OpenGL REQUIRED)
|
|
|
|
set (GLEW_LIBRARIES ${OPENGL_LIBRARIES})
|
2014-12-01 10:13:15 +00:00
|
|
|
|
2015-02-26 11:00:25 +00:00
|
|
|
add_definitions (-DGLEW_NO_GLU)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-19 11:44:16 +00:00
|
|
|
include_directories (${GLEW_DIR}/include)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2015-02-19 11:44:16 +00:00
|
|
|
add_library (glew SHARED ${GLEW_DIR}/src/glew.c)
|
2015-02-26 11:10:12 +00:00
|
|
|
set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX "${DLL_PREFIX}")
|
2015-02-19 11:44:16 +00:00
|
|
|
add_library (glew_s STATIC ${GLEW_DIR}/src/glew.c)
|
2015-02-26 11:00:25 +00:00
|
|
|
set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib)
|
2015-02-06 08:33:39 +00:00
|
|
|
target_link_libraries (glew ${GLEW_LIBRARIES})
|
|
|
|
target_link_libraries (glew_s ${GLEW_LIBRARIES})
|
|
|
|
|
2015-02-19 11:44:16 +00:00
|
|
|
add_library(glewmx SHARED ${GLEW_DIR}/src/glew.c )
|
2015-02-26 11:10:12 +00:00
|
|
|
set_target_properties (glewmx PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD;GLEW_MX" OUTPUT_NAME "${GLEW_LIB_NAME}mx" PREFIX "${DLL_PREFIX}")
|
2015-02-19 11:44:16 +00:00
|
|
|
add_library(glewmx_s STATIC ${GLEW_DIR}/src/glew.c )
|
2015-02-26 11:10:12 +00:00
|
|
|
set_target_properties (glewmx_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC;GLEW_MX" OUTPUT_NAME "${GLEW_LIB_NAME}mx" PREFIX lib)
|
2015-02-06 08:33:39 +00:00
|
|
|
target_link_libraries (glewmx ${GLEW_LIBRARIES})
|
|
|
|
target_link_libraries (glewmx_s ${GLEW_LIBRARIES})
|
|
|
|
|
|
|
|
install ( TARGETS glew glew_s glewmx glewmx_s
|
2015-02-04 20:27:12 +00:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib${LIB_SUFFIX}
|
|
|
|
ARCHIVE DESTINATION lib${LIB_SUFFIX}
|
|
|
|
)
|
|
|
|
|
2015-02-06 08:33:39 +00:00
|
|
|
if (BUILD_UTILS)
|
2015-02-19 11:44:16 +00:00
|
|
|
add_executable (glewinfo ${GLEW_DIR}/src/glewinfo.c)
|
2015-02-06 08:33:39 +00:00
|
|
|
target_link_libraries (glewinfo glew)
|
|
|
|
|
2015-02-19 11:44:16 +00:00
|
|
|
add_executable (visualinfo ${GLEW_DIR}/src/visualinfo.c)
|
2015-02-06 08:33:39 +00:00
|
|
|
target_link_libraries (visualinfo glew)
|
|
|
|
|
|
|
|
install ( TARGETS glewinfo visualinfo
|
|
|
|
DESTINATION bin)
|
|
|
|
endif ()
|
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
set (prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set (exec_prefix \${prefix})
|
|
|
|
set (libdir \${prefix}/lib)
|
|
|
|
set (includedir \${prefix}/include)
|
|
|
|
set (includedir \${prefix}/include)
|
|
|
|
set (version ${GLEW_VERSION})
|
|
|
|
set (libname ${GLEW_LIB_NAME})
|
|
|
|
set (cflags)
|
|
|
|
set (requireslib glu)
|
2015-02-19 11:44:16 +00:00
|
|
|
configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glew.pc @ONLY)
|
2015-02-04 20:27:12 +00:00
|
|
|
set (cflags "-DGLEW_MX")
|
|
|
|
set (libname ${GLEW_LIB_NAME}mx)
|
2015-02-19 11:44:16 +00:00
|
|
|
configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glewmx.pc @ONLY)
|
2015-02-04 20:27:12 +00:00
|
|
|
|
2015-02-19 11:44:16 +00:00
|
|
|
install(FILES ${GLEW_DIR}/glew.pc ${GLEW_DIR}/glewmx.pc
|
2015-02-04 20:27:12 +00:00
|
|
|
DESTINATION lib/pkgconfig
|
|
|
|
)
|
2015-06-09 12:59:57 +00:00
|
|
|
|
|
|
|
install (DIRECTORY ${GLEW_DIR}/include/ DESTINATION include)
|