Skip to content

Commit

Permalink
fix(cmake): use full paths defined by GNUInstallDirs
Browse files Browse the repository at this point in the history
Closes #424
  • Loading branch information
lotem committed Jan 11, 2021
1 parent 440a97c commit bb8c263
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,15 @@ if(UNIX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
endif()

# keep these variables lest some Rime plugin's cmake file is still using them {
if(NOT DEFINED LIB_INSTALL_DIR)
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
endif()

if(NOT DEFINED BIN_INSTALL_DIR)
set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR})
endif()
# }

# uninstall target
configure_file(
Expand All @@ -173,22 +175,24 @@ add_custom_target(uninstall
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD|DragonFly|GNU")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(bindir "${exec_prefix}/${BIN_INSTALL_DIR}")
set(libdir "${exec_prefix}/${LIB_INSTALL_DIR}")
set(pkgdatadir "${prefix}${rime_data_dir}")
set(includedir "${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(bindir "${CMAKE_INSTALL_FULL_BINDIR}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(pkgdatadir "${CMAKE_INSTALL_PREFIX}${rime_data_dir}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
configure_file(
${PROJECT_SOURCE_DIR}/rime.pc.in
${PROJECT_BINARY_DIR}/rime.pc
@ONLY)
install(FILES ${PROJECT_BINARY_DIR}/rime.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig)
endif()

install(FILES cmake/RimeConfig.cmake DESTINATION share/cmake/rime)
install(FILES cmake/RimeConfig.cmake
DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/cmake/rime)

file(GLOB rime_public_header_files ${PROJECT_SOURCE_DIR}/src/*.h)
install(FILES ${rime_public_header_files} DESTINATION include)
install(FILES ${rime_public_header_files}
DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR})

if(BUILD_DATA)
file(GLOB rime_preset_data_files ${PROJECT_SOURCE_DIR}/data/preset/*.yaml)
Expand Down
2 changes: 1 addition & 1 deletion plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ foreach(plugin ${plugins})
if(XCODE_VERSION)
set_target_properties(${plugin_name} PROPERTIES INSTALL_NAME_DIR "@rpath")
endif(XCODE_VERSION)
install(TARGETS ${plugin_name} DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS ${plugin_name} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
endif()
endforeach(plugin)

Expand Down
2 changes: 1 addition & 1 deletion sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if(BUILD_SAMPLE)
PROPERTIES
INSTALL_NAME_DIR "@rpath")
endif(XCODE_VERSION)
install(TARGETS ${sample_library} DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS ${sample_library} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

add_subdirectory(tools)
if(BUILD_TEST)
Expand Down
12 changes: 6 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if(BUILD_SHARED_LIBS)
if(XCODE_VERSION)
set_target_properties(rime PROPERTIES INSTALL_NAME_DIR "@rpath")
endif()
install(TARGETS rime DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS rime DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

if(BUILD_SEPARATE_LIBS)
add_library(rime-dict ${rime_dict_module_src})
Expand All @@ -91,7 +91,7 @@ if(BUILD_SHARED_LIBS)
if(XCODE_VERSION)
set_target_properties(rime-dict PROPERTIES INSTALL_NAME_DIR "@rpath")
endif()
install(TARGETS rime-dict DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS rime-dict DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

add_library(rime-gears ${rime_gears_src})
target_link_libraries(rime-gears
Expand All @@ -104,7 +104,7 @@ if(BUILD_SHARED_LIBS)
if(XCODE_VERSION)
set_target_properties(rime-gears PROPERTIES INSTALL_NAME_DIR "@rpath")
endif()
install(TARGETS rime-gears DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS rime-gears DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

add_library(rime-levers ${rime_levers_src})
target_link_libraries(rime-levers
Expand All @@ -117,7 +117,7 @@ if(BUILD_SHARED_LIBS)
if(XCODE_VERSION)
set_target_properties(rime-levers PROPERTIES INSTALL_NAME_DIR "@rpath")
endif()
install(TARGETS rime-levers DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS rime-levers DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})

if(rime_plugins_library)
add_library(rime-plugins
Expand All @@ -134,12 +134,12 @@ if(BUILD_SHARED_LIBS)
if(XCODE_VERSION)
set_target_properties(rime-plugins PROPERTIES INSTALL_NAME_DIR "@rpath")
endif()
install(TARGETS rime-plugins DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS rime-plugins DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
endif()
endif()
else()
add_library(rime-static STATIC ${rime_src})
target_link_libraries(rime-static ${rime_deps})
set_target_properties(rime-static PROPERTIES OUTPUT_NAME "rime" PREFIX "lib")
install(TARGETS rime-static DESTINATION ${LIB_INSTALL_DIR})
install(TARGETS rime-static DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
endif()

0 comments on commit bb8c263

Please sign in to comment.