99
#TODO Enable NLS on windows natively
100
101
#macros for parsing the Makefile for sources and scripts
102
-macro(parse_makefile_for_sources list_var regex)
103
- file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
102
+macro(parse_makefile_for_sources list_var makefile regex)
103
+ file(STRINGS ${makefile} ${list_var} REGEX "^${regex} \\+=(.*)")
104
string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
105
string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
106
string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
662
663
#build
664
#libgit
665
-parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
665
+parse_makefile_for_sources(libgit_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "LIB_OBJS")
666
667
list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
668
list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
680
add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
681
682
#libxdiff
683
-parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
683
+parse_makefile_for_sources(libxdiff_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "XDIFF_OBJS")
684
685
list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
686
add_library(xdiff STATIC ${libxdiff_SOURCES})
687
688
#reftable
689
-parse_makefile_for_sources(reftable_SOURCES "REFTABLE_OBJS")
689
+parse_makefile_for_sources(reftable_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "REFTABLE_OBJS")
690
691
list(TRANSFORM reftable_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
692
add_library(reftable STATIC ${reftable_SOURCES})
757
endif()
758
759
#git
760
-parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
760
+parse_makefile_for_sources(git_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "BUILTIN_OBJS")
761
762
list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
763
add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
912
VERBATIM)
913
add_custom_target(python-gen ALL DEPENDS "${CMAKE_BINARY_DIR}/git-p4")
914
915
-#templates
916
-file(GLOB templates "${CMAKE_SOURCE_DIR}/templates/*")
917
-list(TRANSFORM templates REPLACE "${CMAKE_SOURCE_DIR}/templates/" "")
918
-list(REMOVE_ITEM templates ".gitignore")
919
-list(REMOVE_ITEM templates "Makefile")
920
-list(REMOVE_ITEM templates "blt")# Prevents an error when reconfiguring for in source builds
921
-
922
-list(REMOVE_ITEM templates "branches--")
923
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/branches) #create branches
924
-
915
+#${CMAKE_SOURCE_DIR}/Makefile templates
916
+parse_makefile_for_sources(templates ${CMAKE_SOURCE_DIR}/templates/Makefile "TEMPLATES")
917
+string(REPLACE " " ";" templates ${templates})
918
#templates have @.*@ replacement so use configure_file instead
919
foreach(tm ${templates})
927
- string(REPLACE "--" "/" blt_tm ${tm})
928
- string(REPLACE "this" "" blt_tm ${blt_tm})# for this--
929
- configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${blt_tm} @ONLY)
920
+ configure_file(${CMAKE_SOURCE_DIR}/templates/${tm} ${CMAKE_BINARY_DIR}/templates/blt/${tm} @ONLY)
921
endforeach()
922
932
-
923
#translations
924
if(MSGFMT_EXE)
925
file(GLOB po_files "${CMAKE_SOURCE_DIR}/po/*.po")
993
target_link_libraries(test-fake-ssh common-main)
994
995
#unit-tests
1006
-parse_makefile_for_sources(unit-test_SOURCES "UNIT_TEST_OBJS")
996
+parse_makefile_for_sources(unit-test_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "UNIT_TEST_OBJS")
997
list(TRANSFORM unit-test_SOURCES REPLACE "\\$\\(UNIT_TEST_DIR\\)/" "${CMAKE_SOURCE_DIR}/t/unit-tests/")
998
add_library(unit-test-lib STATIC ${unit-test_SOURCES})
999
1059
endif()
1060
1061
#test-tool
1072
-parse_makefile_for_sources(test-tool_SOURCES "TEST_BUILTINS_OBJS")
1062
+parse_makefile_for_sources(test-tool_SOURCES ${CMAKE_SOURCE_DIR}/Makefile "TEST_BUILTINS_OBJS")
1063
add_library(test-lib OBJECT ${CMAKE_SOURCE_DIR}/t/unit-tests/test-lib.c)
1064
1065
list(TRANSFORM test-tool_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/t/helper/")