Skip to content

Commit

Permalink
cmake: use GNUInstallDirs
Browse files Browse the repository at this point in the history
  • Loading branch information
DankRank committed Oct 19, 2024
1 parent 69901f0 commit 864b51a
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 22 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ include(CheckIncludeFile)
include(CheckSymbolExists)
include(CMakePushCheckState)
include(GenerateExportHeader)
include(GNUInstallDirs)

cmake_push_check_state(RESET)

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions thanm.old/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ add_executable(thanm.old
thanm.h image.h
)
target_link_libraries(thanm.old PRIVATE util $<$<BOOL:${PNG_FOUND}>: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)
4 changes: 2 additions & 2 deletions thanm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 $<$<BOOL:${PNG_FOUND}>: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)
4 changes: 2 additions & 2 deletions thdat/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include_directories(${CMAKE_SOURCE_DIR})
add_executable(thdat thdat.c)
target_link_libraries(thdat PRIVATE thtk util setargv thtk_warning $<$<BOOL:${OPENMP_FOUND}>: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)
4 changes: 2 additions & 2 deletions thecl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions thmsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions thstd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions thtk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 5 additions & 4 deletions thtk/thtk.pc.in
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 864b51a

Please sign in to comment.