From f6eccf145beb28bdaf4a8d58cd01d110b729be18 Mon Sep 17 00:00:00 2001 From: Lambert Clara Date: Thu, 9 May 2013 15:47:44 +0200 Subject: [PATCH] Add glfwConfig module. This module allows cmake projects to find glfw with FIND_PACKAGE. --- CMakeLists.txt | 15 +++++++++++++++ src/CMakeLists.txt | 4 +++- src/glfwConfig.cmake.in | 10 ++++++++++ src/glfwConfigVersion.cmake.in | 10 ++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/glfwConfig.cmake.in create mode 100644 src/glfwConfigVersion.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a6f4740..17d26198 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -387,6 +387,21 @@ configure_file(${GLFW_SOURCE_DIR}/src/config.h.in install(DIRECTORY include/GL DESTINATION include FILES_MATCHING PATTERN glfw3.h PATTERN glfw3native.h) +#-------------------------------------------------------------------- +# Create and install glfwConfig.cmake and glfwConfigVersion files +#-------------------------------------------------------------------- +configure_file(${GLFW_SOURCE_DIR}/src/glfwConfig.cmake.in + ${GLFW_BINARY_DIR}/src/glfwConfig.cmake @ONLY) +configure_file(${GLFW_SOURCE_DIR}/src/glfwConfigVersion.cmake.in + ${GLFW_BINARY_DIR}/src/glfwConfigVersion.cmake @ONLY) + +install(FILES ${GLFW_BINARY_DIR}/src/glfwConfig.cmake + ${GLFW_BINARY_DIR}/src/glfwConfigVersion.cmake + DESTINATION lib${LIB_SUFFIX}/cmake/glfw) + +# Install the export set for use with the install-tree +install(EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}/cmake/glfw) + #-------------------------------------------------------------------- # Create and install pkg-config file on supported platforms #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6242795e..d0c87dbe 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -81,5 +81,7 @@ if (BUILD_SHARED_LIBS) target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) endif() -install(TARGETS glfw DESTINATION lib${LIB_SUFFIX} ) +install(TARGETS glfw + EXPORT glfwTargets + DESTINATION lib${LIB_SUFFIX} ) diff --git a/src/glfwConfig.cmake.in b/src/glfwConfig.cmake.in new file mode 100644 index 00000000..796ad2ca --- /dev/null +++ b/src/glfwConfig.cmake.in @@ -0,0 +1,10 @@ +# - Config file for the glfw package +# It defines the following variables +# GLFW_INCLUDE_DIR, the path where GLFW headers are located +# GLFW_LIBRARY_DIR, folder in which the GLFW library is located +# GLFW_LIBRARY, library to link against to use GLFW + +set(GLFW_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include") +set(GLFW_LIBRARY_DIR "@CMAKE_INSTALL_PREFIX@/lib@LIB_SUFFIX@") + +find_library(GLFW_LIBRARY "@GLFW_LIB_NAME@" HINTS ${GLFW_LIBRARY_DIR}) diff --git a/src/glfwConfigVersion.cmake.in b/src/glfwConfigVersion.cmake.in new file mode 100644 index 00000000..cd830661 --- /dev/null +++ b/src/glfwConfigVersion.cmake.in @@ -0,0 +1,10 @@ +set(PACKAGE_VERSION "@GLFW_VERSION_FULL@") + +if("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL "@GLFW_VERSION_MAJOR@") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if("${PACKAGE_FIND_VERSION_MINOR}" EQUAL @GLFW_VERSION_MINOR@) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) +endif()