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
|
|
|
|
2017-12-29 14:54:53 +00:00
|
|
|
project (glew C)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2017-04-22 23:20:49 +00:00
|
|
|
cmake_minimum_required (VERSION 2.8.12)
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2016-04-01 13:13:03 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2018-10-13 04:07:01 +00:00
|
|
|
if(POLICY CMP0003)
|
2015-02-04 20:27:12 +00:00
|
|
|
cmake_policy (SET CMP0003 NEW)
|
2018-10-13 04:07:01 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(POLICY CMP0042)
|
2017-04-22 23:20:49 +00:00
|
|
|
cmake_policy (SET CMP0042 NEW)
|
2015-02-04 20:27:12 +00:00
|
|
|
endif()
|
2014-12-01 10:13:15 +00:00
|
|
|
|
2015-06-22 12:06:50 +00:00
|
|
|
set(CMAKE_DEBUG_POSTFIX d)
|
|
|
|
|
2015-02-06 08:33:39 +00:00
|
|
|
option (BUILD_UTILS "utilities" ON)
|
2016-03-19 03:44:44 +00:00
|
|
|
option (GLEW_REGAL "Regal mode" OFF)
|
|
|
|
option (GLEW_OSMESA "OSMesa mode" OFF)
|
|
|
|
if (APPLE)
|
|
|
|
option (BUILD_FRAMEWORK "Build Framework bundle for OSX" OFF)
|
|
|
|
endif ()
|
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
|
|
|
|
2017-04-22 23:34:57 +00:00
|
|
|
find_package (OpenGL REQUIRED)
|
|
|
|
|
2019-01-29 12:12:38 +00:00
|
|
|
# X11 required except for Windows and Apple OSX platforms
|
|
|
|
if (NOT WIN32 AND NOT APPLE)
|
2017-04-22 23:34:57 +00:00
|
|
|
find_package (X11)
|
|
|
|
endif()
|
|
|
|
|
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
|
|
|
|
2019-01-29 12:12:38 +00:00
|
|
|
set (GLEW_LIBRARIES ${OPENGL_LIBRARIES} ${X11_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-10-10 01:22:12 +00:00
|
|
|
#### Regal mode ####
|
|
|
|
|
|
|
|
if (GLEW_REGAL)
|
|
|
|
if (WIN32)
|
|
|
|
set (REGAL_LIB_NAME regal32)
|
|
|
|
else ()
|
|
|
|
set (REGAL_LIB_NAME Regal)
|
|
|
|
endif ()
|
|
|
|
add_definitions (-DGLEW_REGAL)
|
|
|
|
set (GLEW_LIBRARIES ${REGAL_LIB_NAME})
|
|
|
|
endif ()
|
|
|
|
|
2015-10-08 12:03:16 +00:00
|
|
|
#### OSMesa mode ####
|
|
|
|
|
|
|
|
if (GLEW_OSMESA)
|
|
|
|
if (WIN32)
|
|
|
|
set (OSMESA_LIB_NAME osmesa)
|
|
|
|
else ()
|
|
|
|
set (OSMESA_LIB_NAME OSMesa)
|
|
|
|
endif ()
|
|
|
|
add_definitions (-DGLEW_OSMESA)
|
|
|
|
set (GLEW_LIBRARIES ${OSMESA_LIB_NAME} ${OPENGL_LIBRARIES})
|
2016-01-08 13:25:46 +00:00
|
|
|
set (X11_LIBRARIES)
|
2015-10-08 12:03:16 +00:00
|
|
|
endif ()
|
|
|
|
|
2018-12-19 00:04:53 +00:00
|
|
|
#### EGL ####
|
|
|
|
|
|
|
|
if (GLEW_EGL AND UNIX)
|
|
|
|
add_definitions (-DGLEW_EGL)
|
|
|
|
if (OpenGL::EGL)
|
|
|
|
message (FATAL_ERROR "EGL library set but not found.")
|
|
|
|
endif()
|
|
|
|
set (GLEW_LIBRARIES ${OPENGL_LIBRARIES} ${OPENGL_egl_LIBRARY})
|
|
|
|
endif ()
|
|
|
|
|
2015-10-10 01:22:12 +00:00
|
|
|
#### GLEW ####
|
|
|
|
|
2019-01-29 12:12:38 +00:00
|
|
|
include_directories (${GLEW_DIR}/include ${X11_INCLUDE_DIR})
|
2014-11-09 13:25:45 +00:00
|
|
|
|
2016-03-19 03:44:44 +00:00
|
|
|
set (GLEW_PUBLIC_HEADERS_FILES ${GLEW_DIR}/include/GL/wglew.h ${GLEW_DIR}/include/GL/glew.h ${GLEW_DIR}/include/GL/glxew.h)
|
2015-10-06 05:14:06 +00:00
|
|
|
set (GLEW_SRC_FILES ${GLEW_DIR}/src/glew.c)
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
list (APPEND GLEW_SRC_FILES ${GLEW_DIR}/build/glew.rc)
|
|
|
|
endif ()
|
|
|
|
|
2016-03-19 03:44:44 +00:00
|
|
|
add_library (glew SHARED ${GLEW_PUBLIC_HEADERS_FILES} ${GLEW_SRC_FILES})
|
2017-04-23 16:48:58 +00:00
|
|
|
set_target_properties (glew PROPERTIES COMPILE_DEFINITIONS "GLEW_BUILD" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX "${DLL_PREFIX}"
|
|
|
|
VERSION ${GLEW_VERSION}
|
|
|
|
SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR})
|
2016-03-19 03:44:44 +00:00
|
|
|
add_library (glew_s STATIC ${GLEW_PUBLIC_HEADERS_FILES} ${GLEW_SRC_FILES})
|
2016-02-06 15:54:29 +00:00
|
|
|
set_target_properties (glew_s PROPERTIES COMPILE_DEFINITIONS "GLEW_STATIC" OUTPUT_NAME "${GLEW_LIB_NAME}" PREFIX lib)
|
2016-03-19 03:44:44 +00:00
|
|
|
|
2016-02-05 07:53:25 +00:00
|
|
|
if (MSVC)
|
2016-02-06 18:10:02 +00:00
|
|
|
# add options from visual studio project
|
2016-02-06 15:54:29 +00:00
|
|
|
target_compile_definitions (glew PRIVATE "GLEW_BUILD;VC_EXTRALEAN")
|
|
|
|
target_compile_definitions (glew_s PRIVATE "GLEW_STATIC;VC_EXTRALEAN")
|
2016-02-06 18:30:15 +00:00
|
|
|
target_link_libraries (glew LINK_PRIVATE -BASE:0x62AA0000)
|
2016-02-05 07:53:25 +00:00
|
|
|
# kill security checks which are dependent on stdlib
|
|
|
|
target_compile_options (glew PRIVATE -GS-)
|
|
|
|
target_compile_options (glew_s PRIVATE -GS-)
|
2016-02-06 18:10:02 +00:00
|
|
|
# remove stdlib dependency
|
2016-02-06 18:30:15 +00:00
|
|
|
target_link_libraries (glew LINK_PRIVATE -nodefaultlib -noentry)
|
2016-11-06 17:42:20 +00:00
|
|
|
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
2016-02-05 07:53:25 +00:00
|
|
|
elseif (WIN32 AND ((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang")))
|
|
|
|
# remove stdlib dependency on windows with GCC and Clang (for similar reasons
|
|
|
|
# as to MSVC - to allow it to be used with any Windows compiler)
|
2016-02-06 18:10:02 +00:00
|
|
|
target_compile_options (glew PRIVATE -fno-builtin -fno-stack-protector)
|
|
|
|
target_compile_options (glew_s PRIVATE -fno-builtin -fno-stack-protector)
|
2016-02-06 18:30:15 +00:00
|
|
|
target_link_libraries (glew LINK_PRIVATE -nostdlib)
|
2016-02-05 07:53:25 +00:00
|
|
|
endif ()
|
2016-03-19 03:44:44 +00:00
|
|
|
|
|
|
|
if (BUILD_FRAMEWORK)
|
|
|
|
set_target_properties(glew PROPERTIES
|
|
|
|
FRAMEWORK TRUE
|
|
|
|
FRAMEWORK_VERSION ${GLEW_VERSION}
|
|
|
|
MACOSX_FRAMEWORK_IDENTIFIER net.sourceforge.glew
|
|
|
|
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${GLEW_VERSION}
|
|
|
|
MACOSX_FRAMEWORK_BUNDLE_VERSION ${GLEW_VERSION}
|
|
|
|
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
|
|
|
|
PUBLIC_HEADER "${GLEW_PUBLIC_HEADERS_FILES}"
|
|
|
|
OUTPUT_NAME GLEW
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-02-06 18:30:15 +00:00
|
|
|
target_link_libraries (glew LINK_PUBLIC ${GLEW_LIBRARIES})
|
2015-02-06 08:33:39 +00:00
|
|
|
target_link_libraries (glew_s ${GLEW_LIBRARIES})
|
|
|
|
|
2015-06-22 12:06:50 +00:00
|
|
|
if(CMAKE_VERSION VERSION_LESS 2.8.12)
|
|
|
|
set(MAYBE_EXPORT "")
|
|
|
|
else()
|
|
|
|
target_compile_definitions(glew_s INTERFACE "GLEW_STATIC")
|
2016-03-19 03:44:44 +00:00
|
|
|
foreach(t glew glew_s)
|
2015-06-22 12:06:50 +00:00
|
|
|
target_include_directories(${t} PUBLIC $<INSTALL_INTERFACE:include>)
|
|
|
|
endforeach()
|
|
|
|
set(MAYBE_EXPORT EXPORT glew-targets)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(targets_to_install "")
|
|
|
|
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
|
2016-03-19 03:44:44 +00:00
|
|
|
list(APPEND targets_to_install glew)
|
2015-06-22 12:06:50 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT DEFINED BUILD_SHARED_LIBS OR NOT BUILD_SHARED_LIBS)
|
2016-03-19 03:44:44 +00:00
|
|
|
list(APPEND targets_to_install glew_s)
|
2015-06-22 12:06:50 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install ( TARGETS ${targets_to_install}
|
|
|
|
${MAYBE_EXPORT}
|
2016-04-01 13:13:03 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
2016-04-02 08:35:50 +00:00
|
|
|
FRAMEWORK DESTINATION ${CMAKE_INSTALL_PREFIX}
|
2015-02-04 20:27:12 +00:00
|
|
|
)
|
|
|
|
|
2015-02-06 08:33:39 +00:00
|
|
|
if (BUILD_UTILS)
|
2015-10-06 05:14:06 +00:00
|
|
|
set (GLEWINFO_SRC_FILES ${GLEW_DIR}/src/glewinfo.c)
|
|
|
|
if (WIN32)
|
|
|
|
list (APPEND GLEWINFO_SRC_FILES ${GLEW_DIR}/build/glewinfo.rc)
|
|
|
|
endif ()
|
|
|
|
add_executable (glewinfo ${GLEWINFO_SRC_FILES})
|
2016-02-05 07:53:25 +00:00
|
|
|
target_link_libraries (glewinfo glew)
|
|
|
|
if (NOT WIN32)
|
|
|
|
target_link_libraries(glewinfo ${X11_LIBRARIES})
|
|
|
|
endif ()
|
2015-02-06 08:33:39 +00:00
|
|
|
|
2015-10-06 05:14:06 +00:00
|
|
|
set (VISUALINFO_SRC_FILES ${GLEW_DIR}/src/visualinfo.c)
|
|
|
|
if (WIN32)
|
|
|
|
list (APPEND VISUALINFO_SRC_FILES ${GLEW_DIR}/build/visualinfo.rc)
|
|
|
|
endif ()
|
|
|
|
add_executable (visualinfo ${VISUALINFO_SRC_FILES})
|
2016-02-05 07:53:25 +00:00
|
|
|
target_link_libraries (visualinfo glew)
|
|
|
|
if (NOT WIN32)
|
|
|
|
target_link_libraries(visualinfo ${X11_LIBRARIES})
|
|
|
|
endif ()
|
2015-02-06 08:33:39 +00:00
|
|
|
|
|
|
|
install ( TARGETS glewinfo visualinfo
|
2016-04-01 13:13:03 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
2015-02-06 08:33:39 +00:00
|
|
|
endif ()
|
|
|
|
|
2015-02-04 20:27:12 +00:00
|
|
|
set (prefix ${CMAKE_INSTALL_PREFIX})
|
2016-04-02 08:35:50 +00:00
|
|
|
set (exec_prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set (libdir ${CMAKE_INSTALL_FULL_LIBDIR})
|
|
|
|
set (includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
|
2015-02-04 20:27:12 +00:00
|
|
|
set (version ${GLEW_VERSION})
|
|
|
|
set (libname ${GLEW_LIB_NAME})
|
|
|
|
set (cflags)
|
|
|
|
set (requireslib glu)
|
2017-04-23 01:23:12 +00:00
|
|
|
|
|
|
|
# Mac OSX has no glu.pc unless optional X11/GLX is installed
|
|
|
|
if (APPLE)
|
|
|
|
set (requireslib)
|
|
|
|
endif ()
|
|
|
|
|
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
|
|
|
|
2017-04-23 17:23:04 +00:00
|
|
|
install(FILES ${GLEW_DIR}/glew.pc
|
2016-04-01 13:13:03 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
|
2015-02-04 20:27:12 +00:00
|
|
|
)
|
2015-06-09 12:59:57 +00:00
|
|
|
|
2016-12-27 19:29:03 +00:00
|
|
|
if(WIN32 AND MSVC AND (NOT MSVC_VERSION LESS 1600) AND (NOT CMAKE_VERSION VERSION_LESS "3.1"))
|
2016-03-10 10:50:32 +00:00
|
|
|
install(
|
|
|
|
FILES $<TARGET_PDB_FILE:glew>
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
CONFIGURATIONS Debug RelWithDebInfo
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-06-10 08:27:28 +00:00
|
|
|
install (FILES
|
2015-06-10 08:30:26 +00:00
|
|
|
${GLEW_DIR}/include/GL/wglew.h
|
|
|
|
${GLEW_DIR}/include/GL/glew.h
|
|
|
|
${GLEW_DIR}/include/GL/glxew.h
|
2016-04-01 13:13:03 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GL)
|
2015-06-22 12:06:50 +00:00
|
|
|
|
|
|
|
if(MAYBE_EXPORT)
|
2016-04-01 13:13:03 +00:00
|
|
|
install(EXPORT glew-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew
|
2015-06-22 12:06:50 +00:00
|
|
|
NAMESPACE GLEW::)
|
|
|
|
install(FILES
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/glew-config.cmake
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/CopyImportedTargetProperties.cmake
|
2016-04-01 13:13:03 +00:00
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew)
|
2015-06-22 12:06:50 +00:00
|
|
|
endif()
|
2017-06-20 23:06:47 +00:00
|
|
|
|
|
|
|
if(NOT TARGET uninstall)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
|
|
endif()
|