cmake: Use GNUInstallDirs.

This commit is contained in:
orbea 2020-11-30 07:07:51 -08:00 committed by lightningterror
parent 97b74fa6ea
commit 44b700a6fd
5 changed files with 19 additions and 41 deletions

View File

@ -24,6 +24,8 @@ check_compiler_version("7.0" "7.0")
#-------------------------------------------------------------------------------
# Include specific module
# GNUInstallDirs must be done before BuildParameters
include(GNUInstallDirs)
# BuildParameters Must be done before SearchForStuff
include(BuildParameters)
# SearchForStuff be done before SelectPcsx2Plugins
@ -68,9 +70,9 @@ endif()
# Install some files to ease package creation
if(PACKAGE_MODE)
if(NOT DISABLE_CHEATS_ZIP)
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/cheats_ws.zip" DESTINATION "${GAMEINDEX_DIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/cheats_ws.zip" DESTINATION "${CMAKE_INSTALL_DATADIR}/PCSX2")
endif()
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/GameIndex.yaml" DESTINATION "${GAMEINDEX_DIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/GameIndex.yaml" DESTINATION "${CMAKE_INSTALL_DATADIR}/PCSX2")
# set categories depending on system/distribution in pcsx2.desktop
if(openSUSE)
@ -80,13 +82,13 @@ if(PACKAGE_MODE)
endif()
configure_file("${CMAKE_SOURCE_DIR}/linux_various/PCSX2.desktop.in" "${CMAKE_BINARY_DIR}/linux_various/PCSX2.desktop" @ONLY)
INSTALL(FILES "${CMAKE_BINARY_DIR}/linux_various/PCSX2.desktop" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/applications")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/linux_various/PCSX2.xpm" DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pixmaps")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/docs/PCSX2_FAQ.pdf" DESTINATION "${DOC_DIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/docs/Configuration_Guide.pdf" DESTINATION "${DOC_DIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/docs/PCSX2.1" DESTINATION "${MAN_DIR}/man1")
INSTALL(FILES "${CMAKE_BINARY_DIR}/linux_various/PCSX2.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/linux_various/PCSX2.xpm" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/docs/PCSX2_FAQ.pdf" DESTINATION "${CMAKE_INSTALL_DOCDIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/docs/Configuration_Guide.pdf" DESTINATION "${CMAKE_INSTALL_DOCDIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/bin/docs/PCSX2.1" DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
if(NOT DISABLE_PCSX2_WRAPPER)
INSTALL(FILES "${CMAKE_SOURCE_DIR}/linux_various/PCSX2-linux.sh" DESTINATION "${BIN_DIR}")
INSTALL(FILES "${CMAKE_SOURCE_DIR}/linux_various/PCSX2-linux.sh" DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
else()

View File

@ -1,6 +1,3 @@
### TODO
# Hardcode GAMEINDEX_DIR, if default is fine for everybody
### Select the build type
# Use Release/Devel/Debug : -DCMAKE_BUILD_TYPE=Release|Devel|Debug
# Enable/disable the stripping : -DCMAKE_BUILD_STRIP=TRUE|FALSE
@ -10,11 +7,6 @@
# control C flags : -DUSER_CMAKE_C_FLAGS="cflags"
# control C++ flags : -DUSER_CMAKE_CXX_FLAGS="cxxflags"
# control link flags : -DUSER_CMAKE_LD_FLAGS="ldflags"
### Packaging options
# Plugin installation path : -DPLUGIN_DIR="/usr/lib/pcsx2"
# GL Shader installation path : -DGLSL_SHADER_DIR="/usr/share/games/pcsx2"
# Game DB installation path : -DGAMEINDEX_DIR="/usr/share/games/pcsx2"
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
@ -51,28 +43,12 @@ option(SDL2_API "Use SDL2 on SPU2 and PAD Linux (wxWidget mustn't be built with
option(GTK2_API "Use GTK2 api (legacy)")
if(PACKAGE_MODE)
if(NOT DEFINED PLUGIN_DIR)
set(PLUGIN_DIR "${CMAKE_INSTALL_PREFIX}/lib/games/PCSX2")
endif()
if(NOT DEFINED GAMEINDEX_DIR)
set(GAMEINDEX_DIR "${CMAKE_INSTALL_PREFIX}/share/games/PCSX2")
endif()
if(NOT DEFINED BIN_DIR)
set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
endif()
if(NOT DEFINED DOC_DIR)
set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/PCSX2")
endif()
if(NOT DEFINED MAN_DIR)
set(MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
endif()
# Compile all source codes with those defines
add_definitions(-DPLUGIN_DIR_COMPILATION=${PLUGIN_DIR} -DGAMEINDEX_DIR_COMPILATION=${GAMEINDEX_DIR} -DDOC_DIR_COMPILATION=${DOC_DIR})
add_definitions(
-DPLUGIN_DIR_COMPILATION=${CMAKE_INSTALL_FULL_LIBDIR}/PCSX2
-DGAMEINDEX_DIR_COMPILATION=${CMAKE_INSTALL_FULL_DATADIR}/PCSX2
-DDOC_DIR_COMPILATION=${CMAKE_INSTALL_FULL_DOCDIR}
)
endif()
if(APPLE)

View File

@ -125,7 +125,7 @@ macro(add_pcsx2_plugin lib srcs libs flags)
target_link_libraries(${lib} "${USER_CMAKE_LD_FLAGS}")
endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
if(PACKAGE_MODE)
install(TARGETS ${lib} DESTINATION ${PLUGIN_DIR})
install(TARGETS ${lib} DESTINATION ${CMAKE_INSTALL_LIBDIR}/PCSX2)
else(PACKAGE_MODE)
install(TARGETS ${lib} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
endif(PACKAGE_MODE)
@ -156,7 +156,7 @@ macro(add_pcsx2_executable exe srcs libs flags)
target_link_libraries(${exe} "${USER_CMAKE_LD_FLAGS}")
endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
if(PACKAGE_MODE)
install(TARGETS ${exe} DESTINATION ${BIN_DIR})
install(TARGETS ${exe} DESTINATION ${CMAKE_INSTALL_BINDIR})
else(PACKAGE_MODE)
install(TARGETS ${exe} DESTINATION ${CMAKE_SOURCE_DIR}/bin)
endif(PACKAGE_MODE)

View File

@ -69,7 +69,7 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS_PCSX2 _potFile _firstPoFileArg)
ENDIF (CMAKE_BUILD_PO)
IF (PACKAGE_MODE)
INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
INSTALL(FILES ${_gmoFile} DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo)
ELSE (PACKAGE_MODE)
INSTALL(FILES ${_gmoFile} DESTINATION ${CMAKE_SOURCE_DIR}/bin/Langs/${_lang} RENAME ${_potBasename}.mo)
ENDIF (PACKAGE_MODE)

View File

@ -1138,7 +1138,7 @@ endif()
if(NOT DISABLE_SETCAP)
if(PACKAGE_MODE)
install(CODE "execute_process(COMMAND /bin/bash -c \"echo 'Enabling networking capability on Linux...';set -x; [ -f ${BIN_DIR}/${Output} ] && sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ${BIN_DIR}/${Output}; set +x\")")
install(CODE "execute_process(COMMAND /bin/bash -c \"echo 'Enabling networking capability on Linux...';set -x; [ -f ${CMAKE_INSTALL_FULL_BINDIR}/${Output} ] && sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ${CMAKE_INSTALL_FULL_BINDIR}/${Output}; set +x\")")
else()
install(CODE "execute_process(COMMAND /bin/bash -c \"echo 'Enabling networking capability on Linux...';set -x; [ -f ${CMAKE_SOURCE_DIR}/bin/${Output} ] && sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' ${CMAKE_SOURCE_DIR}/bin/${Output}; set +x\")")
endif()