@@ -1645,5 +1645,58 @@ integer function name_ID(cmd,name)
1645
1645
1646
1646
end function name_ID
1647
1647
1648
+ ! Populate build settings from the current CLI/environment
1649
+ ! (after set_args has been called).
1650
+ subroutine build_settings (self , list , show_model , build_tests , config_file )
1651
+ class(fpm_build_settings), intent (inout ) :: self
1652
+ logical , intent (in ), optional :: list, show_model, build_tests
1653
+ character (len=* ), intent (in ), optional :: config_file
1654
+
1655
+ character (len= :), allocatable :: comp, ccomp, cxcomp, arch
1656
+ character (len= :), allocatable :: fflags, cflags, cxxflags, ldflags
1657
+ character (len= :), allocatable :: prof, cfg
1658
+
1659
+ ! Read CLI/env values (sget returns what set_args registered, including defaults)
1660
+ comp = sget(' compiler' ); if (comp == ' ' ) comp = ' gfortran'
1661
+ fflags = ' ' // sget(' flag' )
1662
+ cflags = ' ' // sget(' c-flag' )
1663
+ cxxflags = ' ' // sget(' cxx-flag' )
1664
+ ldflags = ' ' // sget(' link-flag' )
1665
+ prof = sget(' profile' )
1666
+
1667
+ ccomp = sget(' c-compiler' )
1668
+ cxcomp = sget(' cxx-compiler' )
1669
+ arch = sget(' archiver' )
1670
+
1671
+ if (present (config_file)) then
1672
+ if (len_trim (config_file) > 0 ) then
1673
+ cfg = config_file
1674
+ else
1675
+ cfg = sget(' config-file' )
1676
+ end if
1677
+ else
1678
+ cfg = sget(' config-file' )
1679
+ end if
1680
+
1681
+ ! Assign into this (polymorphic) object; allocatable chars auto-allocate
1682
+ self% profile = prof
1683
+ self% prune = .not. lget(' no-prune' )
1684
+ self% compiler = comp
1685
+ self% c_compiler = ccomp
1686
+ self% cxx_compiler = cxcomp
1687
+ self% archiver = arch
1688
+ self% path_to_config= cfg
1689
+ self% flag = fflags
1690
+ self% cflag = cflags
1691
+ self% cxxflag = cxxflags
1692
+ self% ldflag = ldflags
1693
+ self% verbose = lget(' verbose' )
1694
+
1695
+ ! Optional overrides from caller
1696
+ if (present (list)) self% list = list
1697
+ if (present (show_model)) self% show_model = show_model
1698
+ if (present (build_tests)) self% build_tests = build_tests
1699
+ end subroutine build_settings
1700
+
1648
1701
1649
1702
end module fpm_command_line
0 commit comments