CMakeLists.txt 3.39 KB
Newer Older
Michel Zou's avatar
Michel Zou committed
1
2
3
if ( NOT DEFINED CMAKE_BUILD_TYPE )
  set( CMAKE_BUILD_TYPE Release CACHE STRING "Build type" )
endif ()
Togo Nishigaki's avatar
Togo Nishigaki committed
4

Michel Zou's avatar
Michel Zou committed
5
project (glew)
Togo Nishigaki's avatar
Togo Nishigaki committed
6

Michel Zou's avatar
Michel Zou committed
7
cmake_minimum_required (VERSION 2.4)
Togo Nishigaki's avatar
Togo Nishigaki committed
8

Michel Zou's avatar
Michel Zou committed
9
10
11
if (COMMAND cmake_policy)
  cmake_policy (SET CMP0003 NEW)
endif()
12

Michel Zou's avatar
Michel Zou committed
13
option (BUILD_UTILS "utilities" ON)
Togo Nishigaki's avatar
Togo Nishigaki committed
14

15
16
set (GLEW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)

17
18
19
20
21
22
23
24
25
# 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})

Michel Zou's avatar
Michel Zou committed
26
27
28
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)
Togo Nishigaki's avatar
Togo Nishigaki committed
29

Michel Zou's avatar
Michel Zou committed
30
if (WIN32)
Michel Zou's avatar
Michel Zou committed
31
  set (GLEW_LIB_NAME glew32)
Michel Zou's avatar
Michel Zou committed
32
else ()
Michel Zou's avatar
Michel Zou committed
33
34
  set (GLEW_LIB_NAME GLEW)
  set (DLL_PREFIX lib)
Michel Zou's avatar
Michel Zou committed
35
endif ()
36

Michel Zou's avatar
Michel Zou committed
37
38
find_package (OpenGL REQUIRED)
set (GLEW_LIBRARIES ${OPENGL_LIBRARIES})
39

40
add_definitions (-DGLEW_NO_GLU)
Togo Nishigaki's avatar
Togo Nishigaki committed
41

42
include_directories (${GLEW_DIR}/include)
Togo Nishigaki's avatar
Togo Nishigaki committed
43

44
add_library (glew SHARED ${GLEW_DIR}/src/glew.c)
45
set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX "${DLL_PREFIX}")
46
add_library (glew_s STATIC ${GLEW_DIR}/src/glew.c)
47
set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib)
Michel Zou's avatar
Michel Zou committed
48
49
50
target_link_libraries (glew ${GLEW_LIBRARIES})
target_link_libraries (glew_s ${GLEW_LIBRARIES})

51
add_library(glewmx SHARED ${GLEW_DIR}/src/glew.c )
52
set_target_properties (glewmx PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD;GLEW_MX" OUTPUT_NAME "${GLEW_LIB_NAME}mx" PREFIX "${DLL_PREFIX}")
53
add_library(glewmx_s STATIC ${GLEW_DIR}/src/glew.c )
54
set_target_properties (glewmx_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC;GLEW_MX" OUTPUT_NAME "${GLEW_LIB_NAME}mx" PREFIX lib)
Michel Zou's avatar
Michel Zou committed
55
56
57
58
target_link_libraries (glewmx ${GLEW_LIBRARIES})
target_link_libraries (glewmx_s ${GLEW_LIBRARIES})

install ( TARGETS glew glew_s glewmx glewmx_s
Michel Zou's avatar
Michel Zou committed
59
60
61
62
63
          RUNTIME DESTINATION bin
          LIBRARY DESTINATION lib${LIB_SUFFIX}
          ARCHIVE DESTINATION lib${LIB_SUFFIX}
)

Michel Zou's avatar
Michel Zou committed
64
if (BUILD_UTILS)
65
  add_executable (glewinfo ${GLEW_DIR}/src/glewinfo.c)
Michel Zou's avatar
Michel Zou committed
66
67
  target_link_libraries (glewinfo glew)

68
  add_executable (visualinfo ${GLEW_DIR}/src/visualinfo.c)
Michel Zou's avatar
Michel Zou committed
69
70
71
72
73
74
  target_link_libraries (visualinfo glew)

  install ( TARGETS glewinfo visualinfo
            DESTINATION bin)
endif ()

Michel Zou's avatar
Michel Zou committed
75
76
77
78
79
80
81
82
83
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)
84
configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glew.pc @ONLY)
Michel Zou's avatar
Michel Zou committed
85
86
set (cflags "-DGLEW_MX")
set (libname ${GLEW_LIB_NAME}mx)
87
configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glewmx.pc @ONLY)
Michel Zou's avatar
Michel Zou committed
88

89
install(FILES ${GLEW_DIR}/glew.pc ${GLEW_DIR}/glewmx.pc
Michel Zou's avatar
Michel Zou committed
90
91
        DESTINATION lib/pkgconfig
)