mirror of
https://github.com/glfw/glfw.git
synced 2025-10-04 05:36:35 +00:00
Merge 2f59dadb0c
into ac9a6f8504
This commit is contained in:
commit
75a1c67458
17
.travis.yml
Normal file
17
.travis.yml
Normal file
@ -0,0 +1,17 @@
|
||||
language: cpp
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
env:
|
||||
- BUILD_SHARED_LIBS=ON
|
||||
- BUILD_SHARED_LIBS=OFF
|
||||
sudo: false
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- kubuntu-backports
|
||||
packages:
|
||||
- cmake
|
||||
script:
|
||||
- cmake -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} .
|
||||
- cmake --build .
|
104
CMakeLists.txt
104
CMakeLists.txt
@ -1,6 +1,7 @@
|
||||
project(GLFW C)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
cmake_policy(SET CMP0022 NEW)
|
||||
|
||||
if (NOT CMAKE_VERSION VERSION_LESS "3.0")
|
||||
# Until all major package systems have moved to CMake 3,
|
||||
@ -468,41 +469,11 @@ else()
|
||||
set(GLFW_LIB_NAME glfw3)
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Create generated files
|
||||
#--------------------------------------------------------------------
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
if (UNIX)
|
||||
set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake/glfw3/")
|
||||
else()
|
||||
set(GLFW_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/")
|
||||
endif()
|
||||
|
||||
configure_package_config_file("${GLFW_SOURCE_DIR}/src/glfw3Config.cmake.in"
|
||||
"${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
|
||||
INSTALL_DESTINATION "${GLFW_CONFIG_PATH}"
|
||||
PATH_VARS CMAKE_INSTALL_PREFIX
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
|
||||
write_basic_package_version_file("${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
|
||||
VERSION ${GLFW_VERSION_FULL}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
if (GLFW_BUILD_DOCS)
|
||||
configure_file("${GLFW_SOURCE_DIR}/docs/Doxyfile.in"
|
||||
"${GLFW_BINARY_DIR}/docs/Doxyfile" @ONLY)
|
||||
endif()
|
||||
|
||||
configure_file("${GLFW_SOURCE_DIR}/src/glfw_config.h.in"
|
||||
"${GLFW_BINARY_DIR}/src/glfw_config.h" @ONLY)
|
||||
|
||||
configure_file("${GLFW_SOURCE_DIR}/src/glfw3.pc.in"
|
||||
"${GLFW_BINARY_DIR}/src/glfw3.pc" @ONLY)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Add subdirectories
|
||||
#--------------------------------------------------------------------
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if (GLFW_BUILD_EXAMPLES)
|
||||
@ -517,26 +488,75 @@ if (DOXYGEN_FOUND AND GLFW_BUILD_DOCS)
|
||||
add_subdirectory(docs)
|
||||
endif()
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Create generated files
|
||||
#--------------------------------------------------------------------
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
set(GLFW_INSTALL_CONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/glfw3")
|
||||
set(GLFW_INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
|
||||
write_basic_package_version_file(
|
||||
glfw3ConfigVersion.cmake
|
||||
VERSION ${GLFW_VERSION_FULL}
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
|
||||
# build tree package export
|
||||
configure_file(
|
||||
src/glfw3BuildConfig.cmake.in
|
||||
glfw3Config.cmake
|
||||
COPYONLY)
|
||||
|
||||
export(
|
||||
TARGETS glfw
|
||||
FILE glfw3Targets.cmake)
|
||||
|
||||
if (GLFW_BUILD_DOCS)
|
||||
configure_file(docs/Doxyfile.in
|
||||
docs/Doxyfile @ONLY)
|
||||
endif()
|
||||
|
||||
configure_file(src/glfw_config.h.in
|
||||
src/glfw_config.h @ONLY)
|
||||
|
||||
configure_file(src/glfw3.pc.in
|
||||
src/glfw3.pc @ONLY)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Install files other than the library
|
||||
# The library is installed by src/CMakeLists.txt
|
||||
#--------------------------------------------------------------------
|
||||
if (GLFW_INSTALL)
|
||||
install(DIRECTORY include/GLFW DESTINATION include
|
||||
FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h)
|
||||
configure_package_config_file(src/glfw3Config.cmake.in
|
||||
${GLFW_INSTALL_CONFIG_DIR}/glfw3Config.cmake
|
||||
INSTALL_DESTINATION ${GLFW_INSTALL_CONFIG_DIR}
|
||||
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
|
||||
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
|
||||
|
||||
install(FILES "${GLFW_BINARY_DIR}/src/glfw3Config.cmake"
|
||||
"${GLFW_BINARY_DIR}/src/glfw3ConfigVersion.cmake"
|
||||
DESTINATION lib${LIB_SUFFIX}/cmake/glfw)
|
||||
install(
|
||||
DIRECTORY include/GLFW
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
FILES_MATCHING PATTERN *.h)
|
||||
|
||||
install(EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}/cmake/glfw)
|
||||
install(FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
|
||||
DESTINATION lib${LIB_SUFFIX}/pkgconfig)
|
||||
install(
|
||||
FILES
|
||||
${GLFW_BINARY_DIR}/${GLFW_INSTALL_CONFIG_DIR}/glfw3Config.cmake
|
||||
${GLFW_BINARY_DIR}/glfw3ConfigVersion.cmake
|
||||
DESTINATION ${GLFW_INSTALL_CONFIG_DIR})
|
||||
|
||||
install(
|
||||
EXPORT glfwTargets
|
||||
FILE glfw3Targets.cmake
|
||||
DESTINATION ${GLFW_INSTALL_CONFIG_DIR})
|
||||
|
||||
install(
|
||||
FILES "${GLFW_BINARY_DIR}/src/glfw3.pc"
|
||||
DESTINATION ${GLFW_INSTALL_PKGCONFIG_DIR})
|
||||
|
||||
# Only generate this target if no higher-level project already has
|
||||
if (NOT TARGET uninstall)
|
||||
configure_file("${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${GLFW_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
|
||||
configure_file(cmake_uninstall.cmake.in
|
||||
cmake_uninstall.cmake IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
"${CMAKE_COMMAND}" -P
|
||||
|
7
appveyor.yml
Normal file
7
appveyor.yml
Normal file
@ -0,0 +1,7 @@
|
||||
environment:
|
||||
matrix:
|
||||
- BUILD_SHARED_LIBS: ON
|
||||
- BUILD_SHARED_LIBS: OFF
|
||||
build_script:
|
||||
- cmake -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% .
|
||||
- cmake --build .
|
@ -58,7 +58,7 @@ either be included _before_ the GLFW one, or the `GLFW_INCLUDE_NONE` macro
|
||||
These macros may be defined before the inclusion of the GLFW header and affect
|
||||
its behavior.
|
||||
|
||||
`GLFW_DLL` is required on Windows when using the GLFW DLL, to tell the compiler
|
||||
`GLFW_DLL` is required on Windows (GLFW before 3.2) when using the GLFW DLL, to tell the compiler
|
||||
that the GLFW functions are defined in a DLL.
|
||||
|
||||
The following macros control which OpenGL or OpenGL ES API header is included.
|
||||
@ -165,26 +165,40 @@ compiler where to find it.
|
||||
include_directories(path/to/glfw/include)
|
||||
@endcode
|
||||
|
||||
Once GLFW has been added to the project, the `GLFW_LIBRARIES` cache variable
|
||||
contains all link-time dependencies of GLFW as it is currently configured. To
|
||||
link against GLFW, link against them and the `glfw` target.
|
||||
|
||||
You need to link against glfw library and its transitive dependencies.
|
||||
@code{.cmake}
|
||||
target_link_libraries(myapp glfw ${GLFW_LIBRARIES})
|
||||
target_link_libraries(myapp glfw)
|
||||
@endcode
|
||||
|
||||
Note that `GLFW_LIBRARIES` does not include GLU, as GLFW does not use it. If
|
||||
your application needs GLU, you can add it to the list of dependencies with the
|
||||
`OPENGL_glu_LIBRARY` cache variable, which is implicitly created when the GLFW
|
||||
CMake files look for OpenGL.
|
||||
Note that glfw transitive dependencies do not include GLU, as GLFW does not use
|
||||
it. If your application needs GLU, you can add it to the list of dependencies
|
||||
with the `OPENGL_glu_LIBRARY` cache variable, which is implicitly created when
|
||||
the GLFW CMake files look for OpenGL.
|
||||
|
||||
@code{.cmake}
|
||||
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY} ${GLFW_LIBRARIES})
|
||||
target_link_libraries(myapp glfw ${OPENGL_glu_LIBRARY})
|
||||
@endcode
|
||||
|
||||
@subsection build_link_cmake With CMake and installed GLFW binaries
|
||||
|
||||
CMake can import settings from CMake package file, which GLFW supports.
|
||||
|
||||
@code{.cmake}
|
||||
find_package(glfw3 REQUIRED)
|
||||
@endcode
|
||||
|
||||
This registers glfw imported target in your build.
|
||||
You need to link against glfw library and its transitive dependencies.
|
||||
|
||||
@code{.cmake}
|
||||
target_link_libraries(simple glfw)
|
||||
@endcode
|
||||
|
||||
@subsection build_link_cmake_pkgconfig With CMake on Unix and installed GLFW binaries
|
||||
|
||||
@deprecated Since GLFW 3.2 it is recommended to use @ref build_link_cmake
|
||||
"native CMake configuration files"
|
||||
|
||||
CMake can import settings from pkg-config, which GLFW supports. When you
|
||||
installed GLFW, the pkg-config file `glfw3.pc` was installed along with it.
|
||||
|
||||
@ -223,9 +237,11 @@ If you are using the static library version of GLFW, use the
|
||||
target_link_libraries(simple ${GLFW_STATIC_LIBRARIES})
|
||||
@endcode
|
||||
|
||||
|
||||
@subsection build_link_pkgconfig With pkg-config on OS X or other Unix
|
||||
|
||||
@deprecated Since GLFW 3.2 it is recommended to use @ref build_link_cmake
|
||||
"native CMake configuration files"
|
||||
|
||||
GLFW supports [pkg-config](http://www.freedesktop.org/wiki/Software/pkg-config/),
|
||||
and the `glfw3.pc` pkf-config file is generated when the GLFW library is built
|
||||
and is installed along with it. A pkg-config file describes all necessary
|
||||
|
@ -1,19 +1,5 @@
|
||||
|
||||
link_libraries(glfw)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_definitions(-DGLFW_DLL)
|
||||
link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}")
|
||||
else()
|
||||
link_libraries(${glfw_LIBRARIES})
|
||||
endif()
|
||||
|
||||
include_directories("${GLFW_SOURCE_DIR}/include"
|
||||
"${GLFW_SOURCE_DIR}/deps")
|
||||
|
||||
if ("${OPENGL_INCLUDE_DIR}")
|
||||
include_directories("${OPENGL_INCLUDE_DIR}")
|
||||
endif()
|
||||
include_directories(${GLFW_SOURCE_DIR}/deps)
|
||||
|
||||
set(GLAD "${GLFW_SOURCE_DIR}/deps/glad/glad.h"
|
||||
"${GLFW_SOURCE_DIR}/deps/glad.c")
|
||||
@ -56,4 +42,3 @@ if (APPLE)
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL}
|
||||
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
|
||||
endif()
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
|
||||
include_directories("${GLFW_SOURCE_DIR}/src"
|
||||
"${GLFW_BINARY_DIR}/src"
|
||||
${glfw_INCLUDE_DIRS})
|
||||
|
||||
add_definitions(-D_GLFW_USE_CONFIG_H)
|
||||
|
||||
set(common_HEADERS internal.h
|
||||
"${GLFW_BINARY_DIR}/src/glfw_config.h"
|
||||
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h"
|
||||
@ -58,15 +51,28 @@ if (APPLE)
|
||||
endif()
|
||||
|
||||
add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS})
|
||||
target_link_libraries(glfw ${glfw_LIBRARIES})
|
||||
target_include_directories(glfw
|
||||
PUBLIC
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
|
||||
PRIVATE
|
||||
"${GLFW_SOURCE_DIR}/src"
|
||||
"${GLFW_BINARY_DIR}/src"
|
||||
${glfw_INCLUDE_DIRS})
|
||||
target_compile_definitions(glfw PRIVATE -D_GLFW_USE_CONFIG_H)
|
||||
|
||||
set_target_properties(glfw PROPERTIES
|
||||
OUTPUT_NAME "${GLFW_LIB_NAME}"
|
||||
VERSION ${GLFW_VERSION}
|
||||
SOVERSION ${GLFW_VERSION_MAJOR}
|
||||
POSITION_INDEPENDENT_CODE ON
|
||||
FOLDER "GLFW3")
|
||||
FOLDER "GLFW3"
|
||||
DEBUG_POSTFIX d)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if (WIN32)
|
||||
target_compile_definitions(glfw INTERFACE -DGLFW_DLL)
|
||||
# The GLFW DLL needs a special compile-time macro and import library name
|
||||
set_target_properties(glfw PROPERTIES PREFIX "" IMPORT_PREFIX "")
|
||||
|
||||
@ -86,11 +92,8 @@ if (BUILD_SHARED_LIBS)
|
||||
COMPILE_FLAGS "${glfw_CFLAGS} -fno-common"
|
||||
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
|
||||
endif()
|
||||
|
||||
target_link_libraries(glfw ${glfw_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (GLFW_INSTALL)
|
||||
install(TARGETS glfw EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX})
|
||||
endif()
|
||||
|
||||
|
1
src/glfw3BuildConfig.cmake.in
Normal file
1
src/glfw3BuildConfig.cmake.in
Normal file
@ -0,0 +1 @@
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")
|
@ -8,8 +8,8 @@ set(GLFW3_VERSION "@GLFW_VERSION_FULL@")
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(GLFW3_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/include")
|
||||
set_and_check(GLFW3_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@")
|
||||
|
||||
find_library(GLFW3_LIBRARY "@GLFW_LIB_NAME@" HINTS ${GLFW3_LIBRARY_DIR})
|
||||
set_and_check(GLFW3_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
|
||||
set_and_check(GLFW3_LIBRARY_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/glfw3Targets.cmake")
|
||||
set(GLFW3_LIBRARY glfw)
|
||||
|
@ -1,19 +1,5 @@
|
||||
|
||||
link_libraries(glfw)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_definitions(-DGLFW_DLL)
|
||||
link_libraries("${OPENGL_gl_LIBRARY}" "${MATH_LIBRARY}")
|
||||
else()
|
||||
link_libraries(${glfw_LIBRARIES})
|
||||
endif()
|
||||
|
||||
include_directories("${GLFW_SOURCE_DIR}/include"
|
||||
"${GLFW_SOURCE_DIR}/deps")
|
||||
|
||||
if ("${OPENGL_INCLUDE_DIR}")
|
||||
include_directories("${OPENGL_INCLUDE_DIR}")
|
||||
endif()
|
||||
include_directories(${GLFW_SOURCE_DIR}/deps)
|
||||
|
||||
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
|
||||
"${GLFW_SOURCE_DIR}/deps/getopt.c")
|
||||
|
Loading…
Reference in New Issue
Block a user