diff --git a/CMakeLists.txt b/CMakeLists.txt index 09a9928c..af6075c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ include(CheckIncludeFile) include(CheckSymbolExists) include(CMakePushCheckState) include(GenerateExportHeader) +include(GNUInstallDirs) cmake_push_check_state(RESET) @@ -78,7 +79,7 @@ if(HAVE_MATH_LIBM) set_target_properties(math PROPERTIES INTERFACE_LINK_LIBRARIES m) endif() -set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_LIBDIR}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) option(BUILD_SHARED_LIBS "Prefer to build shared lib" ON) diff --git a/thanm.old/CMakeLists.txt b/thanm.old/CMakeLists.txt index 067b98fb..37f95737 100644 --- a/thanm.old/CMakeLists.txt +++ b/thanm.old/CMakeLists.txt @@ -3,5 +3,5 @@ add_executable(thanm.old thanm.h image.h ) target_link_libraries(thanm.old PRIVATE util $<$:PNG::PNG> setargv thtk_warning) -install(TARGETS thanm.old DESTINATION bin) -install(FILES thanm.old.1 DESTINATION share/man/man1) +install(TARGETS thanm.old DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES thanm.old.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/thanm/CMakeLists.txt b/thanm/CMakeLists.txt index 41b0c660..08d08d97 100644 --- a/thanm/CMakeLists.txt +++ b/thanm/CMakeLists.txt @@ -10,5 +10,5 @@ add_executable(thanm ) target_include_directories(thanm PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) target_link_libraries(thanm PRIVATE util $<$:PNG::PNG> math setargv thtk_warning) -install(TARGETS thanm DESTINATION bin) -install(FILES thanm.1 DESTINATION share/man/man1) +install(TARGETS thanm DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES thanm.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/thdat/CMakeLists.txt b/thdat/CMakeLists.txt index 9bb7f7d7..48d55e95 100644 --- a/thdat/CMakeLists.txt +++ b/thdat/CMakeLists.txt @@ -1,5 +1,5 @@ include_directories(${CMAKE_SOURCE_DIR}) add_executable(thdat thdat.c) target_link_libraries(thdat PRIVATE thtk util setargv thtk_warning $<$:OpenMP::OpenMP_C>) -install(TARGETS thdat DESTINATION bin) -install(FILES thdat.1 DESTINATION share/man/man1) +install(TARGETS thdat DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES thdat.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/thecl/CMakeLists.txt b/thecl/CMakeLists.txt index 12945530..b9ef841c 100644 --- a/thecl/CMakeLists.txt +++ b/thecl/CMakeLists.txt @@ -9,5 +9,5 @@ add_executable(thecl expr.c thecl.c eclmap.c thecl06.c thecl10.c expr.h thecl.h eclmap.h) target_link_libraries(thecl PRIVATE util math setargv thtk_warning) -install(TARGETS thecl DESTINATION bin) -install(FILES thecl.1 DESTINATION share/man/man1) +install(TARGETS thecl DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES thecl.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/thmsg/CMakeLists.txt b/thmsg/CMakeLists.txt index 41f5cb4e..f58a874c 100644 --- a/thmsg/CMakeLists.txt +++ b/thmsg/CMakeLists.txt @@ -3,5 +3,5 @@ add_executable(thmsg thmsg.h ) target_link_libraries(thmsg PRIVATE util setargv thtk_warning) -install(TARGETS thmsg DESTINATION bin) -install(FILES thmsg.1 DESTINATION share/man/man1) +install(TARGETS thmsg DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES thmsg.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/thstd/CMakeLists.txt b/thstd/CMakeLists.txt index 131dd506..48b0a0f9 100644 --- a/thstd/CMakeLists.txt +++ b/thstd/CMakeLists.txt @@ -3,5 +3,5 @@ add_executable(thstd thstd.h ) target_link_libraries(thstd PRIVATE util setargv thtk_warning) -install(TARGETS thstd DESTINATION bin) -install(FILES thstd.1 DESTINATION share/man/man1) +install(TARGETS thstd DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES thstd.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/thtk/CMakeLists.txt b/thtk/CMakeLists.txt index 56df0317..99cade41 100644 --- a/thtk/CMakeLists.txt +++ b/thtk/CMakeLists.txt @@ -29,10 +29,10 @@ find_package(PkgConfig) if (PKG_CONFIG_FOUND) configure_file(thtk.pc.in ${CMAKE_CURRENT_BINARY_DIR}/thtk.pc) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/thtk.pc - DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() install(TARGETS thtk - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - PUBLIC_HEADER DESTINATION include/thtk) + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/thtk) diff --git a/thtk/thtk.pc.in b/thtk/thtk.pc.in index 9b05e9d1..e01742ed 100644 --- a/thtk/thtk.pc.in +++ b/thtk/thtk.pc.in @@ -1,10 +1,11 @@ prefix = @CMAKE_INSTALL_PREFIX@ -exec_prefix = @CMAKE_INSTALL_PREFIX@ -libdir = @CMAKE_INSTALL_PREFIX@/lib -includedir = @CMAKE_INSTALL_PREFIX@/include/thtk +exec_prefix = {prefix} +includedir = {prefix}/@CMAKE_INSTALL_INCLUDEDIR@ +libdir = {exec_prefix}/@CMAKE_INSTALL_LIBDIR@ Name: @PROJECT_NAME@ Description: Touhou Toolkit shared library URL: @PROJECT_URL@ Version: @PROJECT_VERSION@ -Libs: -L@CMAKE_INSTALL_PREFIX@/lib -lthtk +Libs: -L{libdir} -lthtk +Cflags: -I{includedir}