Skip to content

Commit

Permalink
chore(CMakeLists.txt): Use GNUinstalldirs module (#327)
Browse files Browse the repository at this point in the history
GNUInstallDirs module is available since CMake 3.0.2. It provides
standard install directory variables as defined for GNU software.
Using this module would provides standard variable names for
bindir, libdir, includedir and datadir, etc., which would be
beneficial.

This patch modifies the top-level CMakeLists.txt and apply the
standard variables accordingly. The minimal CMake version requirement
is also bumped to 3.0.2.
  • Loading branch information
hosiet authored and lotem committed Dec 12, 2019
1 parent b93fbee commit 3cf8eaf
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/c_flag_over
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxx_flag_overrides.cmake)

project(rime)
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.0.2)

set(rime_version 1.5.3)
set(rime_soversion 1)

add_definitions(-DRIME_VERSION="${rime_version}")

include(GNUInstallDirs)

option(BUILD_SHARED_LIBS "Build Rime as shared library" ON)
option(BUILD_MERGED_PLUGINS "Merge plugins into one Rime library" ON)
option(BUILD_STATIC "Build with dependencies as static libraries" OFF)
Expand Down Expand Up @@ -161,11 +163,11 @@ if(UNIX)
endif()

if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
endif()

if(NOT DEFINED BIN_INSTALL_DIR)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
endif()

# uninstall target
Expand All @@ -179,10 +181,10 @@ add_custom_target(uninstall
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|DragonFly")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(bindir "${exec_prefix}/bin")
set(bindir "${BIN_INSTALL_DIR}")
set(libdir "${LIB_INSTALL_DIR}")
set(pkgdatadir "${prefix}${rime_data_dir}")
set(includedir "${CMAKE_INSTALL_PREFIX}/include")
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
configure_file(
${PROJECT_SOURCE_DIR}/rime.pc.in
${PROJECT_BINARY_DIR}/rime.pc
Expand Down

0 comments on commit 3cf8eaf

Please sign in to comment.