Skip to content

Commit f1f5dff

Browse files
SibiSiddharthangitster
authored andcommitted
cmake: installation support for git
Install the built binaries and scripts using CMake This is very similar to `make install`. By default the destination directory(DESTDIR) is /usr/local/ on Linux To set a custom installation path do this: cmake `relative-path-to-srcdir` -DCMAKE_INSTALL_PREFIX=`preferred-install-path` Then run `make install` Signed-off-by: Sibi Siddharthan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent afa45fe commit f1f5dff

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

contrib/buildsystems/CMakeLists.txt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ project(git
6565
VERSION ${git_version}
6666
LANGUAGES C)
6767

68+
#TODO gitk git-gui gitweb
69+
#TODO Add pcre support
6870

6971
#macros for parsing the Makefile for sources and scripts
7072
macro(parse_makefile_for_sources list_var regex)
@@ -699,3 +701,50 @@ if(MSGFMT_EXE)
699701
endforeach()
700702
add_custom_target(po-gen ALL DEPENDS ${po_gen})
701703
endif()
704+
705+
706+
#to help with the install
707+
list(TRANSFORM git_shell_scripts PREPEND "${CMAKE_BINARY_DIR}/")
708+
list(TRANSFORM git_perl_scripts PREPEND "${CMAKE_BINARY_DIR}/")
709+
710+
#install
711+
install(TARGETS git git-shell
712+
RUNTIME DESTINATION bin)
713+
install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
714+
DESTINATION bin)
715+
716+
list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
717+
install(TARGETS ${PROGRAMS_BUILT}
718+
RUNTIME DESTINATION libexec/git-core)
719+
720+
set(bin_links
721+
git-receive-pack git-upload-archive git-upload-pack)
722+
723+
foreach(b ${bin_links})
724+
install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/bin/${b})")
725+
endforeach()
726+
727+
install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git)")
728+
install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git-shell ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-shell)")
729+
730+
foreach(b ${git_links})
731+
string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
732+
install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/bin/git ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
733+
endforeach()
734+
735+
foreach(b ${git_http_links})
736+
string(REPLACE "${CMAKE_BINARY_DIR}" "" b ${b})
737+
install(CODE "file(CREATE_LINK ${CMAKE_INSTALL_PREFIX}/libexec/git-core/git-remote-http ${CMAKE_INSTALL_PREFIX}/libexec/git-core/${b})")
738+
endforeach()
739+
740+
install(PROGRAMS ${git_shell_scripts} ${git_perl_scripts} ${CMAKE_BINARY_DIR}/git-p4
741+
DESTINATION libexec/git-core)
742+
743+
install(DIRECTORY ${CMAKE_SOURCE_DIR}/mergetools DESTINATION libexec/git-core)
744+
install(DIRECTORY ${CMAKE_BINARY_DIR}/perl/build/lib/ DESTINATION share/perl5
745+
FILES_MATCHING PATTERN "*.pm")
746+
install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION share/git-core/templates)
747+
748+
if(MSGFMT_EXE)
749+
install(DIRECTORY ${CMAKE_BINARY_DIR}/po/build/locale DESTINATION share)
750+
endif()

0 commit comments

Comments
 (0)