Merge pull request #32 from jzarl/cmake-package

Cmake package
This commit is contained in:
Diederick C. Niehorster 2015-07-11 23:25:29 +02:00
commit 9f7338ebe5
2 changed files with 47 additions and 9 deletions

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR) CMAKE_MINIMUM_REQUIRED(VERSION 3.0.0 FATAL_ERROR)
PROJECT(freeglut) PROJECT(freeglut)
# for multiarch LIBDIR support (requires cmake>=2.8.8) # for multiarch LIBDIR support (requires cmake>=2.8.8)
@ -20,6 +20,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(VERSION_MAJOR 3) set(VERSION_MAJOR 3)
set(VERSION_MINOR 0) set(VERSION_MINOR 0)
set(VERSION_PATCH 0) set(VERSION_PATCH 0)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# Update fg_version.h to match the versions number here in cmake # Update fg_version.h to match the versions number here in cmake
CONFIGURE_FILE(src/fg_version.h.in src/fg_version.h) CONFIGURE_FILE(src/fg_version.h.in src/fg_version.h)
@ -244,7 +245,7 @@ ENDIF()
# but do use GLES constants directly for all other needs # but do use GLES constants directly for all other needs
# GLES1 and GLES2 libraries are compatible and can be co-linked. # GLES1 and GLES2 libraries are compatible and can be co-linked.
IF(FREEGLUT_GLES) IF(FREEGLUT_GLES)
ADD_DEFINITIONS(-DFREEGLUT_GLES) LIST(APPEND PUBLIC_DEFINITIONS -DFREEGLUT_GLES)
LIST(APPEND LIBS GLESv2 GLESv1_CM EGL) LIST(APPEND LIBS GLESv2 GLESv1_CM EGL)
ELSE() ELSE()
FIND_PACKAGE(OpenGL REQUIRED) FIND_PACKAGE(OpenGL REQUIRED)
@ -448,36 +449,42 @@ ELSE()
ENDIF() ENDIF()
IF(FREEGLUT_BUILD_SHARED_LIBS) IF(FREEGLUT_BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(freeglut ${LIBS}) TARGET_LINK_LIBRARIES(freeglut ${LIBS})
TARGET_COMPILE_DEFINITIONS(freeglut PUBLIC ${PUBLIC_DEFINITIONS})
ENDIF() ENDIF()
IF(FREEGLUT_BUILD_STATIC_LIBS) IF(FREEGLUT_BUILD_STATIC_LIBS)
TARGET_LINK_LIBRARIES(freeglut_static ${LIBS}) TARGET_LINK_LIBRARIES(freeglut_static ${LIBS})
TARGET_COMPILE_DEFINITIONS(freeglut_static PUBLIC ${PUBLIC_DEFINITIONS})
ENDIF() ENDIF()
IF(FREEGLUT_BUILD_SHARED_LIBS) IF(FREEGLUT_BUILD_SHARED_LIBS)
INSTALL(TARGETS freeglut INSTALL(TARGETS freeglut EXPORT FreeGLUTTargets
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include
) )
IF(INSTALL_PDB) IF(INSTALL_PDB)
INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/freeglut${CMAKE_DEBUG_POSTFIX}.pdb INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/freeglut${CMAKE_DEBUG_POSTFIX}.pdb
DESTINATION bin DESTINATION bin
CONFIGURATIONS Debug) CONFIGURATIONS Debug
COMPONENT Devel)
ENDIF() ENDIF()
ENDIF() ENDIF()
IF(FREEGLUT_BUILD_STATIC_LIBS) IF(FREEGLUT_BUILD_STATIC_LIBS)
INSTALL(TARGETS freeglut_static INSTALL(TARGETS freeglut_static EXPORT FreeGLUTTargets
RUNTIME DESTINATION bin RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION include
) )
IF(INSTALL_PDB) IF(INSTALL_PDB)
INSTALL(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/Debug/freeglut_static${CMAKE_DEBUG_POSTFIX}.pdb INSTALL(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/Debug/freeglut_static${CMAKE_DEBUG_POSTFIX}.pdb
DESTINATION lib DESTINATION lib
CONFIGURATIONS Debug) CONFIGURATIONS Debug
COMPONENT Devel)
ENDIF() ENDIF()
ENDIF() ENDIF()
INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL) INSTALL(FILES ${FREEGLUT_HEADERS} DESTINATION include/GL COMPONENT Devel)
@ -571,6 +578,36 @@ IF(FREEGLUT_GLES)
SET(PC_FILENAME "freeglut-gles.pc") SET(PC_FILENAME "freeglut-gles.pc")
ENDIF() ENDIF()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY)
INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ RENAME ${PC_FILENAME}) INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ RENAME ${PC_FILENAME} COMPONENT Devel)
# TODO: change the library and .pc name when building for GLES, # TODO: change the library and .pc name when building for GLES,
# e.g. -lglut-GLES # e.g. -lglut-GLES
INCLUDE(CMakePackageConfigHelpers)
WRITE_BASIC_PACKAGE_VERSION_FILE(
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfigVersion.cmake"
VERSION ${VERSION}
COMPATIBILITY AnyNewerVersion
)
# needs cmake 3.0 (as does the "INCLUDES DIRECTORY" argument to install(TARGETS)):
EXPORT(EXPORT FreeGLUTTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTTargets.cmake"
NAMESPACE FreeGLUT::
)
CONFIGURE_FILE(FreeGLUTConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfig.cmake"
@ONLY
)
SET(ConfigPackageLocation lib/cmake/FreeGLUT)
INSTALL(EXPORT FreeGLUTTargets
FILE FreeGLUTTargets.cmake
NAMESPACE FreeGLUT::
DESTINATION ${ConfigPackageLocation}
)
INSTALL(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/FreeGLUT/FreeGLUTConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
COMPONENT Devel
)

View File

@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/FreeGLUTTargets.cmake")