CMake: Use GNUInstallDirs to place the build artifacts properly

CMake 2.8.5 added the GNUInstallDirs module, which provides various
variables following the CMAKE_INSTALL_*DIR pattern to allow users a more
flexible installation setup and to provide sensible defaults while
respecting distribution specific install locations like lib64 for RPM
based linux distributions or debian multiarch tuples.
This commit is contained in:
Marcel Metz 2016-04-01 15:13:03 +02:00
parent c4bade8726
commit 3420a943ad

View File

@ -6,6 +6,8 @@ project (glew)
cmake_minimum_required (VERSION 2.8.7) cmake_minimum_required (VERSION 2.8.7)
include(GNUInstallDirs)
if (COMMAND cmake_policy) if (COMMAND cmake_policy)
cmake_policy (SET CMP0003 NEW) cmake_policy (SET CMP0003 NEW)
endif() endif()
@ -125,9 +127,9 @@ endif()
install ( TARGETS ${targets_to_install} install ( TARGETS ${targets_to_install}
${MAYBE_EXPORT} ${MAYBE_EXPORT}
RUNTIME DESTINATION bin RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION lib${LIB_SUFFIX} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
) )
if (BUILD_UTILS) if (BUILD_UTILS)
@ -152,7 +154,7 @@ if (BUILD_UTILS)
endif () endif ()
install ( TARGETS glewinfo visualinfo install ( TARGETS glewinfo visualinfo
DESTINATION bin) DESTINATION ${CMAKE_INSTALL_BINDIR})
endif () endif ()
set (prefix ${CMAKE_INSTALL_PREFIX}) set (prefix ${CMAKE_INSTALL_PREFIX})
@ -167,20 +169,20 @@ set (requireslib glu)
configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glew.pc @ONLY) configure_file (${GLEW_DIR}/glew.pc.in ${GLEW_DIR}/glew.pc @ONLY)
install(FILES ${GLEW_DIR}/glew.pc install(FILES ${GLEW_DIR}/glew.pc
DESTINATION lib/pkgconfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
) )
install (FILES install (FILES
${GLEW_DIR}/include/GL/wglew.h ${GLEW_DIR}/include/GL/wglew.h
${GLEW_DIR}/include/GL/glew.h ${GLEW_DIR}/include/GL/glew.h
${GLEW_DIR}/include/GL/glxew.h ${GLEW_DIR}/include/GL/glxew.h
DESTINATION include/GL) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GL)
if(MAYBE_EXPORT) if(MAYBE_EXPORT)
install(EXPORT glew-targets DESTINATION lib/cmake/glew install(EXPORT glew-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew
NAMESPACE GLEW::) NAMESPACE GLEW::)
install(FILES install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/glew-config.cmake ${CMAKE_CURRENT_SOURCE_DIR}/glew-config.cmake
${CMAKE_CURRENT_SOURCE_DIR}/CopyImportedTargetProperties.cmake ${CMAKE_CURRENT_SOURCE_DIR}/CopyImportedTargetProperties.cmake
DESTINATION lib/cmake/glew) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/glew)
endif() endif()