CMakeLists.txt: use GNUInstallDirs
authorAntonio Ospite <ao2@ao2.it>
Fri, 2 Mar 2018 12:40:48 +0000 (13:40 +0100)
committerAntonio Ospite <ao2@ao2.it>
Fri, 2 Mar 2018 17:28:14 +0000 (18:28 +0100)
This fixes installation in multi-arch paths on systems which supports that.

CMakeLists.txt
doc/CMakeLists.txt
doc/man/CMakeLists.txt
examples/CMakeLists.txt
src/CMakeLists.txt
src/libam7xxx.pc.in

index 73657f8..f234866 100644 (file)
@@ -1,6 +1,8 @@
 cmake_minimum_required(VERSION 2.6)
 project(libam7xxx C)
 
+include (GNUInstallDirs)
+
 set(PROJECT_DESCRIPTION
   "Communication library for Actions Micro AM7XXX based USB projectors and DPFs")
 
index 6ccf100..0335a2e 100644 (file)
@@ -17,7 +17,7 @@ if(DOXYGEN_FOUND)
   install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} doc)")
 
   install(DIRECTORY ${DOC_OUTPUT_PATH}/html
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}"
+    DESTINATION ${CMAKE_INSTALL_DOCDIR}
     COMPONENT doc)
 
 endif(DOXYGEN_FOUND)
index c7ce4bb..f97b1cb 100644 (file)
@@ -20,7 +20,7 @@ if(ASCIIDOC_FOUND)
     ${DOC_OUTPUT_PATH}/man/am7xxx-play.1
     ${DOC_OUTPUT_PATH}/man/am7xxx-modeswitch.1
     ${DOC_OUTPUT_PATH}/man/picoproj.1
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1/"
+    DESTINATION "${CMAKE_INSTALL_MANDIR}/man1/"
     COMPONENT manpages)
 
 endif(ASCIIDOC_FOUND)
index d44a26f..f624ba5 100644 (file)
@@ -9,7 +9,7 @@ if(BUILD_PICOPROJ)
   add_executable(picoproj picoproj.c)
   target_link_libraries(picoproj am7xxx)
   install(TARGETS picoproj
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
+    DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
 # Build a more complete example
@@ -58,7 +58,7 @@ if(BUILD_AM7XXX-PLAY)
     ${FFMPEG_LIBSWSCALE_LIBRARIES}
     ${OPTIONAL_LIBRARIES})
   install(TARGETS am7xxx-play
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
+    DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
 # Build a simple usb-modeswitch clone for am7xxx devices
@@ -71,6 +71,6 @@ if(BUILD_am7xxx-modeswitch)
   add_executable(am7xxx-modeswitch am7xxx-modeswitch.c)
   target_link_libraries(am7xxx-modeswitch ${LIBUSB_1_LIBRARIES})
   install(TARGETS am7xxx-modeswitch
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
+    DESTINATION ${CMAKE_INSTALL_BINDIR})
 endif()
 
index d6cdaad..9422436 100644 (file)
@@ -17,7 +17,7 @@ set_target_properties(am7xxx PROPERTIES
   VERSION ${PROJECT_VER}
   SOVERSION ${PROJECT_APIVER})
 install(TARGETS am7xxx
-  DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
+  DESTINATION "${CMAKE_INSTALL_LIBDIR}")
 
 add_library(am7xxx-static STATIC ${SRC})
 set_target_properties(am7xxx-static PROPERTIES OUTPUT_NAME am7xxx)
@@ -25,7 +25,7 @@ if(UNIX AND NOT APPLE)
   set_target_properties(am7xxx-static PROPERTIES COMPILE_FLAGS "-fPIC")
 endif()
 install(TARGETS am7xxx-static
-   DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
+  DESTINATION "${CMAKE_INSTALL_LIBDIR}")
 
 if(NOT WIN32)
   find_library(MATH_LIB m)
@@ -39,11 +39,11 @@ target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES})
 
 # Install the header files
 install(FILES "am7xxx.h"
-  DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
 
 if(UNIX AND NOT APPLE)
   # Produce a pkg-config file for linking against the shared lib
   configure_file("libam7xxx.pc.in" "libam7xxx.pc" @ONLY)
   install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libam7xxx.pc"
-    DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
+    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 endif()
index dff65c6..a596abc 100644 (file)
@@ -1,7 +1,5 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
 
 Name: @PROJECT_NAME@
 Description: @PROJECT_DESCRIPTION@