@@ -222,23 +222,31 @@ sub patch_file {
222222}
223223
224224sub make_sources_cmake {
225- my @list = @_ ;
225+ my ($src_ref , $hdr_ref ) = @_ ;
226+ my @sources = @{ $src_ref };
227+ my @headers = @{ $hdr_ref };
226228 my $output = " # SPDX-License-Identifier: Unlicense
227229# Autogenerated File! Do not edit.
228230
229231set(SOURCES\n " ;
230- foreach my $obj (sort @list ) {
231- $output .= $obj . " \n " ;
232+ foreach my $sobj (sort @sources ) {
233+ $output .= $sobj . " \n " ;
234+ }
235+ $output .= " )\n\n set(HEADERS\n " ;
236+ foreach my $hobj (sort @headers ) {
237+ $output .= $hobj . " \n " ;
232238 }
233- $output .= " )\n\n set(HEADERS \n tommath.h \n ) \n " ;
239+ $output .= " )\n " ;
234240 return $output ;
235241}
236242
237243sub process_makefiles {
238244 my $write = shift ;
239245 my $changed_count = 0;
240- my @o = map { my $x = $_ ; $x =~ s /\. c$/ .o/ ; $x } bsd_glob(" *.c" );
241- my @all = bsd_glob(" *.{c,h}" );
246+ my @headers = bsd_glob(" *.h" );
247+ my @sources = bsd_glob(" *.c" );
248+ my @o = map { my $x = $_ ; $x =~ s /\. c$/ .o/ ; $x } @sources ;
249+ my @all = sort (@sources , @headers );
242250
243251 my $var_o = prepare_variable(" OBJECTS" , @o );
244252 (my $var_obj = $var_o ) =~ s /\. o\b / .obj/ sg ;
@@ -260,7 +268,7 @@ sub process_makefiles {
260268 for my $m (qw/ makefile makefile.shared makefile_include.mk makefile.msvc makefile.unix makefile.mingw sources.cmake / ) {
261269 my $old = read_file($m );
262270 my $new = $m eq ' makefile.msvc' ? patch_file($old , $var_obj )
263- : $m eq ' sources.cmake' ? make_sources_cmake(bsd_glob( " *.c " ) )
271+ : $m eq ' sources.cmake' ? make_sources_cmake(\ @sources , \ @headers )
264272 : patch_file($old , $var_o );
265273
266274 if ($old ne $new ) {
0 commit comments