summaryrefslogtreecommitdiffstats
BranchCommit messageAuthorAge
2.7[2.7] bpo-31675: Fix memory leaks in Tkinter's methods splitlist() and split(...Serhiy Storchaka7 years
3.3post 3.3.7, should there be anyNed Deily7 years
3.4Remove retired and security branches from active docs (#3883)Ned Deily7 years
3.5Remove retired and security branches from active docs (#3882)Ned Deily7 years
3.6[3.6] bpo-31178: Mock os.waitpid() in test_subprocess (GH-3896) (#3897)Miss Islington (bot)7 years
benjamin-clangcloses bpo-31696: don't mention GCC in sys.version when building with clangBenjamin Peterson7 years
benjamin-iteration-torturebpo-31530: stop crashes when iterating over a file on multiple threadsBenjamin Peterson7 years
buildbot-custombpo-5885: add Misc/NEWS entryIgor Galić7 years
masterbpo-38614: Use support timeout constants (GH-17572)Victor Stinner5 years
 
TagDownloadAuthorAge
v3.14.0a5cpython-3.14.0a5.zip  cpython-3.14.0a5.tar.gz  cpython-3.14.0a5.tar.bz2  Hugo van Kemenade3 weeks
v3.13.2cpython-3.13.2.zip  cpython-3.13.2.tar.gz  cpython-3.13.2.tar.bz2  Thomas Wouters4 weeks
v3.12.9cpython-3.12.9.zip  cpython-3.12.9.tar.gz  cpython-3.12.9.tar.bz2  Thomas Wouters4 weeks
v3.14.0a4cpython-3.14.0a4.zip  cpython-3.14.0a4.tar.gz  cpython-3.14.0a4.tar.bz2  Hugo van Kemenade7 weeks
v3.14.0a3cpython-3.14.0a3.zip  cpython-3.14.0a3.tar.gz  cpython-3.14.0a3.tar.bz2  Hugo van Kemenade3 months
v3.12.8cpython-3.12.8.zip  cpython-3.12.8.tar.gz  cpython-3.12.8.tar.bz2  Thomas Wouters3 months
v3.13.1cpython-3.13.1.zip  cpython-3.13.1.tar.gz  cpython-3.13.1.tar.bz2  Thomas Wouters3 months
v3.9.21cpython-3.9.21.zip  cpython-3.9.21.tar.gz  cpython-3.9.21.tar.bz2  Łukasz Langa3 months
v3.10.16cpython-3.10.16.zip  cpython-3.10.16.tar.gz  cpython-3.10.16.tar.bz2  Pablo Galindo3 months
v3.11.11cpython-3.11.11.zip  cpython-3.11.11.tar.gz  cpython-3.11.11.tar.bz2  Pablo Galindo3 months
v3.14.0a2cpython-3.14.0a2.zip  cpython-3.14.0a2.tar.gz  cpython-3.14.0a2.tar.bz2  Hugo van Kemenade3 months
v3.14.0a1cpython-3.14.0a1.zip  cpython-3.14.0a1.tar.gz  cpython-3.14.0a1.tar.bz2  Hugo van Kemenade5 months
3.8cpython-3.8.zip  cpython-3.8.tar.gz  cpython-3.8.tar.bz2  Łukasz Langa5 months
v3.13.0cpython-3.13.0.zip  cpython-3.13.0.tar.gz  cpython-3.13.0.tar.bz2  Thomas Wouters5 months
v3.12.7cpython-3.12.7.zip  cpython-3.12.7.tar.gz  cpython-3.12.7.tar.bz2  Thomas Wouters5 months
v3.13.0rc3cpython-3.13.0rc3.zip  cpython-3.13.0rc3.tar.gz  cpython-3.13.0rc3.tar.bz2  Thomas Wouters5 months
v3.11.10cpython-3.11.10.zip  cpython-3.11.10.tar.gz  cpython-3.11.10.tar.bz2  Pablo Galindo6 months
v3.10.15cpython-3.10.15.zip  cpython-3.10.15.tar.gz  cpython-3.10.15.tar.bz2  Pablo Galindo6 months
v3.13.0rc2cpython-3.13.0rc2.zip  cpython-3.13.0rc2.tar.gz  cpython-3.13.0rc2.tar.bz2  Thomas Wouters6 months
v3.8.20cpython-3.8.20.zip  cpython-3.8.20.tar.gz  cpython-3.8.20.tar.bz2  Łukasz Langa6 months
v3.9.20cpython-3.9.20.zip  cpython-3.9.20.tar.gz  cpython-3.9.20.tar.bz2  Łukasz Langa6 months
v3.12.6cpython-3.12.6.zip  cpython-3.12.6.tar.gz  cpython-3.12.6.tar.bz2  Thomas Wouters6 months
v3.12.5cpython-3.12.5.zip  cpython-3.12.5.tar.gz  cpython-3.12.5.tar.bz2  Thomas Wouters7 months
v3.13.0rc1cpython-3.13.0rc1.zip  cpython-3.13.0rc1.tar.gz  cpython-3.13.0rc1.tar.bz2  Thomas Wouters7 months
v3.13.0b4cpython-3.13.0b4.zip  cpython-3.13.0b4.tar.gz  cpython-3.13.0b4.tar.bz2  Thomas Wouters8 months
v3.13.0b3cpython-3.13.0b3.zip  cpython-3.13.0b3.tar.gz  cpython-3.13.0b3.tar.bz2  Thomas Wouters8 months
v3.12.4cpython-3.12.4.zip  cpython-3.12.4.tar.gz  cpython-3.12.4.tar.bz2  Thomas Wouters9 months
v3.13.0b2cpython-3.13.0b2.zip  cpython-3.13.0b2.tar.gz  cpython-3.13.0b2.tar.bz2  Thomas Wouters9 months
v3.13.0b1cpython-3.13.0b1.zip  cpython-3.13.0b1.tar.gz  cpython-3.13.0b1.tar.bz2  Thomas Wouters10 months
v3.13.0a6cpython-3.13.0a6.zip  cpython-3.13.0a6.tar.gz  cpython-3.13.0a6.tar.bz2  Thomas Wouters11 months
v3.12.3cpython-3.12.3.zip  cpython-3.12.3.tar.gz  cpython-3.12.3.tar.bz2  Thomas Wouters11 months
v3.11.9cpython-3.11.9.zip  cpython-3.11.9.tar.gz  cpython-3.11.9.tar.bz2  Pablo Galindo11 months
v3.10.14cpython-3.10.14.zip  cpython-3.10.14.tar.gz  cpython-3.10.14.tar.bz2  Łukasz Langa11 months
v3.9.19cpython-3.9.19.zip  cpython-3.9.19.tar.gz  cpython-3.9.19.tar.bz2  Łukasz Langa11 months
v3.8.19cpython-3.8.19.zip  cpython-3.8.19.tar.gz  cpython-3.8.19.tar.bz2  Łukasz Langa11 months
v3.13.0a5cpython-3.13.0a5.zip  cpython-3.13.0a5.tar.gz  cpython-3.13.0a5.tar.bz2  Thomas Wouters12 months
v3.13.0a4cpython-3.13.0a4.zip  cpython-3.13.0a4.tar.gz  cpython-3.13.0a4.tar.bz2  Thomas Wouters13 months
v3.11.8cpython-3.11.8.zip  cpython-3.11.8.tar.gz  cpython-3.11.8.tar.bz2  Pablo Galindo13 months
v3.12.2cpython-3.12.2.zip  cpython-3.12.2.tar.gz  cpython-3.12.2.tar.bz2  Thomas Wouters13 months
v3.13.0a3cpython-3.13.0a3.zip  cpython-3.13.0a3.tar.gz  cpython-3.13.0a3.tar.bz2  Thomas Wouters14 months
v3.12.1cpython-3.12.1.zip  cpython-3.12.1.tar.gz  cpython-3.12.1.tar.bz2  Thomas Wouters15 months
v3.11.7cpython-3.11.7.zip  cpython-3.11.7.tar.gz  cpython-3.11.7.tar.bz2  Pablo Galindo15 months
v3.13.0a2cpython-3.13.0a2.zip  cpython-3.13.0a2.tar.gz  cpython-3.13.0a2.tar.bz2  Thomas Wouters15 months
v3.13.0a1cpython-3.13.0a1.zip  cpython-3.13.0a1.tar.gz  cpython-3.13.0a1.tar.bz2  Thomas Wouters17 months
v3.11.6cpython-3.11.6.zip  cpython-3.11.6.tar.gz  cpython-3.11.6.tar.bz2  Pablo Galindo17 months
v3.12.0cpython-3.12.0.zip  cpython-3.12.0.tar.gz  cpython-3.12.0.tar.bz2  Thomas Wouters17 months
v3.12.0rc3cpython-3.12.0rc3.zip  cpython-3.12.0rc3.tar.gz  cpython-3.12.0rc3.tar.bz2  Thomas Wouters18 months
v3.12.0rc2cpython-3.12.0rc2.zip  cpython-3.12.0rc2.tar.gz  cpython-3.12.0rc2.tar.bz2  Thomas Wouters18 months
v3.8.18cpython-3.8.18.zip  cpython-3.8.18.tar.gz  cpython-3.8.18.tar.bz2  Łukasz Langa18 months
v3.9.18cpython-3.9.18.zip  cpython-3.9.18.tar.gz  cpython-3.9.18.tar.bz2  Łukasz Langa18 months
v3.10.13cpython-3.10.13.zip  cpython-3.10.13.tar.gz  cpython-3.10.13.tar.bz2  Pablo Galindo18 months
v3.11.5cpython-3.11.5.zip  cpython-3.11.5.tar.gz  cpython-3.11.5.tar.bz2  Pablo Galindo18 months
v3.12.0rc1cpython-3.12.0rc1.zip  cpython-3.12.0rc1.tar.gz  cpython-3.12.0rc1.tar.bz2  Thomas Wouters19 months
v3.12.0b4cpython-3.12.0b4.zip  cpython-3.12.0b4.tar.gz  cpython-3.12.0b4.tar.bz2  Thomas Wouters20 months
v3.12.0b3cpython-3.12.0b3.zip  cpython-3.12.0b3.tar.gz  cpython-3.12.0b3.tar.bz2  Thomas Wouters20 months
v3.10.12cpython-3.10.12.zip  cpython-3.10.12.tar.gz  cpython-3.10.12.tar.bz2  Pablo Galindo21 months
v3.11.4cpython-3.11.4.zip  cpython-3.11.4.tar.gz  cpython-3.11.4.tar.bz2  Pablo Galindo21 months
v3.12.0b2cpython-3.12.0b2.zip  cpython-3.12.0b2.tar.gz  cpython-3.12.0b2.tar.bz2  Thomas Wouters21 months
v3.8.17cpython-3.8.17.zip  cpython-3.8.17.tar.gz  cpython-3.8.17.tar.bz2  Łukasz Langa21 months
v3.9.17cpython-3.9.17.zip  cpython-3.9.17.tar.gz  cpython-3.9.17.tar.bz2  Łukasz Langa21 months
v3.7.17cpython-3.7.17.zip  cpython-3.7.17.tar.gz  cpython-3.7.17.tar.bz2  Ned Deily21 months
v3.12.0b1cpython-3.12.0b1.zip  cpython-3.12.0b1.tar.gz  cpython-3.12.0b1.tar.bz2  Thomas Wouters21 months
v3.11.3cpython-3.11.3.zip  cpython-3.11.3.tar.gz  cpython-3.11.3.tar.bz2  Pablo Galindo23 months
v3.10.11cpython-3.10.11.zip  cpython-3.10.11.tar.gz  cpython-3.10.11.tar.bz2  Pablo Galindo23 months
v3.12.0a7cpython-3.12.0a7.zip  cpython-3.12.0a7.tar.gz  cpython-3.12.0a7.tar.bz2  Thomas Wouters23 months
v3.12.0a6cpython-3.12.0a6.zip  cpython-3.12.0a6.tar.gz  cpython-3.12.0a6.tar.bz2  Thomas Wouters24 months
v3.11.2cpython-3.11.2.zip  cpython-3.11.2.tar.gz  cpython-3.11.2.tar.bz2  Pablo Galindo2 years
v3.12.0a5cpython-3.12.0a5.zip  cpython-3.12.0a5.tar.gz  cpython-3.12.0a5.tar.bz2  Thomas Wouters2 years
v3.10.10cpython-3.10.10.zip  cpython-3.10.10.tar.gz  cpython-3.10.10.tar.bz2  Pablo Galindo2 years
v3.12.0a4cpython-3.12.0a4.zip  cpython-3.12.0a4.tar.gz  cpython-3.12.0a4.tar.bz2  Thomas Wouters2 years
v3.11.1cpython-3.11.1.zip  cpython-3.11.1.tar.gz  cpython-3.11.1.tar.bz2  Pablo Galindo2 years
v3.8.16cpython-3.8.16.zip  cpython-3.8.16.tar.gz  cpython-3.8.16.tar.bz2  Łukasz Langa2 years
v3.7.16cpython-3.7.16.zip  cpython-3.7.16.tar.gz  cpython-3.7.16.tar.bz2  Ned Deily2 years
v3.12.0a3cpython-3.12.0a3.zip  cpython-3.12.0a3.tar.gz  cpython-3.12.0a3.tar.bz2  Thomas Wouters2 years
v3.10.9cpython-3.10.9.zip  cpython-3.10.9.tar.gz  cpython-3.10.9.tar.bz2  Pablo Galindo2 years
v3.9.16cpython-3.9.16.zip  cpython-3.9.16.tar.gz  cpython-3.9.16.tar.bz2  Łukasz Langa2 years
v3.12.0a2cpython-3.12.0a2.zip  cpython-3.12.0a2.tar.gz  cpython-3.12.0a2.tar.bz2  Thomas Wouters2 years
v3.12.0a1cpython-3.12.0a1.zip  cpython-3.12.0a1.tar.gz  cpython-3.12.0a1.tar.bz2  Thomas Wouters2 years
v3.11.0cpython-3.11.0.zip  cpython-3.11.0.tar.gz  cpython-3.11.0.tar.bz2  Pablo Galindo2 years
v3.8.15cpython-3.8.15.zip  cpython-3.8.15.tar.gz  cpython-3.8.15.tar.bz2  Łukasz Langa2 years
v3.9.15cpython-3.9.15.zip  cpython-3.9.15.tar.gz  cpython-3.9.15.tar.bz2  Łukasz Langa2 years
v3.10.8cpython-3.10.8.zip  cpython-3.10.8.tar.gz  cpython-3.10.8.tar.bz2  Pablo Galindo2 years
v3.7.15cpython-3.7.15.zip  cpython-3.7.15.tar.gz  cpython-3.7.15.tar.bz2  Ned Deily2 years
v3.11.0rc2cpython-3.11.0rc2.zip  cpython-3.11.0rc2.tar.gz  cpython-3.11.0rc2.tar.bz2  Pablo Galindo2 years
v3.8.14cpython-3.8.14.zip  cpython-3.8.14.tar.gz  cpython-3.8.14.tar.bz2  Łukasz Langa2 years
v3.9.14cpython-3.9.14.zip  cpython-3.9.14.tar.gz  cpython-3.9.14.tar.bz2  Łukasz Langa2 years
v3.7.14cpython-3.7.14.zip  cpython-3.7.14.tar.gz  cpython-3.7.14.tar.bz2  Ned Deily2 years
v3.10.7cpython-3.10.7.zip  cpython-3.10.7.tar.gz  cpython-3.10.7.tar.bz2  Pablo Galindo2 years
v3.11.0rc1cpython-3.11.0rc1.zip  cpython-3.11.0rc1.tar.gz  cpython-3.11.0rc1.tar.bz2  Pablo Galindo3 years
v3.10.6cpython-3.10.6.zip  cpython-3.10.6.tar.gz  cpython-3.10.6.tar.bz2  Pablo Galindo3 years
v3.11.0b5cpython-3.11.0b5.zip  cpython-3.11.0b5.tar.gz  cpython-3.11.0b5.tar.bz2  Pablo Galindo3 years
v3.11.0b4cpython-3.11.0b4.zip  cpython-3.11.0b4.tar.gz  cpython-3.11.0b4.tar.bz2  Pablo Galindo3 years
v3.10.5cpython-3.10.5.zip  cpython-3.10.5.tar.gz  cpython-3.10.5.tar.bz2  Pablo Galindo3 years
v3.11.0b3cpython-3.11.0b3.zip  cpython-3.11.0b3.tar.gz  cpython-3.11.0b3.tar.bz2  Pablo Galindo3 years
v3.11.0b2cpython-3.11.0b2.zip  cpython-3.11.0b2.tar.gz  cpython-3.11.0b2.tar.bz2  Pablo Galindo3 years
v3.9.13cpython-3.9.13.zip  cpython-3.9.13.tar.gz  cpython-3.9.13.tar.bz2  Łukasz Langa3 years
v3.11.0b1cpython-3.11.0b1.zip  cpython-3.11.0b1.tar.gz  cpython-3.11.0b1.tar.bz2  Pablo Galindo3 years
v3.11.0a7cpython-3.11.0a7.zip  cpython-3.11.0a7.tar.gz  cpython-3.11.0a7.tar.bz2  Pablo Galindo3 years
v3.9.12cpython-3.9.12.zip  cpython-3.9.12.tar.gz  cpython-3.9.12.tar.bz2  Łukasz Langa3 years
v3.10.4cpython-3.10.4.zip  cpython-3.10.4.tar.gz  cpython-3.10.4.tar.bz2  Pablo Galindo3 years
v3.7.13cpython-3.7.13.zip  cpython-3.7.13.tar.gz  cpython-3.7.13.tar.bz2  Ned Deily3 years
v3.9.11cpython-3.9.11.zip  cpython-3.9.11.tar.gz  cpython-3.9.11.tar.bz2  Łukasz Langa3 years
v3.8.13cpython-3.8.13.zip  cpython-3.8.13.tar.gz  cpython-3.8.13.tar.bz2  Łukasz Langa3 years
v3.10.3cpython-3.10.3.zip  cpython-3.10.3.tar.gz  cpython-3.10.3.tar.bz2  Pablo Galindo3 years
v3.11.0a6cpython-3.11.0a6.zip  cpython-3.11.0a6.tar.gz  cpython-3.11.0a6.tar.bz2  Pablo Galindo3 years
v3.11.0a5cpython-3.11.0a5.zip  cpython-3.11.0a5.tar.gz  cpython-3.11.0a5.tar.bz2  Pablo Galindo3 years
v3.9.10cpython-3.9.10.zip  cpython-3.9.10.tar.gz  cpython-3.9.10.tar.bz2  Łukasz Langa3 years
v3.11.0a4cpython-3.11.0a4.zip  cpython-3.11.0a4.tar.gz  cpython-3.11.0a4.tar.bz2  Pablo Galindo3 years
v3.10.2cpython-3.10.2.zip  cpython-3.10.2.tar.gz  cpython-3.10.2.tar.bz2  Pablo Galindo3 years
3.6cpython-3.6.zip  cpython-3.6.tar.gz  cpython-3.6.tar.bz2  Ned Deily3 years
v3.11.0a3cpython-3.11.0a3.zip  cpython-3.11.0a3.tar.gz  cpython-3.11.0a3.tar.bz2  Pablo Galindo3 years
v3.10.1cpython-3.10.1.zip  cpython-3.10.1.tar.gz  cpython-3.10.1.tar.bz2  Pablo Galindo3 years
v3.9.9cpython-3.9.9.zip  cpython-3.9.9.tar.gz  cpython-3.9.9.tar.bz2  Łukasz Langa3 years
v3.9.8cpython-3.9.8.zip  cpython-3.9.8.tar.gz  cpython-3.9.8.tar.bz2  Łukasz Langa3 years
v3.11.0a2cpython-3.11.0a2.zip  cpython-3.11.0a2.tar.gz  cpython-3.11.0a2.tar.bz2  Pablo Galindo3 years
v3.11.0a1cpython-3.11.0a1.zip  cpython-3.11.0a1.tar.gz  cpython-3.11.0a1.tar.bz2  Pablo Galindo3 years
v3.10.0cpython-3.10.0.zip  cpython-3.10.0.tar.gz  cpython-3.10.0.tar.bz2  Pablo Galindo3 years
v3.10.0rc2cpython-3.10.0rc2.zip  cpython-3.10.0rc2.tar.gz  cpython-3.10.0rc2.tar.bz2  Pablo Galindo3 years
v3.6.15cpython-3.6.15.zip  cpython-3.6.15.tar.gz  cpython-3.6.15.tar.bz2  Ned Deily3 years
v3.7.12cpython-3.7.12.zip  cpython-3.7.12.tar.gz  cpython-3.7.12.tar.bz2  Ned Deily3 years
v3.9.7cpython-3.9.7.zip  cpython-3.9.7.tar.gz  cpython-3.9.7.tar.bz2  Łukasz Langa4 years
v3.8.12cpython-3.8.12.zip  cpython-3.8.12.tar.gz  cpython-3.8.12.tar.bz2  Łukasz Langa4 years
v3.10.0rc1cpython-3.10.0rc1.zip  cpython-3.10.0rc1.tar.gz  cpython-3.10.0rc1.tar.bz2  Pablo Galindo4 years
v3.10.0b4cpython-3.10.0b4.zip  cpython-3.10.0b4.tar.gz  cpython-3.10.0b4.tar.bz2  Pablo Galindo4 years
v3.6.14cpython-3.6.14.zip  cpython-3.6.14.tar.gz  cpython-3.6.14.tar.bz2  Ned Deily4 years
v3.7.11cpython-3.7.11.zip  cpython-3.7.11.tar.gz  cpython-3.7.11.tar.bz2  Ned Deily4 years
v3.8.11cpython-3.8.11.zip  cpython-3.8.11.tar.gz  cpython-3.8.11.tar.bz2  Łukasz Langa4 years
v3.9.6cpython-3.9.6.zip  cpython-3.9.6.tar.gz  cpython-3.9.6.tar.bz2  Łukasz Langa4 years
v3.10.0b3cpython-3.10.0b3.zip  cpython-3.10.0b3.tar.gz  cpython-3.10.0b3.tar.bz2  Pablo Galindo4 years
v3.10.0b2cpython-3.10.0b2.zip  cpython-3.10.0b2.tar.gz  cpython-3.10.0b2.tar.bz2  Pablo Galindo4 years
v3.10.0b1cpython-3.10.0b1.zip  cpython-3.10.0b1.tar.gz  cpython-3.10.0b1.tar.bz2  Pablo Galindo4 years
v3.9.5cpython-3.9.5.zip  cpython-3.9.5.tar.gz  cpython-3.9.5.tar.bz2  Łukasz Langa4 years
v3.8.10cpython-3.8.10.zip  cpython-3.8.10.tar.gz  cpython-3.8.10.tar.bz2  Łukasz Langa4 years
v3.10.0a7cpython-3.10.0a7.zip  cpython-3.10.0a7.tar.gz  cpython-3.10.0a7.tar.bz2  Pablo Galindo4 years
v3.9.4cpython-3.9.4.zip  cpython-3.9.4.tar.gz  cpython-3.9.4.tar.bz2  Łukasz Langa4 years
v3.8.9cpython-3.8.9.zip  cpython-3.8.9.tar.gz  cpython-3.8.9.tar.bz2  Łukasz Langa4 years
v3.9.3cpython-3.9.3.zip  cpython-3.9.3.tar.gz  cpython-3.9.3.tar.bz2  Łukasz Langa4 years
v3.10.0a6cpython-3.10.0a6.zip  cpython-3.10.0a6.tar.gz  cpython-3.10.0a6.tar.bz2  Pablo Galindo4 years
v3.9.2cpython-3.9.2.zip  cpython-3.9.2.tar.gz  cpython-3.9.2.tar.bz2  Łukasz Langa4 years
v3.8.8cpython-3.8.8.zip  cpython-3.8.8.tar.gz  cpython-3.8.8.tar.bz2  Łukasz Langa4 years
v3.9.2rc1cpython-3.9.2rc1.zip  cpython-3.9.2rc1.tar.gz  cpython-3.9.2rc1.tar.bz2  Łukasz Langa4 years
v3.8.8rc1cpython-3.8.8rc1.zip  cpython-3.8.8rc1.tar.gz  cpython-3.8.8rc1.tar.bz2  Łukasz Langa4 years
v3.6.13cpython-3.6.13.zip  cpython-3.6.13.tar.gz  cpython-3.6.13.tar.bz2  Ned Deily4 years
v3.7.10cpython-3.7.10.zip  cpython-3.7.10.tar.gz  cpython-3.7.10.tar.bz2  Ned Deily4 years
v3.10.0a5cpython-3.10.0a5.zip  cpython-3.10.0a5.tar.gz  cpython-3.10.0a5.tar.bz2  Pablo Galindo4 years
2.7cpython-2.7.zip  cpython-2.7.tar.gz  cpython-2.7.tar.bz2  Benjamin Peterson4 years
v3.10.0a4cpython-3.10.0a4.zip  cpython-3.10.0a4.tar.gz  cpython-3.10.0a4.tar.bz2  Pablo Galindo4 years
v3.8.7cpython-3.8.7.zip  cpython-3.8.7.tar.gz  cpython-3.8.7.tar.bz2  Łukasz Langa4 years
v3.10.0a3cpython-3.10.0a3.zip  cpython-3.10.0a3.tar.gz  cpython-3.10.0a3.tar.bz2  Pablo Galindo4 years
v3.8.7rc1cpython-3.8.7rc1.zip  cpython-3.8.7rc1.tar.gz  cpython-3.8.7rc1.tar.bz2  Łukasz Langa4 years
v3.9.1cpython-3.9.1.zip  cpython-3.9.1.tar.gz  cpython-3.9.1.tar.bz2  Łukasz Langa4 years
v3.9.1rc1cpython-3.9.1rc1.zip  cpython-3.9.1rc1.tar.gz  cpython-3.9.1rc1.tar.bz2  Łukasz Langa4 years
v3.10.0a2cpython-3.10.0a2.zip  cpython-3.10.0a2.tar.gz  cpython-3.10.0a2.tar.bz2  Pablo Galindo4 years
3.5cpython-3.5.zip  cpython-3.5.tar.gz  cpython-3.5.tar.bz2  Larry Hastings4 years
v3.10.0a1cpython-3.10.0a1.zip  cpython-3.10.0a1.tar.gz  cpython-3.10.0a1.tar.bz2  Pablo Galindo4 years
v3.9.0cpython-3.9.0.zip  cpython-3.9.0.tar.gz  cpython-3.9.0.tar.bz2  Łukasz Langa4 years
fedora-2.7.18-6fedora-2.7.18-6.zip  fedora-2.7.18-6.tar.gz  fedora-2.7.18-6.tar.bz2  AMIR4 years
fedora-2.7.18-5fedora-2.7.18-5.zip  fedora-2.7.18-5.tar.gz  fedora-2.7.18-5.tar.bz2  Rishi4 years
v3.8.6cpython-3.8.6.zip  cpython-3.8.6.tar.gz  cpython-3.8.6.tar.bz2  Łukasz Langa4 years
v3.9.0rc2cpython-3.9.0rc2.zip  cpython-3.9.0rc2.tar.gz  cpython-3.9.0rc2.tar.bz2  Łukasz Langa4 years
v3.8.6rc1cpython-3.8.6rc1.zip  cpython-3.8.6rc1.tar.gz  cpython-3.8.6rc1.tar.bz2  Łukasz Langa4 years
v3.5.10cpython-3.5.10.zip  cpython-3.5.10.tar.gz  cpython-3.5.10.tar.bz2  Larry Hastings4 years
v3.5.10rc1cpython-3.5.10rc1.zip  cpython-3.5.10rc1.tar.gz  cpython-3.5.10rc1.tar.bz2  Larry Hastings5 years
v3.6.12cpython-3.6.12.zip  cpython-3.6.12.tar.gz  cpython-3.6.12.tar.bz2  Ned Deily5 years
v3.7.9cpython-3.7.9.zip  cpython-3.7.9.tar.gz  cpython-3.7.9.tar.bz2  Ned Deily5 years
v3.9.0rc1cpython-3.9.0rc1.zip  cpython-3.9.0rc1.tar.gz  cpython-3.9.0rc1.tar.bz2  Łukasz Langa5 years
v3.9.0b5cpython-3.9.0b5.zip  cpython-3.9.0b5.tar.gz  cpython-3.9.0b5.tar.bz2  Łukasz Langa5 years
v3.8.5cpython-3.8.5.zip  cpython-3.8.5.tar.gz  cpython-3.8.5.tar.bz2  Łukasz Langa5 years
v3.8.4cpython-3.8.4.zip  cpython-3.8.4.tar.gz  cpython-3.8.4.tar.bz2  Łukasz Langa5 years
v3.9.0b4cpython-3.9.0b4.zip  cpython-3.9.0b4.tar.gz  cpython-3.9.0b4.tar.bz2  Łukasz Langa5 years
v3.8.4rc1cpython-3.8.4rc1.zip  cpython-3.8.4rc1.tar.gz  cpython-3.8.4rc1.tar.bz2  Łukasz Langa5 years
v3.6.11cpython-3.6.11.zip  cpython-3.6.11.tar.gz  cpython-3.6.11.tar.bz2  Ned Deily5 years
v3.7.8cpython-3.7.8.zip  cpython-3.7.8.tar.gz  cpython-3.7.8.tar.bz2  Ned Deily5 years
v3.6.11rc1cpython-3.6.11rc1.zip  cpython-3.6.11rc1.tar.gz  cpython-3.6.11rc1.tar.bz2  Ned Deily5 years
v3.7.8rc1cpython-3.7.8rc1.zip  cpython-3.7.8rc1.tar.gz  cpython-3.7.8rc1.tar.bz2  Ned Deily5 years
v3.9.0b3cpython-3.9.0b3.zip  cpython-3.9.0b3.tar.gz  cpython-3.9.0b3.tar.bz2  Łukasz Langa5 years
v3.9.0b2cpython-3.9.0b2.zip  cpython-3.9.0b2.tar.gz  cpython-3.9.0b2.tar.bz2  Łukasz Langa5 years
v3.9.0b1cpython-3.9.0b1.zip  cpython-3.9.0b1.tar.gz  cpython-3.9.0b1.tar.bz2  Łukasz Langa5 years
v3.8.3cpython-3.8.3.zip  cpython-3.8.3.tar.gz  cpython-3.8.3.tar.bz2  Łukasz Langa5 years
v3.8.3rc1cpython-3.8.3rc1.zip  cpython-3.8.3rc1.tar.gz  cpython-3.8.3rc1.tar.bz2  Łukasz Langa5 years
v3.9.0a6cpython-3.9.0a6.zip  cpython-3.9.0a6.tar.gz  cpython-3.9.0a6.tar.bz2  Łukasz Langa5 years
v2.7.18cpython-2.7.18.zip  cpython-2.7.18.tar.gz  cpython-2.7.18.tar.bz2  Benjamin Peterson5 years
v2.7.18rc1cpython-2.7.18rc1.zip  cpython-2.7.18rc1.tar.gz  cpython-2.7.18rc1.tar.bz2  Benjamin Peterson5 years
v3.9.0a5cpython-3.9.0a5.zip  cpython-3.9.0a5.tar.gz  cpython-3.9.0a5.tar.bz2  Łukasz Langa5 years
v3.7.7cpython-3.7.7.zip  cpython-3.7.7.tar.gz  cpython-3.7.7.tar.bz2  Ned Deily5 years
v3.7.7rc1cpython-3.7.7rc1.zip  cpython-3.7.7rc1.tar.gz  cpython-3.7.7rc1.tar.bz2  Ned Deily5 years
v3.9.0a4cpython-3.9.0a4.zip  cpython-3.9.0a4.tar.gz  cpython-3.9.0a4.tar.bz2  Łukasz Langa5 years
v3.8.2cpython-3.8.2.zip  cpython-3.8.2.tar.gz  cpython-3.8.2.tar.bz2  Łukasz Langa5 years
v3.8.2rc2cpython-3.8.2rc2.zip  cpython-3.8.2rc2.tar.gz  cpython-3.8.2rc2.tar.bz2  Łukasz Langa5 years
v3.8.2rc1cpython-3.8.2rc1.zip  cpython-3.8.2rc1.tar.gz  cpython-3.8.2rc1.tar.bz2  Łukasz Langa5 years
v3.9.0a3cpython-3.9.0a3.zip  cpython-3.9.0a3.tar.gz  cpython-3.9.0a3.tar.bz2  Łukasz Langa5 years
v3.9.0a2cpython-3.9.0a2.zip  cpython-3.9.0a2.tar.gz  cpython-3.9.0a2.tar.bz2  Łukasz Langa5 years
v3.6.10cpython-3.6.10.zip  cpython-3.6.10.tar.gz  cpython-3.6.10.tar.bz2  Ned Deily5 years
v3.7.6cpython-3.7.6.zip  cpython-3.7.6.tar.gz  cpython-3.7.6.tar.bz2  Ned Deily5 years
v3.8.1cpython-3.8.1.zip  cpython-3.8.1.tar.gz  cpython-3.8.1.tar.bz2  Łukasz Langa5 years
v3.6.10rc1cpython-3.6.10rc1.zip  cpython-3.6.10rc1.tar.gz  cpython-3.6.10rc1.tar.bz2  Ned Deily5 years
v3.7.6rc1cpython-3.7.6rc1.zip  cpython-3.7.6rc1.tar.gz  cpython-3.7.6rc1.tar.bz2  Ned Deily5 years
v3.8.1rc1cpython-3.8.1rc1.zip  cpython-3.8.1rc1.tar.gz  cpython-3.8.1rc1.tar.bz2  Łukasz Langa5 years
v3.9.0a1cpython-3.9.0a1.zip  cpython-3.9.0a1.tar.gz  cpython-3.9.0a1.tar.bz2  Łukasz Langa5 years
v3.5.9cpython-3.5.9.zip  cpython-3.5.9.tar.gz  cpython-3.5.9.tar.bz2  Larry Hastings5 years
v3.5.8cpython-3.5.8.zip  cpython-3.5.8.tar.gz  cpython-3.5.8.tar.bz2  Larry Hastings5 years
v2.7.17cpython-2.7.17.zip  cpython-2.7.17.tar.gz  cpython-2.7.17.tar.bz2  Benjamin Peterson5 years
v3.7.5cpython-3.7.5.zip  cpython-3.7.5.tar.gz  cpython-3.7.5.tar.bz2  Ned Deily5 years
v3.8.0cpython-3.8.0.zip  cpython-3.8.0.tar.gz  cpython-3.8.0.tar.bz2  Łukasz Langa5 years
v3.5.8rc2cpython-3.5.8rc2.zip  cpython-3.5.8rc2.tar.gz  cpython-3.5.8rc2.tar.bz2  Larry Hastings5 years
v2.7.17rc1cpython-2.7.17rc1.zip  cpython-2.7.17rc1.tar.gz  cpython-2.7.17rc1.tar.bz2  Benjamin Peterson5 years
v3.7.5rc1cpython-3.7.5rc1.zip  cpython-3.7.5rc1.tar.gz  cpython-3.7.5rc1.tar.bz2  Ned Deily5 years
v3.8.0rc1cpython-3.8.0rc1.zip  cpython-3.8.0rc1.tar.gz  cpython-3.8.0rc1.tar.bz2  Łukasz Langa5 years
v3.5.8rc1cpython-3.5.8rc1.zip  cpython-3.5.8rc1.tar.gz  cpython-3.5.8rc1.tar.bz2  Larry Hastings5 years
v3.8.0b4cpython-3.8.0b4.zip  cpython-3.8.0b4.tar.gz  cpython-3.8.0b4.tar.bz2  Łukasz Langa6 years
v3.8.0b3cpython-3.8.0b3.zip  cpython-3.8.0b3.tar.gz  cpython-3.8.0b3.tar.bz2  Łukasz Langa6 years
v3.7.4cpython-3.7.4.zip  cpython-3.7.4.tar.gz  cpython-3.7.4.tar.bz2  Ned Deily6 years
v3.8.0b2cpython-3.8.0b2.zip  cpython-3.8.0b2.tar.gz  cpython-3.8.0b2.tar.bz2  Łukasz Langa6 years
v3.6.9cpython-3.6.9.zip  cpython-3.6.9.tar.gz  cpython-3.6.9.tar.bz2  Ned Deily6 years
v3.7.4rc2cpython-3.7.4rc2.zip  cpython-3.7.4rc2.tar.gz  cpython-3.7.4rc2.tar.bz2  Ned Deily6 years
v3.6.9rc1cpython-3.6.9rc1.zip  cpython-3.6.9rc1.tar.gz  cpython-3.6.9rc1.tar.bz2  Ned Deily6 years
v3.7.4rc1cpython-3.7.4rc1.zip  cpython-3.7.4rc1.tar.gz  cpython-3.7.4rc1.tar.bz2  Ned Deily6 years
v3.8.0b1cpython-3.8.0b1.zip  cpython-3.8.0b1.tar.gz  cpython-3.8.0b1.tar.bz2  Łukasz Langa6 years
3.4cpython-3.4.zip  cpython-3.4.tar.gz  cpython-3.4.tar.bz2  Larry Hastings6 years
v3.8.0a4cpython-3.8.0a4.zip  cpython-3.8.0a4.tar.gz  cpython-3.8.0a4.tar.bz2  Łukasz Langa6 years
v3.7.3cpython-3.7.3.zip  cpython-3.7.3.tar.gz  cpython-3.7.3.tar.bz2  Ned Deily6 years
v3.8.0a3cpython-3.8.0a3.zip  cpython-3.8.0a3.tar.gz  cpython-3.8.0a3.tar.bz2  Łukasz Langa6 years
v3.4.10cpython-3.4.10.zip  cpython-3.4.10.tar.gz  cpython-3.4.10.tar.bz2  Larry Hastings6 years
v3.5.7cpython-3.5.7.zip  cpython-3.5.7.tar.gz  cpython-3.5.7.tar.bz2  Larry Hastings6 years
v3.7.3rc1cpython-3.7.3rc1.zip  cpython-3.7.3rc1.tar.gz  cpython-3.7.3rc1.tar.bz2  Ned Deily6 years
v3.5.7rc1cpython-3.5.7rc1.zip  cpython-3.5.7rc1.tar.gz  cpython-3.5.7rc1.tar.bz2  Larry Hastings6 years
v3.4.10rc1cpython-3.4.10rc1.zip  cpython-3.4.10rc1.tar.gz  cpython-3.4.10rc1.tar.bz2  Larry Hastings6 years
v2.7.16cpython-2.7.16.zip  cpython-2.7.16.tar.gz  cpython-2.7.16.tar.bz2  Benjamin Peterson6 years
v3.8.0a2cpython-3.8.0a2.zip  cpython-3.8.0a2.tar.gz  cpython-3.8.0a2.tar.bz2  Łukasz Langa6 years
v2.7.16rc1cpython-2.7.16rc1.zip  cpython-2.7.16rc1.tar.gz  cpython-2.7.16rc1.tar.bz2  Benjamin Peterson6 years
v3.8.0a1cpython-3.8.0a1.zip  cpython-3.8.0a1.tar.gz  cpython-3.8.0a1.tar.bz2  Łukasz Langa6 years
v3.7.2cpython-3.7.2.zip  cpython-3.7.2.tar.gz  cpython-3.7.2.tar.bz2  Ned Deily6 years
v3.6.8cpython-3.6.8.zip  cpython-3.6.8.tar.gz  cpython-3.6.8.tar.bz2  Ned Deily6 years
v3.6.8rc1cpython-3.6.8rc1.zip  cpython-3.6.8rc1.tar.gz  cpython-3.6.8rc1.tar.bz2  Ned Deily6 years
v3.7.2rc1cpython-3.7.2rc1.zip  cpython-3.7.2rc1.tar.gz  cpython-3.7.2rc1.tar.bz2  Ned Deily6 years
v3.7.1cpython-3.7.1.zip  cpython-3.7.1.tar.gz  cpython-3.7.1.tar.bz2  Ned Deily6 years
v3.6.7cpython-3.6.7.zip  cpython-3.6.7.tar.gz  cpython-3.6.7.tar.bz2  Ned Deily6 years
v3.6.7rc2cpython-3.6.7rc2.zip  cpython-3.6.7rc2.tar.gz  cpython-3.6.7rc2.tar.bz2  Ned Deily6 years
v3.7.1rc2cpython-3.7.1rc2.zip  cpython-3.7.1rc2.tar.gz  cpython-3.7.1rc2.tar.bz2  Ned Deily6 years
v3.6.7rc1cpython-3.6.7rc1.zip  cpython-3.6.7rc1.tar.gz  cpython-3.6.7rc1.tar.bz2  Ned Deily6 years
v3.7.1rc1cpython-3.7.1rc1.zip  cpython-3.7.1rc1.tar.gz  cpython-3.7.1rc1.tar.bz2  Ned Deily6 years
v3.5.6cpython-3.5.6.zip  cpython-3.5.6.tar.gz  cpython-3.5.6.tar.bz2  Larry Hastings7 years
v3.4.9cpython-3.4.9.zip  cpython-3.4.9.tar.gz  cpython-3.4.9.tar.bz2  Larry Hastings7 years
v3.5.6rc1cpython-3.5.6rc1.zip  cpython-3.5.6rc1.tar.gz  cpython-3.5.6rc1.tar.bz2  Larry Hastings7 years
v3.4.9rc1cpython-3.4.9rc1.zip  cpython-3.4.9rc1.tar.gz  cpython-3.4.9rc1.tar.bz2  Larry Hastings7 years
v3.7.0cpython-3.7.0.zip  cpython-3.7.0.tar.gz  cpython-3.7.0.tar.bz2  Ned Deily7 years
v3.6.6cpython-3.6.6.zip  cpython-3.6.6.tar.gz  cpython-3.6.6.tar.bz2  Ned Deily7 years
v3.7.0rc1cpython-3.7.0rc1.zip  cpython-3.7.0rc1.tar.gz  cpython-3.7.0rc1.tar.bz2  Ned Deily7 years
v3.6.6rc1cpython-3.6.6rc1.zip  cpython-3.6.6rc1.tar.gz  cpython-3.6.6rc1.tar.bz2  Ned Deily7 years
v3.7.0b5cpython-3.7.0b5.zip  cpython-3.7.0b5.tar.gz  cpython-3.7.0b5.tar.bz2  Ned Deily7 years
v3.7.0b4cpython-3.7.0b4.zip  cpython-3.7.0b4.tar.gz  cpython-3.7.0b4.tar.bz2  Ned Deily7 years
v2.7.15cpython-2.7.15.zip  cpython-2.7.15.tar.gz  cpython-2.7.15.tar.bz2  Benjamin Peterson7 years
v2.7.15rc1cpython-2.7.15rc1.zip  cpython-2.7.15rc1.tar.gz  cpython-2.7.15rc1.tar.bz2  Benjamin Peterson7 years
v3.7.0b3cpython-3.7.0b3.zip  cpython-3.7.0b3.tar.gz  cpython-3.7.0b3.tar.bz2  Ned Deily7 years
v3.6.5cpython-3.6.5.zip  cpython-3.6.5.tar.gz  cpython-3.6.5.tar.bz2  Ned Deily7 years
v3.6.5rc1cpython-3.6.5rc1.zip  cpython-3.6.5rc1.tar.gz  cpython-3.6.5rc1.tar.bz2  Ned Deily7 years
v3.7.0b2cpython-3.7.0b2.zip  cpython-3.7.0b2.tar.gz  cpython-3.7.0b2.tar.bz2  Ned Deily7 years
v3.5.5cpython-3.5.5.zip  cpython-3.5.5.tar.gz  cpython-3.5.5.tar.bz2  Larry Hastings7 years
v3.4.8cpython-3.4.8.zip  cpython-3.4.8.tar.gz  cpython-3.4.8.tar.bz2  Larry Hastings7 years
v3.5.5rc1cpython-3.5.5rc1.zip  cpython-3.5.5rc1.tar.gz  cpython-3.5.5rc1.tar.bz2  Larry Hastings7 years
v3.4.8rc1cpython-3.4.8rc1.zip  cpython-3.4.8rc1.tar.gz  cpython-3.4.8rc1.tar.bz2  Larry Hastings7 years
v3.7.0b1cpython-3.7.0b1.zip  cpython-3.7.0b1.tar.gz  cpython-3.7.0b1.tar.bz2  Ned Deily7 years
v3.7.0a4cpython-3.7.0a4.zip  cpython-3.7.0a4.tar.gz  cpython-3.7.0a4.tar.bz2  Ned Deily7 years
v3.6.4cpython-3.6.4.zip  cpython-3.6.4.tar.gz  cpython-3.6.4.tar.bz2  Ned Deily7 years
v3.7.0a3cpython-3.7.0a3.zip  cpython-3.7.0a3.tar.gz  cpython-3.7.0a3.tar.bz2  Ned Deily7 years
v3.6.4rc1cpython-3.6.4rc1.zip  cpython-3.6.4rc1.tar.gz  cpython-3.6.4rc1.tar.bz2  Ned Deily7 years
v3.7.0a2cpython-3.7.0a2.zip  cpython-3.7.0a2.tar.gz  cpython-3.7.0a2.tar.bz2  Ned Deily7 years
3.3cpython-3.3.zip  cpython-3.3.tar.gz  cpython-3.3.tar.bz2  Ned Deily7 years
v3.6.3cpython-3.6.3.zip  cpython-3.6.3.tar.gz  cpython-3.6.3.tar.bz2  Ned Deily7 years
v3.3.7cpython-3.3.7.zip  cpython-3.3.7.tar.gz  cpython-3.3.7.tar.bz2  Ned Deily7 years
v3.7.0a1cpython-3.7.0a1.zip  cpython-3.7.0a1.tar.gz  cpython-3.7.0a1.tar.bz2  Ned Deily7 years
v3.6.3rc1cpython-3.6.3rc1.zip  cpython-3.6.3rc1.tar.gz  cpython-3.6.3rc1.tar.bz2  Ned Deily7 years
v2.7.14cpython-2.7.14.zip  cpython-2.7.14.tar.gz  cpython-2.7.14.tar.bz2  Benjamin Peterson7 years
v3.3.7rc1cpython-3.3.7rc1.zip  cpython-3.3.7rc1.tar.gz  cpython-3.3.7rc1.tar.bz2  Ned Deily7 years
v2.7.14rc1cpython-2.7.14rc1.zip  cpython-2.7.14rc1.tar.gz  cpython-2.7.14rc1.tar.bz2  Benjamin Peterson8 years
v3.4.7cpython-3.4.7.zip  cpython-3.4.7.tar.gz  cpython-3.4.7.tar.bz2  Larry Hastings8 years
v3.5.4cpython-3.5.4.zip  cpython-3.5.4.tar.gz  cpython-3.5.4.tar.bz2  Larry Hastings8 years
v3.5.4rc1cpython-3.5.4rc1.zip  cpython-3.5.4rc1.tar.gz  cpython-3.5.4rc1.tar.bz2  Larry Hastings8 years
v3.4.7rc1cpython-3.4.7rc1.zip  cpython-3.4.7rc1.tar.gz  cpython-3.4.7rc1.tar.bz2  Larry Hastings8 years
v3.6.2cpython-3.6.2.zip  cpython-3.6.2.tar.gz  cpython-3.6.2.tar.bz2  Ned Deily8 years
v3.6.2rc2cpython-3.6.2rc2.zip  cpython-3.6.2rc2.tar.gz  cpython-3.6.2rc2.tar.bz2  Ned Deily8 years
3.0cpython-3.0.zip  cpython-3.0.tar.gz  cpython-3.0.tar.bz2  Ned Deily8 years
3.1cpython-3.1.zip  cpython-3.1.tar.gz  cpython-3.1.tar.bz2  Ned Deily8 years
3.2cpython-3.2.zip  cpython-3.2.tar.gz  cpython-3.2.tar.bz2  Ned Deily8 years
legacy-trunklegacy-trunk.zip  legacy-trunk.tar.gz  legacy-trunk.tar.bz2  Ned Deily8 years
2.1cpython-2.1.zip  cpython-2.1.tar.gz  cpython-2.1.tar.bz2  Ned Deily8 years
2.2cpython-2.2.zip  cpython-2.2.tar.gz  cpython-2.2.tar.bz2  Ned Deily8 years
2.3cpython-2.3.zip  cpython-2.3.tar.gz  cpython-2.3.tar.bz2  Ned Deily8 years
2.4cpython-2.4.zip  cpython-2.4.tar.gz  cpython-2.4.tar.bz2  Ned Deily8 years
2.5cpython-2.5.zip  cpython-2.5.tar.gz  cpython-2.5.tar.bz2  Ned Deily8 years
2.6cpython-2.6.zip  cpython-2.6.tar.gz  cpython-2.6.tar.bz2  Ned Deily8 years
2.0cpython-2.0.zip  cpython-2.0.tar.gz  cpython-2.0.tar.bz2  Ned Deily8 years
v3.6.2rc1cpython-3.6.2rc1.zip  cpython-3.6.2rc1.tar.gz  cpython-3.6.2rc1.tar.bz2  Ned Deily8 years
v3.6.1cpython-3.6.1.zip  cpython-3.6.1.tar.gz  cpython-3.6.1.tar.bz2  Ned Deily8 years
v3.6.1rc1cpython-3.6.1rc1.zip  cpython-3.6.1rc1.tar.gz  cpython-3.6.1rc1.tar.bz2  Ned Deily8 years
v3.4.6cpython-3.4.6.zip  cpython-3.4.6.tar.gz  cpython-3.4.6.tar.bz2  Larry Hastings8 years
v3.5.3cpython-3.5.3.zip  cpython-3.5.3.tar.gz  cpython-3.5.3.tar.bz2  Larry Hastings8 years
v3.5.3rc1cpython-3.5.3rc1.zip  cpython-3.5.3rc1.tar.gz  cpython-3.5.3rc1.tar.bz2  Larry Hastings8 years
v3.4.6rc1cpython-3.4.6rc1.zip  cpython-3.4.6rc1.tar.gz  cpython-3.4.6rc1.tar.bz2  Larry Hastings8 years
v3.6.0cpython-3.6.0.zip  cpython-3.6.0.tar.gz  cpython-3.6.0.tar.bz2  Ned Deily8 years
v2.7.13cpython-2.7.13.zip  cpython-2.7.13.tar.gz  cpython-2.7.13.tar.bz2  Benjamin Peterson8 years
v3.6.0rc2cpython-3.6.0rc2.zip  cpython-3.6.0rc2.tar.gz  cpython-3.6.0rc2.tar.bz2  Ned Deily8 years
v3.6.0rc1cpython-3.6.0rc1.zip  cpython-3.6.0rc1.tar.gz  cpython-3.6.0rc1.tar.bz2  Ned Deily8 years
v2.7.13rc1cpython-2.7.13rc1.zip  cpython-2.7.13rc1.tar.gz  cpython-2.7.13rc1.tar.bz2  Benjamin Peterson8 years
v3.6.0b4cpython-3.6.0b4.zip  cpython-3.6.0b4.tar.gz  cpython-3.6.0b4.tar.bz2  Ned Deily8 years
v3.6.0b3cpython-3.6.0b3.zip  cpython-3.6.0b3.tar.gz  cpython-3.6.0b3.tar.bz2  Ned Deily8 years
v3.6.0b2cpython-3.6.0b2.zip  cpython-3.6.0b2.tar.gz  cpython-3.6.0b2.tar.bz2  Ned Deily8 years
v3.6.0b1cpython-3.6.0b1.zip  cpython-3.6.0b1.tar.gz  cpython-3.6.0b1.tar.bz2  Ned Deily8 years
v3.6.0a4cpython-3.6.0a4.zip  cpython-3.6.0a4.tar.gz  cpython-3.6.0a4.tar.bz2  Ned Deily9 years
v3.6.0a3cpython-3.6.0a3.zip  cpython-3.6.0a3.tar.gz  cpython-3.6.0a3.tar.bz2  Ned Deily9 years
v3.4.5cpython-3.4.5.zip  cpython-3.4.5.tar.gz  cpython-3.4.5.tar.bz2  Larry Hastings9 years
v3.5.2cpython-3.5.2.zip  cpython-3.5.2.tar.gz  cpython-3.5.2.tar.bz2  Larry Hastings9 years
v2.7.12cpython-2.7.12.zip  cpython-2.7.12.tar.gz  cpython-2.7.12.tar.bz2  Benjamin Peterson9 years
v3.6.0a2cpython-3.6.0a2.zip  cpython-3.6.0a2.tar.gz  cpython-3.6.0a2.tar.bz2  Ned Deily9 years
v3.4.5rc1cpython-3.4.5rc1.zip  cpython-3.4.5rc1.tar.gz  cpython-3.4.5rc1.tar.bz2  Larry Hastings9 years
v3.5.2rc1cpython-3.5.2rc1.zip  cpython-3.5.2rc1.tar.gz  cpython-3.5.2rc1.tar.bz2  Larry Hastings9 years
v2.7.12rc1cpython-2.7.12rc1.zip  cpython-2.7.12rc1.tar.gz  cpython-2.7.12rc1.tar.bz2  Benjamin Peterson9 years
v3.6.0a1cpython-3.6.0a1.zip  cpython-3.6.0a1.tar.gz  cpython-3.6.0a1.tar.bz2  Ned Deily9 years
v3.4.4cpython-3.4.4.zip  cpython-3.4.4.tar.gz  cpython-3.4.4.tar.bz2  Larry Hastings9 years
v3.4.4rc1cpython-3.4.4rc1.zip  cpython-3.4.4rc1.tar.gz  cpython-3.4.4rc1.tar.bz2  Larry Hastings9 years
v3.5.1cpython-3.5.1.zip  cpython-3.5.1.tar.gz  cpython-3.5.1.tar.bz2  Larry Hastings9 years
v2.7.11cpython-2.7.11.zip  cpython-2.7.11.tar.gz  cpython-2.7.11.tar.bz2  Benjamin Peterson9 years
v3.5.1rc1cpython-3.5.1rc1.zip  cpython-3.5.1rc1.tar.gz  cpython-3.5.1rc1.tar.bz2  Larry Hastings9 years
v2.7.11rc1cpython-2.7.11rc1.zip  cpython-2.7.11rc1.tar.gz  cpython-2.7.11rc1.tar.bz2  Benjamin Peterson9 years
v3.5.0cpython-3.5.0.zip  cpython-3.5.0.tar.gz  cpython-3.5.0.tar.bz2  Larry Hastings9 years
v3.5.0rc4cpython-3.5.0rc4.zip  cpython-3.5.0rc4.tar.gz  cpython-3.5.0rc4.tar.bz2  Larry Hastings9 years
v3.5.0rc3cpython-3.5.0rc3.zip  cpython-3.5.0rc3.tar.gz  cpython-3.5.0rc3.tar.bz2  Larry Hastings9 years
v3.5.0rc2cpython-3.5.0rc2.zip  cpython-3.5.0rc2.tar.gz  cpython-3.5.0rc2.tar.bz2  Larry Hastings10 years
v3.5.0rc1cpython-3.5.0rc1.zip  cpython-3.5.0rc1.tar.gz  cpython-3.5.0rc1.tar.bz2  Larry Hastings10 years
v3.5.0b4cpython-3.5.0b4.zip  cpython-3.5.0b4.tar.gz  cpython-3.5.0b4.tar.bz2  Larry Hastings10 years
v3.5.0b3cpython-3.5.0b3.zip  cpython-3.5.0b3.tar.gz  cpython-3.5.0b3.tar.bz2  Larry Hastings10 years
v3.5.0b2cpython-3.5.0b2.zip  cpython-3.5.0b2.tar.gz  cpython-3.5.0b2.tar.bz2  Larry Hastings10 years
v3.5.0b1cpython-3.5.0b1.zip  cpython-3.5.0b1.tar.gz  cpython-3.5.0b1.tar.bz2  Larry Hastings10 years
v2.7.10cpython-2.7.10.zip  cpython-2.7.10.tar.gz  cpython-2.7.10.tar.bz2  Benjamin Peterson10 years
v2.7.10rc1cpython-2.7.10rc1.zip  cpython-2.7.10rc1.tar.gz  cpython-2.7.10rc1.tar.bz2  Benjamin Peterson10 years
v3.5.0a4cpython-3.5.0a4.zip  cpython-3.5.0a4.tar.gz  cpython-3.5.0a4.tar.bz2  Larry Hastings10 years
v3.5.0a3cpython-3.5.0a3.zip  cpython-3.5.0a3.tar.gz  cpython-3.5.0a3.tar.bz2  Larry Hastings10 years
v3.5.0a2cpython-3.5.0a2.zip  cpython-3.5.0a2.tar.gz  cpython-3.5.0a2.tar.bz2  Larry Hastings10 years
v3.4.3cpython-3.4.3.zip  cpython-3.4.3.tar.gz  cpython-3.4.3.tar.bz2  Larry Hastings10 years
v3.5.0a1cpython-3.5.0a1.zip  cpython-3.5.0a1.tar.gz  cpython-3.5.0a1.tar.bz2  Larry Hastings10 years
v3.4.3rc1cpython-3.4.3rc1.zip  cpython-3.4.3rc1.tar.gz  cpython-3.4.3rc1.tar.bz2  Larry Hastings10 years
v2.7.9cpython-2.7.9.zip  cpython-2.7.9.tar.gz  cpython-2.7.9.tar.bz2  Benjamin Peterson10 years
v2.7.9rc1cpython-2.7.9rc1.zip  cpython-2.7.9rc1.tar.gz  cpython-2.7.9rc1.tar.bz2  Benjamin Peterson10 years
v3.3.6cpython-3.3.6.zip  cpython-3.3.6.tar.gz  cpython-3.3.6.tar.bz2  Georg Brandl10 years
v3.2.6cpython-3.2.6.zip  cpython-3.2.6.tar.gz  cpython-3.2.6.tar.bz2  Georg Brandl10 years
v3.4.2cpython-3.4.2.zip  cpython-3.4.2.tar.gz  cpython-3.4.2.tar.bz2  Larry Hastings10 years
v3.2.6rc1cpython-3.2.6rc1.zip  cpython-3.2.6rc1.tar.gz  cpython-3.2.6rc1.tar.bz2  Georg Brandl10 years
v3.3.6rc1cpython-3.3.6rc1.zip  cpython-3.3.6rc1.tar.gz  cpython-3.3.6rc1.tar.bz2  Serhiy Storchaka10 years
v3.4.2rc1cpython-3.4.2rc1.zip  cpython-3.4.2rc1.tar.gz  cpython-3.4.2rc1.tar.bz2  Larry Hastings10 years
v2.7.8cpython-2.7.8.zip  cpython-2.7.8.tar.gz  cpython-2.7.8.tar.bz2  Benjamin Peterson11 years
v2.7.7cpython-2.7.7.zip  cpython-2.7.7.tar.gz  cpython-2.7.7.tar.bz2  Benjamin Peterson11 years
v3.4.1cpython-3.4.1.zip  cpython-3.4.1.tar.gz  cpython-3.4.1.tar.bz2  Larry Hastings11 years
v2.7.7rc1cpython-2.7.7rc1.zip  cpython-2.7.7rc1.tar.gz  cpython-2.7.7rc1.tar.bz2  Benjamin Peterson11 years
v3.4.1rc1cpython-3.4.1rc1.zip  cpython-3.4.1rc1.tar.gz  cpython-3.4.1rc1.tar.bz2  Larry Hastings11 years
v3.4.0cpython-3.4.0.zip  cpython-3.4.0.tar.gz  cpython-3.4.0.tar.bz2  Larry Hastings11 years
v3.4.0rc3cpython-3.4.0rc3.zip  cpython-3.4.0rc3.tar.gz  cpython-3.4.0rc3.tar.bz2  Larry Hastings11 years
v3.3.5cpython-3.3.5.zip  cpython-3.3.5.tar.gz  cpython-3.3.5.tar.bz2  Georg Brandl11 years
v3.3.5rc2cpython-3.3.5rc2.zip  cpython-3.3.5rc2.tar.gz  cpython-3.3.5rc2.tar.bz2  Georg Brandl11 years
v3.4.0rc2cpython-3.4.0rc2.zip  cpython-3.4.0rc2.tar.gz  cpython-3.4.0rc2.tar.bz2  Larry Hastings11 years
v3.3.5rc1cpython-3.3.5rc1.zip  cpython-3.3.5rc1.tar.gz  cpython-3.3.5rc1.tar.bz2  Georg Brandl11 years
v3.4.0rc1cpython-3.4.0rc1.zip  cpython-3.4.0rc1.tar.gz  cpython-3.4.0rc1.tar.bz2  Larry Hastings11 years
v3.3.4cpython-3.3.4.zip  cpython-3.3.4.tar.gz  cpython-3.3.4.tar.bz2  Georg Brandl11 years
v3.3.4rc1cpython-3.3.4rc1.zip  cpython-3.3.4rc1.tar.gz  cpython-3.3.4rc1.tar.bz2  Georg Brandl11 years
v3.4.0b3cpython-3.4.0b3.zip  cpython-3.4.0b3.tar.gz  cpython-3.4.0b3.tar.bz2  Larry Hastings11 years
v3.4.0b2cpython-3.4.0b2.zip  cpython-3.4.0b2.tar.gz  cpython-3.4.0b2.tar.bz2  Larry Hastings11 years
v3.4.0b1cpython-3.4.0b1.zip  cpython-3.4.0b1.tar.gz  cpython-3.4.0b1.tar.bz2  Larry Hastings11 years
v3.3.3cpython-3.3.3.zip  cpython-3.3.3.tar.gz  cpython-3.3.3.tar.bz2  Georg Brandl11 years
v3.3.3rc2cpython-3.3.3rc2.zip  cpython-3.3.3rc2.tar.gz  cpython-3.3.3rc2.tar.bz2  Georg Brandl11 years
v2.7.6cpython-2.7.6.zip  cpython-2.7.6.tar.gz  cpython-2.7.6.tar.bz2  Benjamin Peterson11 years
v2.6.9cpython-2.6.9.zip  cpython-2.6.9.tar.gz  cpython-2.6.9.tar.bz2  Barry Warsaw11 years
v3.3.3rc1cpython-3.3.3rc1.zip  cpython-3.3.3rc1.tar.gz  cpython-3.3.3rc1.tar.bz2  Georg Brandl11 years
v2.7.6rc1cpython-2.7.6rc1.zip  cpython-2.7.6rc1.tar.gz  cpython-2.7.6rc1.tar.bz2  Benjamin Peterson11 years
v3.4.0a4cpython-3.4.0a4.zip  cpython-3.4.0a4.tar.gz  cpython-3.4.0a4.tar.bz2  Larry Hastings11 years
v2.6.9rc1cpython-2.6.9rc1.zip  cpython-2.6.9rc1.tar.gz  cpython-2.6.9rc1.tar.bz2  Barry Warsaw11 years
v3.4.0a3cpython-3.4.0a3.zip  cpython-3.4.0a3.tar.gz  cpython-3.4.0a3.tar.bz2  Larry Hastings11 years
v3.4.0a2cpython-3.4.0a2.zip  cpython-3.4.0a2.tar.gz  cpython-3.4.0a2.tar.bz2  Larry Hastings11 years
v3.4.0a1cpython-3.4.0a1.zip  cpython-3.4.0a1.tar.gz  cpython-3.4.0a1.tar.bz2  Larry Hastings12 years
v3.3.2cpython-3.3.2.zip  cpython-3.3.2.tar.gz  cpython-3.3.2.tar.bz2  Georg Brandl12 years
v3.2.5cpython-3.2.5.zip  cpython-3.2.5.tar.gz  cpython-3.2.5.tar.bz2  Georg Brandl12 years
v2.7.5cpython-2.7.5.zip  cpython-2.7.5.tar.gz  cpython-2.7.5.tar.bz2  Benjamin Peterson12 years
v2.7.4cpython-2.7.4.zip  cpython-2.7.4.tar.gz  cpython-2.7.4.tar.bz2  Benjamin Peterson12 years
v3.3.1cpython-3.3.1.zip  cpython-3.3.1.tar.gz  cpython-3.3.1.tar.bz2  Georg Brandl12 years
v3.2.4cpython-3.2.4.zip  cpython-3.2.4.tar.gz  cpython-3.2.4.tar.bz2  Georg Brandl12 years
v3.3.1rc1cpython-3.3.1rc1.zip  cpython-3.3.1rc1.tar.gz  cpython-3.3.1rc1.tar.bz2  Georg Brandl12 years
v3.2.4rc1cpython-3.2.4rc1.zip  cpython-3.2.4rc1.tar.gz  cpython-3.2.4rc1.tar.bz2  Georg Brandl12 years
v2.7.4rc1cpython-2.7.4rc1.zip  cpython-2.7.4rc1.tar.gz  cpython-2.7.4rc1.tar.bz2  Benjamin Peterson12 years
v3.3.0cpython-3.3.0.zip  cpython-3.3.0.tar.gz  cpython-3.3.0.tar.bz2  Georg Brandl12 years
v3.3.0rc3cpython-3.3.0rc3.zip  cpython-3.3.0rc3.tar.gz  cpython-3.3.0rc3.tar.bz2  Georg Brandl12 years
v3.3.0rc2cpython-3.3.0rc2.zip  cpython-3.3.0rc2.tar.gz  cpython-3.3.0rc2.tar.bz2  Stefan Krah12 years
v3.3.0rc1cpython-3.3.0rc1.zip  cpython-3.3.0rc1.tar.gz  cpython-3.3.0rc1.tar.bz2  Georg Brandl13 years
v3.3.0b2cpython-3.3.0b2.zip  cpython-3.3.0b2.tar.gz  cpython-3.3.0b2.tar.bz2  Georg Brandl13 years
v3.3.0b1cpython-3.3.0b1.zip  cpython-3.3.0b1.tar.gz  cpython-3.3.0b1.tar.bz2  Georg Brandl13 years
v3.3.0a4cpython-3.3.0a4.zip  cpython-3.3.0a4.tar.gz  cpython-3.3.0a4.tar.bz2  Georg Brandl13 years
v3.3.0a3cpython-3.3.0a3.zip  cpython-3.3.0a3.tar.gz  cpython-3.3.0a3.tar.bz2  Georg Brandl13 years
v3.2.3cpython-3.2.3.zip  cpython-3.2.3.tar.gz  cpython-3.2.3.tar.bz2  Georg Brandl13 years
v2.6.8cpython-2.6.8.zip  cpython-2.6.8.tar.gz  cpython-2.6.8.tar.bz2  Barry Warsaw13 years
v2.7.3cpython-2.7.3.zip  cpython-2.7.3.tar.gz  cpython-2.7.3.tar.bz2  Benjamin Peterson13 years
v3.1.5cpython-3.1.5.zip  cpython-3.1.5.tar.gz  cpython-3.1.5.tar.bz2  Benjamin Peterson13 years
v3.3.0a2cpython-3.3.0a2.zip  cpython-3.3.0a2.tar.gz  cpython-3.3.0a2.tar.bz2  Georg Brandl13 years
v3.2.3rc2cpython-3.2.3rc2.zip  cpython-3.2.3rc2.tar.gz  cpython-3.2.3rc2.tar.bz2  Georg Brandl13 years
v2.6.8rc2cpython-2.6.8rc2.zip  cpython-2.6.8rc2.tar.gz  cpython-2.6.8rc2.tar.bz2  Barry Warsaw13 years
v3.1.5rc2cpython-3.1.5rc2.zip  cpython-3.1.5rc2.tar.gz  cpython-3.1.5rc2.tar.bz2  Benjamin Peterson13 years
v2.7.3rc2cpython-2.7.3rc2.zip  cpython-2.7.3rc2.tar.gz  cpython-2.7.3rc2.tar.bz2  Benjamin Peterson13 years
v3.3.0a1cpython-3.3.0a1.zip  cpython-3.3.0a1.tar.gz  cpython-3.3.0a1.tar.bz2  Georg Brandl13 years
v3.2.3rc1cpython-3.2.3rc1.zip  cpython-3.2.3rc1.tar.gz  cpython-3.2.3rc1.tar.bz2  Georg Brandl13 years
v2.6.8rc1cpython-2.6.8rc1.zip  cpython-2.6.8rc1.tar.gz  cpython-2.6.8rc1.tar.bz2  Barry Warsaw13 years
v2.7.3rc1cpython-2.7.3rc1.zip  cpython-2.7.3rc1.tar.gz  cpython-2.7.3rc1.tar.bz2  Benjamin Peterson13 years
v3.1.5rc1cpython-3.1.5rc1.zip  cpython-3.1.5rc1.tar.gz  cpython-3.1.5rc1.tar.bz2  Benjamin Peterson13 years
v3.2.2cpython-3.2.2.zip  cpython-3.2.2.tar.gz  cpython-3.2.2.tar.bz2  Antoine Pitrou14 years
v3.2.2rc1cpython-3.2.2rc1.zip  cpython-3.2.2rc1.tar.gz  cpython-3.2.2rc1.tar.bz2  Georg Brandl14 years
v3.2.1cpython-3.2.1.zip  cpython-3.2.1.tar.gz  cpython-3.2.1.tar.bz2  Georg Brandl14 years
v3.2.1rc2cpython-3.2.1rc2.zip  cpython-3.2.1rc2.tar.gz  cpython-3.2.1rc2.tar.bz2  Georg Brandl14 years
v3.1.4cpython-3.1.4.zip  cpython-3.1.4.tar.gz  cpython-3.1.4.tar.bz2  Benjamin Peterson14 years
v2.7.2cpython-2.7.2.zip  cpython-2.7.2.tar.gz  cpython-2.7.2.tar.bz2  Benjamin Peterson14 years
v2.6.7cpython-2.6.7.zip  cpython-2.6.7.tar.gz  cpython-2.6.7.tar.bz2  Barry Warsaw14 years
v2.7.2rc1cpython-2.7.2rc1.zip  cpython-2.7.2rc1.tar.gz  cpython-2.7.2rc1.tar.bz2  Benjamin Peterson14 years
v3.1.4rc1cpython-3.1.4rc1.zip  cpython-3.1.4rc1.tar.gz  cpython-3.1.4rc1.tar.bz2  Benjamin Peterson14 years
v2.5.6cpython-2.5.6.zip  cpython-2.5.6.tar.gz  cpython-2.5.6.tar.bz2  Martin v. Löwis14 years
v2.5.6c1cpython-2.5.6c1.zip  cpython-2.5.6c1.tar.gz  cpython-2.5.6c1.tar.bz2  Martin v. Löwis14 years
v3.2.1rc1cpython-3.2.1rc1.zip  cpython-3.2.1rc1.tar.gz  cpython-3.2.1rc1.tar.bz2  Georg Brandl14 years
v3.2.1b1cpython-3.2.1b1.zip  cpython-3.2.1b1.tar.gz  cpython-3.2.1b1.tar.bz2  Georg Brandl14 years
v3.2cpython-3.2.zip  cpython-3.2.tar.gz  cpython-3.2.tar.bz2  Georg Brandl14 years
v3.2rc3cpython-3.2rc3.zip  cpython-3.2rc3.tar.gz  cpython-3.2rc3.tar.bz2  Georg Brandl14 years
v3.2rc2cpython-3.2rc2.zip  cpython-3.2rc2.tar.gz  cpython-3.2rc2.tar.bz2  Georg Brandl14 years
v3.2rc1cpython-3.2rc1.zip  cpython-3.2rc1.tar.gz  cpython-3.2rc1.tar.bz2  Antoine Pitrou14 years
v3.2b2cpython-3.2b2.zip  cpython-3.2b2.tar.gz  cpython-3.2b2.tar.bz2  Georg Brandl14 years
v3.2b1cpython-3.2b1.zip  cpython-3.2b1.tar.gz  cpython-3.2b1.tar.bz2  Georg Brandl14 years
v3.1.3cpython-3.1.3.zip  cpython-3.1.3.tar.gz  cpython-3.1.3.tar.bz2  Benjamin Peterson14 years
v2.7.1cpython-2.7.1.zip  cpython-2.7.1.tar.gz  cpython-2.7.1.tar.bz2  Benjamin Peterson14 years
v2.7.1rc1cpython-2.7.1rc1.zip  cpython-2.7.1rc1.tar.gz  cpython-2.7.1rc1.tar.bz2  Benjamin Peterson14 years
v3.1.3rc1cpython-3.1.3rc1.zip  cpython-3.1.3rc1.tar.gz  cpython-3.1.3rc1.tar.bz2  Benjamin Peterson14 years
v3.2a4cpython-3.2a4.zip  cpython-3.2a4.tar.gz  cpython-3.2a4.tar.bz2  Georg Brandl14 years
v3.2a3cpython-3.2a3.zip  cpython-3.2a3.tar.gz  cpython-3.2a3.tar.bz2  Georg Brandl14 years
v3.2a2cpython-3.2a2.zip  cpython-3.2a2.tar.gz  cpython-3.2a2.tar.bz2  Éric Araujo15 years
v2.6.6cpython-2.6.6.zip  cpython-2.6.6.tar.gz  cpython-2.6.6.tar.bz2  Barry Warsaw15 years
v2.6.6rc2cpython-2.6.6rc2.zip  cpython-2.6.6rc2.tar.gz  cpython-2.6.6rc2.tar.bz2  Barry Warsaw15 years
v2.6.6rc1cpython-2.6.6rc1.zip  cpython-2.6.6rc1.tar.gz  cpython-2.6.6rc1.tar.bz2  Barry Warsaw15 years
v3.2a1cpython-3.2a1.zip  cpython-3.2a1.tar.gz  cpython-3.2a1.tar.bz2  Georg Brandl15 years
v2.7cpython-2.7.zip  cpython-2.7.tar.gz  cpython-2.7.tar.bz2  Benjamin Peterson15 years
v2.7rc2cpython-2.7rc2.zip  cpython-2.7rc2.tar.gz  cpython-2.7rc2.tar.bz2  Benjamin Peterson15 years
v2.7rc1cpython-2.7rc1.zip  cpython-2.7rc1.tar.gz  cpython-2.7rc1.tar.bz2  Benjamin Peterson15 years
v2.7b2cpython-2.7b2.zip  cpython-2.7b2.tar.gz  cpython-2.7b2.tar.bz2  Benjamin Peterson15 years
v2.7b1cpython-2.7b1.zip  cpython-2.7b1.tar.gz  cpython-2.7b1.tar.bz2  Benjamin Peterson15 years
v3.1.2cpython-3.1.2.zip  cpython-3.1.2.tar.gz  cpython-3.1.2.tar.bz2  Benjamin Peterson15 years
v2.6.5cpython-2.6.5.zip  cpython-2.6.5.tar.gz  cpython-2.6.5.tar.bz2  Barry Warsaw15 years
v2.6.5rc2cpython-2.6.5rc2.zip  cpython-2.6.5rc2.tar.gz  cpython-2.6.5rc2.tar.bz2  Barry Warsaw15 years
v3.1.2rc1cpython-3.1.2rc1.zip  cpython-3.1.2rc1.tar.gz  cpython-3.1.2rc1.tar.bz2  Benjamin Peterson15 years
v2.7a4cpython-2.7a4.zip  cpython-2.7a4.tar.gz  cpython-2.7a4.tar.bz2  Benjamin Peterson15 years
v2.6.5rc1cpython-2.6.5rc1.zip  cpython-2.6.5rc1.tar.gz  cpython-2.6.5rc1.tar.bz2  Barry Warsaw15 years
v2.7a3cpython-2.7a3.zip  cpython-2.7a3.tar.gz  cpython-2.7a3.tar.bz2  Benjamin Peterson15 years
v2.5.5cpython-2.5.5.zip  cpython-2.5.5.tar.gz  cpython-2.5.5.tar.bz2  Martin v. Löwis15 years
v2.5.5c2cpython-2.5.5c2.zip  cpython-2.5.5c2.tar.gz  cpython-2.5.5c2.tar.bz2  Martin v. Löwis15 years
v2.5.5c1cpython-2.5.5c1.zip  cpython-2.5.5c1.tar.gz  cpython-2.5.5c1.tar.bz2  Martin v. Löwis15 years
v2.7a2cpython-2.7a2.zip  cpython-2.7a2.tar.gz  cpython-2.7a2.tar.bz2  Benjamin Peterson15 years
v2.7a1cpython-2.7a1.zip  cpython-2.7a1.tar.gz  cpython-2.7a1.tar.bz2  Benjamin Peterson15 years
v2.6.4cpython-2.6.4.zip  cpython-2.6.4.tar.gz  cpython-2.6.4.tar.bz2  Barry Warsaw15 years
v2.6.4rc2cpython-2.6.4rc2.zip  cpython-2.6.4rc2.tar.gz  cpython-2.6.4rc2.tar.bz2  Barry Warsaw15 years
v2.6.4rc1cpython-2.6.4rc1.zip  cpython-2.6.4rc1.tar.gz  cpython-2.6.4rc1.tar.bz2  Barry Warsaw15 years
v2.6.3cpython-2.6.3.zip  cpython-2.6.3.tar.gz  cpython-2.6.3.tar.bz2  Barry Warsaw15 years
v2.6.3rc1cpython-2.6.3rc1.zip  cpython-2.6.3rc1.tar.gz  cpython-2.6.3rc1.tar.bz2  Barry Warsaw15 years
v3.1.1cpython-3.1.1.zip  cpython-3.1.1.tar.gz  cpython-3.1.1.tar.bz2  Benjamin Peterson16 years
v3.1.1rc1cpython-3.1.1rc1.zip  cpython-3.1.1rc1.tar.gz  cpython-3.1.1rc1.tar.bz2  Benjamin Peterson16 years
v3.1cpython-3.1.zip  cpython-3.1.tar.gz  cpython-3.1.tar.bz2  Benjamin Peterson16 years
v3.1rc2cpython-3.1rc2.zip  cpython-3.1rc2.tar.gz  cpython-3.1rc2.tar.bz2  Benjamin Peterson16 years
v3.1rc1cpython-3.1rc1.zip  cpython-3.1rc1.tar.gz  cpython-3.1rc1.tar.bz2  Benjamin Peterson16 years
v3.1b1cpython-3.1b1.zip  cpython-3.1b1.tar.gz  cpython-3.1b1.tar.bz2  Benjamin Peterson16 years
v2.6.2cpython-2.6.2.zip  cpython-2.6.2.tar.gz  cpython-2.6.2.tar.bz2  Barry Warsaw16 years
v2.6.2c1cpython-2.6.2c1.zip  cpython-2.6.2c1.tar.gz  cpython-2.6.2c1.tar.bz2  Barry Warsaw16 years
v3.1a2cpython-3.1a2.zip  cpython-3.1a2.tar.gz  cpython-3.1a2.tar.bz2  Benjamin Peterson16 years
v3.1a1cpython-3.1a1.zip  cpython-3.1a1.tar.gz  cpython-3.1a1.tar.bz2  Benjamin Peterson16 years
v3.0.1cpython-3.0.1.zip  cpython-3.0.1.tar.gz  cpython-3.0.1.tar.bz2  Barry Warsaw16 years
v2.5.4cpython-2.5.4.zip  cpython-2.5.4.tar.gz  cpython-2.5.4.tar.bz2  Martin v. Löwis16 years
v2.5.3cpython-2.5.3.zip  cpython-2.5.3.tar.gz  cpython-2.5.3.tar.bz2  Martin v. Löwis16 years
v2.4.6cpython-2.4.6.zip  cpython-2.4.6.tar.gz  cpython-2.4.6.tar.bz2  Martin v. Löwis16 years
v2.5.3c1cpython-2.5.3c1.zip  cpython-2.5.3c1.tar.gz  cpython-2.5.3c1.tar.bz2  Martin v. Löwis16 years
v2.4.6c1cpython-2.4.6c1.zip  cpython-2.4.6c1.tar.gz  cpython-2.4.6c1.tar.bz2  Martin v. Löwis16 years
v2.6.1cpython-2.6.1.zip  cpython-2.6.1.tar.gz  cpython-2.6.1.tar.bz2  Barry Warsaw16 years
v3.0cpython-3.0.zip  cpython-3.0.tar.gz  cpython-3.0.tar.bz2  Barry Warsaw16 years
v3.0rc3cpython-3.0rc3.zip  cpython-3.0rc3.tar.gz  cpython-3.0rc3.tar.bz2  Barry Warsaw16 years
v3.0rc2cpython-3.0rc2.zip  cpython-3.0rc2.tar.gz  cpython-3.0rc2.tar.bz2  Barry Warsaw16 years
v2.6cpython-2.6.zip  cpython-2.6.tar.gz  cpython-2.6.tar.bz2  Barry Warsaw16 years
v2.6rc2cpython-2.6rc2.zip  cpython-2.6rc2.tar.gz  cpython-2.6rc2.tar.bz2  Barry Warsaw16 years
v3.0rc1cpython-3.0rc1.zip  cpython-3.0rc1.tar.gz  cpython-3.0rc1.tar.bz2  Barry Warsaw16 years
v2.6rc1cpython-2.6rc1.zip  cpython-2.6rc1.tar.gz  cpython-2.6rc1.tar.bz2  Barry Warsaw16 years
v3.0b3cpython-3.0b3.zip  cpython-3.0b3.tar.gz  cpython-3.0b3.tar.bz2  Barry Warsaw17 years
v2.6b3cpython-2.6b3.zip  cpython-2.6b3.tar.gz  cpython-2.6b3.tar.bz2  Barry Warsaw17 years
v2.6b2cpython-2.6b2.zip  cpython-2.6b2.tar.gz  cpython-2.6b2.tar.bz2  Barry Warsaw17 years
v3.0b2cpython-3.0b2.zip  cpython-3.0b2.tar.gz  cpython-3.0b2.tar.bz2  Barry Warsaw17 years
v2.6b1cpython-2.6b1.zip  cpython-2.6b1.tar.gz  cpython-2.6b1.tar.bz2  Barry Warsaw17 years
v3.0b1cpython-3.0b1.zip  cpython-3.0b1.tar.gz  cpython-3.0b1.tar.bz2  Barry Warsaw17 years
v2.6a3cpython-2.6a3.zip  cpython-2.6a3.tar.gz  cpython-2.6a3.tar.bz2  Barry Warsaw17 years
v3.0a5cpython-3.0a5.zip  cpython-3.0a5.tar.gz  cpython-3.0a5.tar.bz2  Barry Warsaw17 years
v2.6a2cpython-2.6a2.zip  cpython-2.6a2.tar.gz  cpython-2.6a2.tar.bz2  Barry Warsaw17 years
v3.0a4cpython-3.0a4.zip  cpython-3.0a4.tar.gz  cpython-3.0a4.tar.bz2  Barry Warsaw17 years
v2.3.7cpython-2.3.7.zip  cpython-2.3.7.tar.gz  cpython-2.3.7.tar.bz2  Martin v. Löwis17 years
v2.4.5cpython-2.4.5.zip  cpython-2.4.5.tar.gz  cpython-2.4.5.tar.bz2  Martin v. Löwis17 years
v2.3.7c1cpython-2.3.7c1.zip  cpython-2.3.7c1.tar.gz  cpython-2.3.7c1.tar.bz2  Martin v. Löwis17 years
v2.4.5c1cpython-2.4.5c1.zip  cpython-2.4.5c1.tar.gz  cpython-2.4.5c1.tar.bz2  Martin v. Löwis17 years
v3.0a3cpython-3.0a3.zip  cpython-3.0a3.tar.gz  cpython-3.0a3.tar.bz2  Barry Warsaw17 years
v2.6a1cpython-2.6a1.zip  cpython-2.6a1.tar.gz  cpython-2.6a1.tar.bz2  Barry Warsaw17 years
v2.5.2cpython-2.5.2.zip  cpython-2.5.2.tar.gz  cpython-2.5.2.tar.bz2  Martin v. Löwis17 years
v2.5.2c1cpython-2.5.2c1.zip  cpython-2.5.2c1.tar.gz  cpython-2.5.2c1.tar.bz2  Martin v. Löwis17 years
v3.0a2cpython-3.0a2.zip  cpython-3.0a2.tar.gz  cpython-3.0a2.tar.bz2  Guido van Rossum17 years
v3.0a1cpython-3.0a1.zip  cpython-3.0a1.tar.gz  cpython-3.0a1.tar.bz2  Guido van Rossum18 years
v2.5.1cpython-2.5.1.zip  cpython-2.5.1.tar.gz  cpython-2.5.1.tar.bz2  Anthony Baxter18 years
v2.5.1c1cpython-2.5.1c1.zip  cpython-2.5.1c1.tar.gz  cpython-2.5.1c1.tar.bz2  Neal Norwitz18 years
v2.3.6cpython-2.3.6.zip  cpython-2.3.6.tar.gz  cpython-2.3.6.tar.bz2  Anthony Baxter18 years
v2.3.6c1cpython-2.3.6c1.zip  cpython-2.3.6c1.tar.gz  cpython-2.3.6c1.tar.bz2  Anthony Baxter18 years
v2.4.4cpython-2.4.4.zip  cpython-2.4.4.tar.gz  cpython-2.4.4.tar.bz2  Anthony Baxter18 years
v2.4.4c1cpython-2.4.4c1.zip  cpython-2.4.4c1.tar.gz  cpython-2.4.4c1.tar.bz2  Anthony Baxter18 years
v2.5cpython-2.5.zip  cpython-2.5.tar.gz  cpython-2.5.tar.bz2  Anthony Baxter18 years
v2.5c2cpython-2.5c2.zip  cpython-2.5c2.tar.gz  cpython-2.5c2.tar.bz2  Anthony Baxter18 years
v2.5c1cpython-2.5c1.zip  cpython-2.5c1.tar.gz  cpython-2.5c1.tar.bz2  Anthony Baxter19 years
v2.5b3cpython-2.5b3.zip  cpython-2.5b3.tar.gz  cpython-2.5b3.tar.bz2  Tim Peters19 years
v2.5b2cpython-2.5b2.zip  cpython-2.5b2.tar.gz  cpython-2.5b2.tar.bz2  Tim Peters19 years
v2.5b1cpython-2.5b1.zip  cpython-2.5b1.tar.gz  cpython-2.5b1.tar.bz2  Trent Mick19 years
v2.5a2cpython-2.5a2.zip  cpython-2.5a2.tar.gz  cpython-2.5a2.tar.bz2  Anthony Baxter19 years
v2.5a1cpython-2.5a1.zip  cpython-2.5a1.tar.gz  cpython-2.5a1.tar.bz2  Neal Norwitz19 years
v2.5a0cpython-2.5a0.zip  cpython-2.5a0.tar.gz  cpython-2.5a0.tar.bz2  Martin v. Löwis19 years
v2.4.3cpython-2.4.3.zip  cpython-2.4.3.tar.gz  cpython-2.4.3.tar.bz2  Hye-Shik Chang19 years
v2.4.3c1cpython-2.4.3c1.zip  cpython-2.4.3c1.tar.gz  cpython-2.4.3c1.tar.bz2  Anthony Baxter19 years
v2.4.2cpython-2.4.2.zip  cpython-2.4.2.tar.gz  cpython-2.4.2.tar.bz2  cvs2svn19 years
v2.4.2c1cpython-2.4.2c1.zip  cpython-2.4.2c1.tar.gz  cpython-2.4.2c1.tar.bz2  cvs2svn19 years
v2.4.1cpython-2.4.1.zip  cpython-2.4.1.tar.gz  cpython-2.4.1.tar.bz2  cvs2svn20 years
v2.4.1c2cpython-2.4.1c2.zip  cpython-2.4.1c2.tar.gz  cpython-2.4.1c2.tar.bz2  cvs2svn20 years
v2.4.1c1cpython-2.4.1c1.zip  cpython-2.4.1c1.tar.gz  cpython-2.4.1c1.tar.bz2  cvs2svn20 years
v2.3.5cpython-2.3.5.zip  cpython-2.3.5.tar.gz  cpython-2.3.5.tar.bz2  cvs2svn20 years
v2.3.5c1cpython-2.3.5c1.zip  cpython-2.3.5c1.tar.gz  cpython-2.3.5c1.tar.bz2  cvs2svn20 years
v2.4cpython-2.4.zip  cpython-2.4.tar.gz  cpython-2.4.tar.bz2  cvs2svn20 years
v2.4c1cpython-2.4c1.zip  cpython-2.4c1.tar.gz  cpython-2.4c1.tar.bz2  cvs2svn20 years
v2.4b2cpython-2.4b2.zip  cpython-2.4b2.tar.gz  cpython-2.4b2.tar.bz2  cvs2svn20 years
v2.4b1cpython-2.4b1.zip  cpython-2.4b1.tar.gz  cpython-2.4b1.tar.bz2  cvs2svn20 years
v2.4a3cpython-2.4a3.zip  cpython-2.4a3.tar.gz  cpython-2.4a3.tar.bz2  cvs2svn21 years
v2.4a2cpython-2.4a2.zip  cpython-2.4a2.tar.gz  cpython-2.4a2.tar.bz2  cvs2svn21 years
v2.4a1cpython-2.4a1.zip  cpython-2.4a1.tar.gz  cpython-2.4a1.tar.bz2  cvs2svn21 years
v2.3.4cpython-2.3.4.zip  cpython-2.3.4.tar.gz  cpython-2.3.4.tar.bz2  cvs2svn21 years
v2.3.4c1cpython-2.3.4c1.zip  cpython-2.3.4c1.tar.gz  cpython-2.3.4c1.tar.bz2  cvs2svn21 years
v2.3.3cpython-2.3.3.zip  cpython-2.3.3.tar.gz  cpython-2.3.3.tar.bz2  cvs2svn21 years
v2.3.3c1cpython-2.3.3c1.zip  cpython-2.3.3c1.tar.gz  cpython-2.3.3c1.tar.bz2  cvs2svn21 years
v2.3.2cpython-2.3.2.zip  cpython-2.3.2.tar.gz  cpython-2.3.2.tar.bz2  cvs2svn21 years
v2.3.2c1cpython-2.3.2c1.zip  cpython-2.3.2c1.tar.gz  cpython-2.3.2c1.tar.bz2  cvs2svn21 years
v2.3.1cpython-2.3.1.zip  cpython-2.3.1.tar.gz  cpython-2.3.1.tar.bz2  cvs2svn21 years
v2.3c2cpython-2.3c2.zip  cpython-2.3c2.tar.gz  cpython-2.3c2.tar.bz2  cvs2svn22 years
v2.3c1cpython-2.3c1.zip  cpython-2.3c1.tar.gz  cpython-2.3c1.tar.bz2  cvs2svn22 years
v2.2.3cpython-2.2.3.zip  cpython-2.2.3.tar.gz  cpython-2.2.3.tar.bz2  cvs2svn22 years
v2.2.3c1cpython-2.2.3c1.zip  cpython-2.2.3c1.tar.gz  cpython-2.2.3c1.tar.bz2  cvs2svn22 years
v2.2.2cpython-2.2.2.zip  cpython-2.2.2.tar.gz  cpython-2.2.2.tar.bz2  cvs2svn22 years
v2.2.2b1cpython-2.2.2b1.zip  cpython-2.2.2b1.tar.gz  cpython-2.2.2b1.tar.bz2  cvs2svn22 years
v2.2.1cpython-2.2.1.zip  cpython-2.2.1.tar.gz  cpython-2.2.1.tar.bz2  cvs2svn23 years
v2.1.3cpython-2.1.3.zip  cpython-2.1.3.tar.gz  cpython-2.1.3.tar.bz2  cvs2svn23 years
v2.2cpython-2.2.zip  cpython-2.2.tar.gz  cpython-2.2.tar.bz2  cvs2svn23 years
v2.2.1c2cpython-2.2.1c2.zip  cpython-2.2.1c2.tar.gz  cpython-2.2.1c2.tar.bz2  cvs2svn23 years
v2.2.1c1cpython-2.2.1c1.zip  cpython-2.2.1c1.tar.gz  cpython-2.2.1c1.tar.bz2  cvs2svn23 years
v2.1.2cpython-2.1.2.zip  cpython-2.1.2.tar.gz  cpython-2.1.2.tar.bz2  cvs2svn23 years
v2.1.2c1cpython-2.1.2c1.zip  cpython-2.1.2c1.tar.gz  cpython-2.1.2c1.tar.bz2  cvs2svn23 years
v2.2a3cpython-2.2a3.zip  cpython-2.2a3.tar.gz  cpython-2.2a3.tar.bz2  cvs2svn23 years
v2.1.1cpython-2.1.1.zip  cpython-2.1.1.tar.gz  cpython-2.1.1.tar.bz2  cvs2svn24 years
v2.1.1c1cpython-2.1.1c1.zip  cpython-2.1.1c1.tar.gz  cpython-2.1.1c1.tar.bz2  cvs2svn24 years
v2.0.1cpython-2.0.1.zip  cpython-2.0.1.tar.gz  cpython-2.0.1.tar.bz2  cvs2svn24 years
v2.0.1c1cpython-2.0.1c1.zip  cpython-2.0.1c1.tar.gz  cpython-2.0.1c1.tar.bz2  cvs2svn24 years
v2.1cpython-2.1.zip  cpython-2.1.tar.gz  cpython-2.1.tar.bz2  cvs2svn24 years
v2.1c2cpython-2.1c2.zip  cpython-2.1c2.tar.gz  cpython-2.1c2.tar.bz2  cvs2svn24 years
v2.1c1cpython-2.1c1.zip  cpython-2.1c1.tar.gz  cpython-2.1c1.tar.bz2  cvs2svn24 years
v2.1b2cpython-2.1b2.zip  cpython-2.1b2.tar.gz  cpython-2.1b2.tar.bz2  cvs2svn24 years
v2.1b1cpython-2.1b1.zip  cpython-2.1b1.tar.gz  cpython-2.1b1.tar.bz2  cvs2svn24 years
v2.1a2cpython-2.1a2.zip  cpython-2.1a2.tar.gz  cpython-2.1a2.tar.bz2  cvs2svn24 years
v2.1a1cpython-2.1a1.zip  cpython-2.1a1.tar.gz  cpython-2.1a1.tar.bz2  cvs2svn24 years
v2.0cpython-2.0.zip  cpython-2.0.tar.gz  cpython-2.0.tar.bz2  cvs2svn24 years
v2.0c1cpython-2.0c1.zip  cpython-2.0c1.tar.gz  cpython-2.0c1.tar.bz2  cvs2svn24 years
v2.0b2cpython-2.0b2.zip  cpython-2.0b2.tar.gz  cpython-2.0b2.tar.bz2  cvs2svn24 years
v2.0b1cpython-2.0b1.zip  cpython-2.0b1.tar.gz  cpython-2.0b1.tar.bz2  cvs2svn25 years
v1.6a2cpython-1.6a2.zip  cpython-1.6a2.tar.gz  cpython-1.6a2.tar.bz2  cvs2svn25 years
v1.6a1cpython-1.6a1.zip  cpython-1.6a1.tar.gz  cpython-1.6a1.tar.bz2  cvs2svn25 years
v1.5.2cpython-1.5.2.zip  cpython-1.5.2.tar.gz  cpython-1.5.2.tar.bz2  cvs2svn26 years
v1.5.2c1cpython-1.5.2c1.zip  cpython-1.5.2c1.tar.gz  cpython-1.5.2c1.tar.bz2  cvs2svn26 years
v1.5.2b2cpython-1.5.2b2.zip  cpython-1.5.2b2.tar.gz  cpython-1.5.2b2.tar.bz2  cvs2svn26 years
v1.5.2b1cpython-1.5.2b1.zip  cpython-1.5.2b1.tar.gz  cpython-1.5.2b1.tar.bz2  cvs2svn26 years
v1.5.2a2cpython-1.5.2a2.zip  cpython-1.5.2a2.tar.gz  cpython-1.5.2a2.tar.bz2  cvs2svn26 years
v1.5.2a1cpython-1.5.2a1.zip  cpython-1.5.2a1.tar.gz  cpython-1.5.2a1.tar.bz2  cvs2svn27 years
v1.5.1cpython-1.5.1.zip  cpython-1.5.1.tar.gz  cpython-1.5.1.tar.bz2  cvs2svn27 years
v1.5cpython-1.5.zip  cpython-1.5.tar.gz  cpython-1.5.tar.bz2  cvs2svn27 years
v1.5b2cpython-1.5b2.zip  cpython-1.5b2.tar.gz  cpython-1.5b2.tar.bz2  cvs2svn27 years
v1.5b1cpython-1.5b1.zip  cpython-1.5b1.tar.gz  cpython-1.5b1.tar.bz2  cvs2svn27 years
v1.5a4cpython-1.5a4.zip  cpython-1.5a4.tar.gz  cpython-1.5a4.tar.bz2  cvs2svn27 years
v1.5a3cpython-1.5a3.zip  cpython-1.5a3.tar.gz  cpython-1.5a3.tar.bz2  cvs2svn28 years
v1.5a2cpython-1.5a2.zip  cpython-1.5a2.tar.gz  cpython-1.5a2.tar.bz2  cvs2svn28 years
v1.5a1cpython-1.5a1.zip  cpython-1.5a1.tar.gz  cpython-1.5a1.tar.bz2  cvs2svn28 years
v1.4cpython-1.4.zip  cpython-1.4.tar.gz  cpython-1.4.tar.bz2  cvs2svn28 years
v1.4b3cpython-1.4b3.zip  cpython-1.4b3.tar.gz  cpython-1.4b3.tar.bz2  cvs2svn29 years
v1.4b2cpython-1.4b2.zip  cpython-1.4b2.tar.gz  cpython-1.4b2.tar.bz2  cvs2svn29 years
v1.4b1cpython-1.4b1.zip  cpython-1.4b1.tar.gz  cpython-1.4b1.tar.bz2  cvs2svn29 years
v1.3cpython-1.3.zip  cpython-1.3.tar.gz  cpython-1.3.tar.bz2  cvs2svn29 years
v1.3b1cpython-1.3b1.zip  cpython-1.3b1.tar.gz  cpython-1.3b1.tar.bz2  cvs2svn30 years
v1.2cpython-1.2.zip  cpython-1.2.tar.gz  cpython-1.2.tar.bz2  cvs2svn30 years
v1.2b4cpython-1.2b4.zip  cpython-1.2b4.tar.gz  cpython-1.2b4.tar.bz2  cvs2svn30 years
v1.2b3cpython-1.2b3.zip  cpython-1.2b3.tar.gz  cpython-1.2b3.tar.bz2  cvs2svn30 years
v1.2b2cpython-1.2b2.zip  cpython-1.2b2.tar.gz  cpython-1.2b2.tar.bz2  cvs2svn30 years
v1.2b1cpython-1.2b1.zip  cpython-1.2b1.tar.gz  cpython-1.2b1.tar.bz2  cvs2svn30 years
v1.1.1cpython-1.1.1.zip  cpython-1.1.1.tar.gz  cpython-1.1.1.tar.bz2  cvs2svn30 years
v1.1cpython-1.1.zip  cpython-1.1.tar.gz  cpython-1.1.tar.bz2  cvs2svn30 years
v1.0.2cpython-1.0.2.zip  cpython-1.0.2.tar.gz  cpython-1.0.2.tar.bz2  cvs2svn31 years
v1.0.1cpython-1.0.1.zip  cpython-1.0.1.tar.gz  cpython-1.0.1.tar.bz2  cvs2svn31 years
v0.9.9cpython-0.9.9.zip  cpython-0.9.9.tar.gz  cpython-0.9.9.tar.bz2  cvs2svn32 years
v0.9.8cpython-0.9.8.zip  cpython-0.9.8.tar.gz  cpython-0.9.8.tar.bz2  cvs2svn32 years
tudio10Generator::GetCSharpFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { return "v142"; @@ -1538,7 +1540,7 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1557,7 +1559,7 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1576,7 +1578,7 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { return "v142"; @@ -1598,7 +1600,7 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( std::string const& toolset) const { - std::string const useToolset = this->GetToolsetName(toolset); + std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || (useToolset == "v142")) { @@ -1614,7 +1616,7 @@ std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetToolsetName( +std::string cmGlobalVisualStudio10Generator::CanonicalToolsetName( std::string const& toolset) const { std::size_t length = toolset.length(); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5057572..6736e17 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -238,7 +238,7 @@ private: std::string GetLibFlagTableName(std::string const& toolset) const; std::string GetLinkFlagTableName(std::string const& toolset) const; std::string GetMasmFlagTableName(std::string const& toolset) const; - std::string GetToolsetName(std::string const& toolset) const; + std::string CanonicalToolsetName(std::string const& toolset) const; std::string CustomVCTargetsPath; std::string VCTargetsPath; -- cgit v0.12 From 1b774e18fbf98b1e5b3b046e621e36f2e7d145f5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:50:43 -0500 Subject: cmGlobalVisualStudio10Generator: Remove redundant arguments --- Source/cmGlobalVisualStudio10Generator.cxx | 42 +++++++++++++----------------- Source/cmGlobalVisualStudio10Generator.h | 12 ++++----- 2 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a8207b5..a155d7d 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1400,8 +1400,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { - std::string optionsName = - this->GetClFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetClFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1412,8 +1411,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { - std::string optionsName = - this->GetCSharpFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetCSharpFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1423,8 +1421,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { - std::string optionsName = - this->GetRcFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetRcFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1434,8 +1431,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { - std::string optionsName = - this->GetLibFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetLibFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1445,8 +1441,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { - std::string optionsName = - this->GetLinkFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetLinkFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1475,8 +1470,7 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { - std::string optionsName = - this->GetMasmFlagTableName(this->GetPlatformToolsetString()); + std::string optionsName = this->GetMasmFlagTableName(); std::string toolsetName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = @@ -1493,9 +1487,9 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const return LoadFlagTable("", toolsetName, defaultName, "NASM"); } -std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if (toolset == "v142") { @@ -1515,9 +1509,9 @@ std::string cmGlobalVisualStudio10Generator::GetClFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { @@ -1537,9 +1531,9 @@ std::string cmGlobalVisualStudio10Generator::GetCSharpFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || @@ -1556,9 +1550,9 @@ std::string cmGlobalVisualStudio10Generator::GetRcFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || @@ -1575,9 +1569,9 @@ std::string cmGlobalVisualStudio10Generator::GetLibFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if (useToolset == "v142") { @@ -1597,9 +1591,9 @@ std::string cmGlobalVisualStudio10Generator::GetLinkFlagTableName( } } -std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName( - std::string const& toolset) const +std::string cmGlobalVisualStudio10Generator::GetMasmFlagTableName() const { + std::string const& toolset = this->GetPlatformToolsetString(); std::string const useToolset = this->CanonicalToolsetName(toolset); if ((useToolset == "v140") || (useToolset == "v141") || diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 6736e17..d683c37 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -232,12 +232,12 @@ private: bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); - std::string GetClFlagTableName(std::string const& toolset) const; - std::string GetCSharpFlagTableName(std::string const& toolset) const; - std::string GetRcFlagTableName(std::string const& toolset) const; - std::string GetLibFlagTableName(std::string const& toolset) const; - std::string GetLinkFlagTableName(std::string const& toolset) const; - std::string GetMasmFlagTableName(std::string const& toolset) const; + std::string GetClFlagTableName() const; + std::string GetCSharpFlagTableName() const; + std::string GetRcFlagTableName() const; + std::string GetLibFlagTableName() const; + std::string GetLinkFlagTableName() const; + std::string GetMasmFlagTableName() const; std::string CanonicalToolsetName(std::string const& toolset) const; std::string CustomVCTargetsPath; -- cgit v0.12 From 99f6f1b3b9df00f0221a0603fca12c4388f3c596 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 13:50:43 -0500 Subject: cmGlobalVisualStudio10Generator: Remove redundant arguments --- Source/cmGlobalVisualStudio10Generator.cxx | 42 +++++++++--------------------- Source/cmGlobalVisualStudio10Generator.h | 1 - 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a155d7d..6b7a972 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1366,8 +1366,8 @@ static std::string cmGetFlagTableName(std::string const& toolsetName, } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( - std::string const& optionsName, std::string const& toolsetName, - std::string const& defaultName, std::string const& table) const + std::string const& optionsName, std::string const& defaultName, + std::string const& table) const { cmIDEFlagTable const* ret = nullptr; @@ -1376,6 +1376,8 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( filename = cmGetFlagTableName(optionsName, table); ret = cmLoadFlagTableJson(filename); } else { + std::string const& toolsetName = + this->CanonicalToolsetName(this->GetPlatformToolsetString()); filename = cmGetFlagTableName(toolsetName, table); if (cmSystemTools::FileExists(filename)) { ret = cmLoadFlagTableJson(filename); @@ -1401,90 +1403,72 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { std::string optionsName = this->GetClFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCLFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "CL"); + return LoadFlagTable(optionsName, defaultName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { std::string optionsName = this->GetCSharpFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCSharpFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "CSharp"); + return LoadFlagTable(optionsName, defaultName, "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { std::string optionsName = this->GetRcFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultRCFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "RC"); + return LoadFlagTable(optionsName, defaultName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { std::string optionsName = this->GetLibFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultLibFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "LIB"); + return LoadFlagTable(optionsName, defaultName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { std::string optionsName = this->GetLinkFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultLinkFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "Link"); + return LoadFlagTable(optionsName, defaultName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCudaFlagTableName); - return LoadFlagTable("", toolsetName, defaultName, "Cuda"); + return LoadFlagTable("", defaultName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultCudaHostFlagTableName); - return LoadFlagTable("", toolsetName, defaultName, "CudaHost"); + return LoadFlagTable("", defaultName, "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { std::string optionsName = this->GetMasmFlagTableName(); - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultMasmFlagTableName); - return LoadFlagTable(optionsName, toolsetName, defaultName, "MASM"); + return LoadFlagTable(optionsName, defaultName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - std::string toolsetName = - this->CanonicalToolsetName(this->GetPlatformToolsetString()); std::string defaultName = this->CanonicalToolsetName(this->DefaultNasmFlagTableName); - return LoadFlagTable("", toolsetName, defaultName, "NASM"); + return LoadFlagTable("", defaultName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index d683c37..5160f29 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -170,7 +170,6 @@ protected: std::string const& GetMSBuildCommand(); cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName, - std::string const& toolsetName, std::string const& defaultName, std::string const& table) const; -- cgit v0.12 From d5522f096da4a04669e49bebfb63887ca1b0fdde Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:25:01 -0500 Subject: cmGlobalVisualStudio10Generator: Drop default toolset name canonicalization The default toolset names are always canonical. --- Source/cmGlobalVisualStudio10Generator.cxx | 37 ++++++++---------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 6b7a972..101ddc0 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1403,72 +1403,55 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { std::string optionsName = this->GetClFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCLFlagTableName); - return LoadFlagTable(optionsName, defaultName, "CL"); + return LoadFlagTable(optionsName, this->DefaultCLFlagTableName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { std::string optionsName = this->GetCSharpFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCSharpFlagTableName); - return LoadFlagTable(optionsName, defaultName, "CSharp"); + return LoadFlagTable(optionsName, this->DefaultCSharpFlagTableName, + "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { std::string optionsName = this->GetRcFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultRCFlagTableName); - return LoadFlagTable(optionsName, defaultName, "RC"); + return LoadFlagTable(optionsName, this->DefaultRCFlagTableName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { std::string optionsName = this->GetLibFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultLibFlagTableName); - return LoadFlagTable(optionsName, defaultName, "LIB"); + return LoadFlagTable(optionsName, this->DefaultLibFlagTableName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { std::string optionsName = this->GetLinkFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultLinkFlagTableName); - return LoadFlagTable(optionsName, defaultName, "Link"); + return LoadFlagTable(optionsName, this->DefaultLinkFlagTableName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCudaFlagTableName); - return LoadFlagTable("", defaultName, "Cuda"); + return LoadFlagTable("", this->DefaultCudaFlagTableName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - std::string defaultName = - this->CanonicalToolsetName(this->DefaultCudaHostFlagTableName); - return LoadFlagTable("", defaultName, "CudaHost"); + return LoadFlagTable("", this->DefaultCudaHostFlagTableName, "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { std::string optionsName = this->GetMasmFlagTableName(); - std::string defaultName = - this->CanonicalToolsetName(this->DefaultMasmFlagTableName); - return LoadFlagTable(optionsName, defaultName, "MASM"); + return LoadFlagTable(optionsName, this->DefaultMasmFlagTableName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - std::string defaultName = - this->CanonicalToolsetName(this->DefaultNasmFlagTableName); - return LoadFlagTable("", defaultName, "NASM"); + return LoadFlagTable("", this->DefaultNasmFlagTableName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const -- cgit v0.12 From cbba9f26a891d477851fac1cf1515d69c25d41a9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:29:08 -0500 Subject: cmGlobalVisualStudio10Generator: Drop unnecessary temporaries --- Source/cmGlobalVisualStudio10Generator.cxx | 32 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 101ddc0..0c7f1c4 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1402,56 +1402,56 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const { - std::string optionsName = this->GetClFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultCLFlagTableName, "CL"); + return LoadFlagTable(this->GetClFlagTableName(), + this->DefaultCLFlagTableName, "CL"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCSharpFlagTable() const { - std::string optionsName = this->GetCSharpFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultCSharpFlagTableName, - "CSharp"); + return LoadFlagTable(this->GetCSharpFlagTableName(), + this->DefaultCSharpFlagTableName, "CSharp"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetRcFlagTable() const { - std::string optionsName = this->GetRcFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultRCFlagTableName, "RC"); + return LoadFlagTable(this->GetRcFlagTableName(), + this->DefaultRCFlagTableName, "RC"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLibFlagTable() const { - std::string optionsName = this->GetLibFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultLibFlagTableName, "LIB"); + return LoadFlagTable(this->GetLibFlagTableName(), + this->DefaultLibFlagTableName, "LIB"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetLinkFlagTable() const { - std::string optionsName = this->GetLinkFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultLinkFlagTableName, "Link"); + return LoadFlagTable(this->GetLinkFlagTableName(), + this->DefaultLinkFlagTableName, "Link"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaFlagTable() const { - return LoadFlagTable("", this->DefaultCudaFlagTableName, "Cuda"); + return LoadFlagTable(std::string(), this->DefaultCudaFlagTableName, "Cuda"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetCudaHostFlagTable() const { - return LoadFlagTable("", this->DefaultCudaHostFlagTableName, "CudaHost"); + return LoadFlagTable(std::string(), this->DefaultCudaHostFlagTableName, + "CudaHost"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const { - std::string optionsName = this->GetMasmFlagTableName(); - return LoadFlagTable(optionsName, this->DefaultMasmFlagTableName, "MASM"); + return LoadFlagTable(this->GetMasmFlagTableName(), + this->DefaultMasmFlagTableName, "MASM"); } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const { - return LoadFlagTable("", this->DefaultNasmFlagTableName, "NASM"); + return LoadFlagTable(std::string(), this->DefaultNasmFlagTableName, "NASM"); } std::string cmGlobalVisualStudio10Generator::GetClFlagTableName() const -- cgit v0.12 From 414b5e0119a99de401e1d7aea61428ec2c9311d5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:34:34 -0500 Subject: cmGlobalVisualStudio10Generator: Clarify LoadFlagTable argument name --- Source/cmGlobalVisualStudio10Generator.cxx | 10 +++++----- Source/cmGlobalVisualStudio10Generator.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 0c7f1c4..40e30d5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1366,19 +1366,19 @@ static std::string cmGetFlagTableName(std::string const& toolsetName, } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( - std::string const& optionsName, std::string const& defaultName, + std::string const& toolSpecificName, std::string const& defaultName, std::string const& table) const { cmIDEFlagTable const* ret = nullptr; std::string filename; - if (!optionsName.empty()) { - filename = cmGetFlagTableName(optionsName, table); + if (!toolSpecificName.empty()) { + filename = cmGetFlagTableName(toolSpecificName, table); ret = cmLoadFlagTableJson(filename); } else { - std::string const& toolsetName = + std::string const& genericName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); - filename = cmGetFlagTableName(toolsetName, table); + filename = cmGetFlagTableName(genericName, table); if (cmSystemTools::FileExists(filename)) { ret = cmLoadFlagTableJson(filename); } else { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5160f29..e8f5ab5 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -169,7 +169,7 @@ protected: std::string const& GetMSBuildCommand(); - cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName, + cmIDEFlagTable const* LoadFlagTable(std::string const& toolSpecificName, std::string const& defaultName, std::string const& table) const; -- cgit v0.12 From 1b33150f7eff42df9d3f926b078de44681755a1d Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 16:23:52 -0500 Subject: cmGlobalVisualStudio10Generator: Generalize flag table lookup interface --- Source/cmGlobalVisualStudio10Generator.cxx | 59 +++++++++++++++++++----------- Source/cmGlobalVisualStudio10Generator.h | 6 +++ 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 40e30d5..8d68bf6 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1358,46 +1358,61 @@ static cmIDEFlagTable const* cmLoadFlagTableJson( return ret; } -static std::string cmGetFlagTableName(std::string const& toolsetName, - std::string const& table) +cm::optional cmGlobalVisualStudio10Generator::FindFlagTable( + cm::string_view toolsetName, cm::string_view table) const { - return cmSystemTools::GetCMakeRoot() + "/Templates/MSBuild/FlagTables/" + - toolsetName + "_" + table + ".json"; + std::string fullPath = + cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/MSBuild/FlagTables/", + toolsetName, '_', table, ".json"); + if (cmSystemTools::FileExists(fullPath)) { + return fullPath; + } + return {}; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::LoadFlagTable( std::string const& toolSpecificName, std::string const& defaultName, std::string const& table) const { - cmIDEFlagTable const* ret = nullptr; + cmMakefile* mf = this->GetCurrentMakefile(); std::string filename; if (!toolSpecificName.empty()) { - filename = cmGetFlagTableName(toolSpecificName, table); - ret = cmLoadFlagTableJson(filename); + if (cm::optional found = + this->FindFlagTable(toolSpecificName, table)) { + filename = std::move(*found); + } else { + mf->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("JSON flag table for ", table, + " not found for toolset ", toolSpecificName)); + return nullptr; + } } else { std::string const& genericName = this->CanonicalToolsetName(this->GetPlatformToolsetString()); - filename = cmGetFlagTableName(genericName, table); - if (cmSystemTools::FileExists(filename)) { - ret = cmLoadFlagTableJson(filename); + cm::optional found = this->FindFlagTable(genericName, table); + if (!found) { + found = this->FindFlagTable(defaultName, table); + } + if (found) { + filename = std::move(*found); } else { - filename = cmGetFlagTableName(defaultName, table); - ret = cmLoadFlagTableJson(filename); + mf->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("JSON flag table for ", table, + " not found for toolset ", genericName, " ", + defaultName)); + return nullptr; } } - if (!ret) { - cmMakefile* mf = this->GetCurrentMakefile(); - - std::ostringstream e; - /* clang-format off */ - e << "JSON flag table \"" << filename << - "\" could not be loaded.\n"; - /* clang-format on */ - mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + if (cmIDEFlagTable const* ret = cmLoadFlagTableJson(filename)) { + return ret; } - return ret; + + mf->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("JSON flag table could not be loaded:\n ", filename)); + return nullptr; } cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetClFlagTable() const diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index e8f5ab5..df79ad7 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -5,6 +5,9 @@ #include #include +#include +#include + #include "cmGlobalVisualStudio8Generator.h" /** \class cmGlobalVisualStudio10Generator @@ -239,6 +242,9 @@ private: std::string GetMasmFlagTableName() const; std::string CanonicalToolsetName(std::string const& toolset) const; + cm::optional FindFlagTable(cm::string_view toolsetName, + cm::string_view table) const; + std::string CustomVCTargetsPath; std::string VCTargetsPath; bool FindVCTargetsPath(cmMakefile* mf); -- cgit v0.12 From 934861e3549b54b9c91c0d501f7e75901d8fa57e Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 5 Mar 2021 09:59:39 -0500 Subject: Find: Document that first argument to PATHS and HINTS can be ENV{} --- Help/command/FIND_XXX.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index 97eecfc..aae1c38 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -11,8 +11,8 @@ The general signature is: |FIND_XXX| ( name | |NAMES| - [HINTS path1 [path2 ... ENV var]] - [PATHS path1 [path2 ... ENV var]] + [HINTS [path | ENV var]... ] + [PATHS [path | ENV var]... ] [PATH_SUFFIXES suffix1 [suffix2 ...]] [DOC "cache documentation string"] [REQUIRED] -- cgit v0.12 From fdfbf89f0c650a9886ffa91e4f3fda08080702b9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 09:06:34 -0500 Subject: ExternalData: Avoid replacing a concurrently-created object If more than one content link references the same object, the build system may launch multiple download processes for the same object concurrently. Use whichever one finishes first, and discard the others. Without this, we replace the objects and use the last finisher instead of the first. This is okay on non-Windows platforms where `rename(2)` gives reliable atomic replacement. However, on Windows platforms and NTFS this is less reliable. I've observed `MoveFileEx` somehow cause another process to get `ERROR_SHARING_VIOLATION` when attempting to read the destination file. We may be able to improve the `file(RENAME)` implementation on modern Windows 10 versions, but for ExternalData's use case it is simpler to just not replace existing objects. --- Modules/ExternalData.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index d6fbae9..b439636 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -1101,7 +1101,14 @@ function(_ExternalData_download_object name hash algo var_obj var_success var_er set(success 1) if(found) - file(RENAME "${tmp}" "${obj}") + # Atomically create the object. If we lose a race with another process, + # do not replace it. Content-addressing ensures it has what we expect. + file(RENAME "${tmp}" "${obj}" NO_REPLACE RESULT result) + if (result STREQUAL "NO_REPLACE") + file(REMOVE "${tmp}") + elseif (result) + message(FATAL_ERROR "Failed to rename:\n \"${tmp}\"\nto:\n \"${obj}\"\nwith error:\n ${result}") + endif() message(STATUS "Downloaded object: \"${obj}\"") elseif(EXISTS "${staged}") set(obj "${staged}") -- cgit v0.12 From 31be23dd1d61db80656159adbcf915a609b8692f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 5 Mar 2021 10:58:54 -0500 Subject: ci: Restore the Module.ExternalData test on Windows In commit a58e3c7e8b (ci: Skip the Module.ExternalData test on Windows, 2020-10-01, v3.19.0-rc1~59^2) the test was dropped pending further investigation. We've now (hopefully) resolved the underlying problem, so we can restore the test. --- .gitlab/ci/ctest_exclusions.cmake | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index a68a693..b885a6a 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -13,15 +13,6 @@ if (CTEST_CMAKE_GENERATOR MATCHES "Visual Studio") "^ExternalProjectUpdateSetup$") endif () -if (CMAKE_HOST_WIN32) - list(APPEND test_exclusions - # This test often fails with an undiagnosed subtle race due to the test - # re-using the same objects for many files. Some copy operations fail - # to open their input with ERROR_SHARING_VIOLATION. - "^Module.ExternalData$" - ) -endif() - string(REPLACE ";" "|" test_exclusions "${test_exclusions}") if (test_exclusions) set(test_exclusions "(${test_exclusions})") -- cgit v0.12 From 425ac4c3b3eb4c7eba9eb3b9f17f19b26e4d22e8 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 6 Mar 2021 00:01:19 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 406174b..27075b3 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210305) +set(CMake_VERSION_PATCH 20210306) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From b72c7f856dc99b3e437ad79201586db32cb65da1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 7 Mar 2021 00:01:08 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 27075b3..a8e47d2 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210306) +set(CMake_VERSION_PATCH 20210307) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From ae791686e7de6c0e80b6120bf2a8949ad5fe4ee5 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 8 Mar 2021 00:03:15 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a8e47d2..f98c0ef 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210307) +set(CMake_VERSION_PATCH 20210308) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 388eb83c098400cb63493896e12b05d685040147 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 8 Mar 2021 13:02:36 -0500 Subject: Tests: Enable MAKE_SUPPORTS_SPACES tests with Ninja generators --- Tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 987f54d..c3652fe 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -96,7 +96,7 @@ if(BUILD_TESTING) # some old versions of make simply cannot handle spaces in paths if (MAKE_IS_GNU OR CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR - CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland") + CMAKE_GENERATOR MATCHES "Visual Studio|Xcode|Borland|Ninja") set(MAKE_SUPPORTS_SPACES 1) else() set(MAKE_SUPPORTS_SPACES 0) -- cgit v0.12 From 7621861f30992bdaddb66a7f3e5dce6eec4545bd Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 15:50:16 -0500 Subject: Tests: Update LibName to cover spaces in shared library name --- Tests/CMakeLists.txt | 2 ++ Tests/LibName/CMakeLists.txt | 8 ++++++++ Tests/LibName/use_ver_space.c | 9 +++++++++ Tests/LibName/ver_space.c | 7 +++++++ 4 files changed, 26 insertions(+) create mode 100644 Tests/LibName/use_ver_space.c create mode 100644 Tests/LibName/ver_space.c diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c3652fe..3a05317 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -828,6 +828,8 @@ if(BUILD_TESTING) ${build_generator_args} --build-project LibName --build-exe-dir "${CMake_BINARY_DIR}/Tests/LibName/lib" + --build-options + -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES} --test-command foobar ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LibName") diff --git a/Tests/LibName/CMakeLists.txt b/Tests/LibName/CMakeLists.txt index 3ac125f..b8f0890 100644 --- a/Tests/LibName/CMakeLists.txt +++ b/Tests/LibName/CMakeLists.txt @@ -24,3 +24,11 @@ set_target_properties(verFoo PROPERTIES VERSION 3.1.4 SOVERSION 3) add_executable(verFoobar foobar.c) target_link_libraries(verFoobar verFoo) + +if(MAKE_SUPPORTS_SPACES AND NOT CMAKE_GENERATOR STREQUAL "Watcom WMake") + # check with lib version and space + add_library(ver_space SHARED ver_space.c) + set_target_properties(ver_space PROPERTIES VERSION 3.1.4 SOVERSION 3 OUTPUT_NAME "ver space") + add_executable(use_ver_space use_ver_space.c) + target_link_libraries(use_ver_space ver_space) +endif() diff --git a/Tests/LibName/use_ver_space.c b/Tests/LibName/use_ver_space.c new file mode 100644 index 0000000..a6a733d --- /dev/null +++ b/Tests/LibName/use_ver_space.c @@ -0,0 +1,9 @@ +#ifdef _WIN32 +__declspec(dllimport) +#endif + int ver_space(void); + +int main(void) +{ + return ver_space(); +} diff --git a/Tests/LibName/ver_space.c b/Tests/LibName/ver_space.c new file mode 100644 index 0000000..669a3b5 --- /dev/null +++ b/Tests/LibName/ver_space.c @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + int ver_space(void) +{ + return 0; +} -- cgit v0.12 From 9e556829c8fd2e78860e798f454f90dc1160dd20 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Mon, 8 Mar 2021 13:32:05 -0500 Subject: KWSys 2021-03-08 (5bfba5e1) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 5bfba5e1a988e16df833e86062d61f4b70d83645 (master). Upstream Shortlog ----------------- Ben Boeckel (4): f69c5cb7 Directory: return a bool literal on Windows 2a118b34 SystemTools: use nullptr in Windows-only code 7ee0dbee Directory: capture the error message dd703ac6 SystemTools: make file copying mechanisms public Sean McBride (1): 3ba8a6de Glob: Change deleted ctor and operator= from private to public --- Directory.cxx | 30 +++++++++++++++++++++++++++++- Glob.hxx.in | 7 +++---- SystemTools.cxx | 17 +++++++---------- SystemTools.hxx.in | 11 +++++++++++ 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Directory.cxx b/Directory.cxx index 0c2190a..e70d4e8 100644 --- a/Directory.cxx +++ b/Directory.cxx @@ -121,7 +121,21 @@ bool Directory::Load(const std::string& name, std::string* errorMessage) delete[] buf; if (srchHandle == -1) { - return 0; + if (errorMessage) { + if (unsigned int errorId = GetLastError()) { + LPSTR message = nullptr; + DWORD size = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&message, 0, nullptr); + *errorMessage = std::string(message, size); + LocalFree(message); + } else { + *errorMessage = "Unknown error."; + } + } + return false; } // Loop through names @@ -152,6 +166,20 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name, delete[] buf; if (srchHandle == -1) { + if (errorMessage) { + if (unsigned int errorId = GetLastError()) { + LPSTR message = nullptr; + DWORD size = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&message, 0, nullptr); + *errorMessage = std::string(message, size); + LocalFree(message); + } else { + *errorMessage = "Unknown error."; + } + } return 0; } diff --git a/Glob.hxx.in b/Glob.hxx.in index e8474e2..fd39775 100644 --- a/Glob.hxx.in +++ b/Glob.hxx.in @@ -54,6 +54,9 @@ public: Glob(); ~Glob(); + Glob(const Glob&) = delete; + void operator=(const Glob&) = delete; + //! Find all files that match the pattern. bool FindFiles(const std::string& inexpr, GlobMessages* messages = nullptr); @@ -124,10 +127,6 @@ protected: std::vector VisitedSymlinks; bool ListDirs; bool RecurseListDirs; - -private: - Glob(const Glob&) = delete; - void operator=(const Glob&) = delete; }; } // namespace @KWSYS_NAMESPACE@ diff --git a/SystemTools.cxx b/SystemTools.cxx index 6144d9c..cf04799 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -244,7 +244,7 @@ inline int Chdir(const std::string& dir) return _wchdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str()); } inline void Realpath(const std::string& path, std::string& resolved_path, - std::string* errorMessage = 0) + std::string* errorMessage = nullptr) { std::wstring tmp = KWSYS_NAMESPACE::Encoding::ToWide(path); wchar_t* ptemp; @@ -2273,11 +2273,8 @@ bool SystemTools::TextFilesDiffer(const std::string& path1, return false; } -/** - * Blockwise copy source to destination file - */ -static bool CopyFileContentBlockwise(const std::string& source, - const std::string& destination) +bool SystemTools::CopyFileContentBlockwise(const std::string& source, + const std::string& destination) { // Open files kwsys::ifstream fin(source.c_str(), std::ios::in | std::ios::binary); @@ -2341,8 +2338,8 @@ static bool CopyFileContentBlockwise(const std::string& source, * - The underlying filesystem does not support file cloning * - An unspecified error occurred */ -static bool CloneFileContent(const std::string& source, - const std::string& destination) +bool SystemTools::CloneFileContent(const std::string& source, + const std::string& destination) { #if defined(__linux) && defined(FICLONE) int in = open(source.c_str(), O_RDONLY); @@ -2410,9 +2407,9 @@ bool SystemTools::CopyFileAlways(const std::string& source, SystemTools::MakeDirectory(destination_dir); - if (!CloneFileContent(source, real_destination)) { + if (!SystemTools::CloneFileContent(source, real_destination)) { // if cloning did not succeed, fall back to blockwise copy - if (!CopyFileContentBlockwise(source, real_destination)) { + if (!SystemTools::CopyFileContentBlockwise(source, real_destination)) { return false; } } diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index 74dc176..a7b1288 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -578,6 +578,17 @@ public: const std::string& path2); /** + * Blockwise copy source to destination file + */ + static bool CopyFileContentBlockwise(const std::string& source, + const std::string& destination); + /** + * Clone the source file to the destination file + */ + static bool CloneFileContent(const std::string& source, + const std::string& destination); + + /** * Return true if the two files are the same file */ static bool SameFile(const std::string& file1, const std::string& file2); -- cgit v0.12 From a8954cc3c47a1a9459ddbe10f5b288e466872076 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 9 Mar 2021 00:01:16 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f98c0ef..ee17d40 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210308) +set(CMake_VERSION_PATCH 20210309) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 6fd7e8c53f83ed5b38dd7a5ca9383b22dc6739cf Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 9 Mar 2021 07:34:17 -0500 Subject: Tests: Make RunCMake.Generator{Platform,Toolset} two-flag cases explicit Do not rely on the RunCMake infrastructure to pass `-T` or `-A`. --- Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake | 4 ++-- Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake index 27ede06..83e63f9 100644 --- a/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorPlatform/RunCMakeTest.cmake @@ -11,9 +11,9 @@ else() run_cmake(BadPlatform) endif() -set(RunCMake_GENERATOR_TOOLSET "") +set(RunCMake_GENERATOR_PLATFORM "") -set(RunCMake_TEST_OPTIONS -A "Extra Platform") +set(RunCMake_TEST_OPTIONS -A "Test Platform" -A "Extra Platform") run_cmake(TwoPlatforms) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index 5f12d79..75ed677 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -76,7 +76,7 @@ endif() set(RunCMake_GENERATOR_TOOLSET "") -set(RunCMake_TEST_OPTIONS -T "Extra Toolset") +set(RunCMake_TEST_OPTIONS -T "Test Toolset" -T "Extra Toolset") run_cmake(TwoToolsets) unset(RunCMake_TEST_OPTIONS) -- cgit v0.12 From f4d154755ac751541a084415d669deb11e8da76c Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 9 Mar 2021 06:52:53 -0500 Subject: Tests: Reverse RunCMake code path order --- Tests/RunCMake/RunCMake.cmake | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 1a69059..c1023f0 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -91,21 +91,7 @@ function(run_cmake test) else() set(maybe_input_file "") endif() - if(RunCMake_TEST_COMMAND) - if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) - set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") - endif() - execute_process( - COMMAND ${RunCMake_TEST_COMMAND} - WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" - OUTPUT_VARIABLE actual_stdout - ERROR_VARIABLE ${actual_stderr_var} - RESULT_VARIABLE actual_result - ENCODING UTF8 - ${maybe_timeout} - ${maybe_input_file} - ) - else() + if(NOT RunCMake_TEST_COMMAND) if(RunCMake_GENERATOR_INSTANCE) set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}") else() @@ -134,6 +120,20 @@ function(run_cmake test) ${maybe_timeout} ${maybe_input_file} ) + else() + if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + endif() + execute_process( + COMMAND ${RunCMake_TEST_COMMAND} + WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" + OUTPUT_VARIABLE actual_stdout + ERROR_VARIABLE ${actual_stderr_var} + RESULT_VARIABLE actual_result + ENCODING UTF8 + ${maybe_timeout} + ${maybe_input_file} + ) endif() set(msg "") if(NOT "${actual_result}" MATCHES "${expect_result}") -- cgit v0.12 From 5f03744e3661f07e9c59d6e62ceec9ce3b45c404 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 9 Mar 2021 07:11:36 -0500 Subject: Tests: Move RunCMake option construction closer to use --- Tests/RunCMake/RunCMake.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index c1023f0..a690f4e 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -64,15 +64,6 @@ function(run_cmake test) else() include(${top_src}/${test}-prep.cmake OPTIONAL) endif() - if(NOT DEFINED RunCMake_TEST_OPTIONS) - set(RunCMake_TEST_OPTIONS "") - endif() - if(APPLE) - list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) - endif() - if(RunCMake_MAKE_PROGRAM) - list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}") - endif() if(RunCMake_TEST_OUTPUT_MERGE) set(actual_stderr_var actual_stdout) set(actual_stderr "") @@ -92,6 +83,15 @@ function(run_cmake test) set(maybe_input_file "") endif() if(NOT RunCMake_TEST_COMMAND) + if(NOT DEFINED RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS "") + endif() + if(APPLE) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) + endif() + if(RunCMake_MAKE_PROGRAM) + list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}") + endif() if(RunCMake_GENERATOR_INSTANCE) set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}") else() -- cgit v0.12 From e8065554a8de34decaa1cd4a9df7865da85daf52 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 9 Mar 2021 07:12:09 -0500 Subject: Tests: Teach RunCMake to always print the command on failure Previously we only printed explicit `RunCMake_TEST_COMMAND` cases on failure. Refactor the RunCMake infrastructure so that we always define `RunCMake_TEST_COMMAND` internally, and print it on failure. --- Tests/RunCMake/RunCMake.cmake | 76 ++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index a690f4e..5e2f647 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -92,49 +92,41 @@ function(run_cmake test) if(RunCMake_MAKE_PROGRAM) list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}") endif() - if(RunCMake_GENERATOR_INSTANCE) - set(_D_CMAKE_GENERATOR_INSTANCE "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}") - else() - set(_D_CMAKE_GENERATOR_INSTANCE "") - endif() + set(RunCMake_TEST_COMMAND ${CMAKE_COMMAND}) if(NOT RunCMake_TEST_NO_SOURCE_DIR) - set(maybe_source_dir "${RunCMake_TEST_SOURCE_DIR}") - else() - set(maybe_source_dir "") + list(APPEND RunCMake_TEST_COMMAND "${RunCMake_TEST_SOURCE_DIR}") endif() - execute_process( - COMMAND ${CMAKE_COMMAND} - ${maybe_source_dir} - -G "${RunCMake_GENERATOR}" - -A "${RunCMake_GENERATOR_PLATFORM}" - -T "${RunCMake_GENERATOR_TOOLSET}" - ${_D_CMAKE_GENERATOR_INSTANCE} - -DRunCMake_TEST=${test} - --no-warn-unused-cli - ${RunCMake_TEST_OPTIONS} - WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" - OUTPUT_VARIABLE actual_stdout - ERROR_VARIABLE ${actual_stderr_var} - RESULT_VARIABLE actual_result - ENCODING UTF8 - ${maybe_timeout} - ${maybe_input_file} - ) - else() - if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) - set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + list(APPEND RunCMake_TEST_COMMAND -G "${RunCMake_GENERATOR}") + if(RunCMake_GENERATOR_PLATFORM) + list(APPEND RunCMake_TEST_COMMAND -A "${RunCMake_GENERATOR_PLATFORM}") + endif() + if(RunCMake_GENERATOR_TOOLSET) + list(APPEND RunCMake_TEST_COMMAND -T "${RunCMake_GENERATOR_TOOLSET}") endif() - execute_process( - COMMAND ${RunCMake_TEST_COMMAND} - WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" - OUTPUT_VARIABLE actual_stdout - ERROR_VARIABLE ${actual_stderr_var} - RESULT_VARIABLE actual_result - ENCODING UTF8 - ${maybe_timeout} - ${maybe_input_file} + if(RunCMake_GENERATOR_INSTANCE) + list(APPEND RunCMake_TEST_COMMAND "-DCMAKE_GENERATOR_INSTANCE=${RunCMake_GENERATOR_INSTANCE}") + endif() + list(APPEND RunCMake_TEST_COMMAND + -DRunCMake_TEST=${test} + --no-warn-unused-cli ) - endif() + else() + set(RunCMake_TEST_OPTIONS "") + endif() + if(NOT RunCMake_TEST_COMMAND_WORKING_DIRECTORY) + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + endif() + execute_process( + COMMAND ${RunCMake_TEST_COMMAND} + ${RunCMake_TEST_OPTIONS} + WORKING_DIRECTORY "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}" + OUTPUT_VARIABLE actual_stdout + ERROR_VARIABLE ${actual_stderr_var} + RESULT_VARIABLE actual_result + ENCODING UTF8 + ${maybe_timeout} + ${maybe_input_file} + ) set(msg "") if(NOT "${actual_result}" MATCHES "${expect_result}") string(APPEND msg "Result is [${actual_result}], not [${expect_result}].\n") @@ -190,8 +182,12 @@ function(run_cmake test) if(RunCMake_TEST_FAILED) set(msg "${RunCMake_TEST_FAILED}\n${msg}") endif() - if(msg AND RunCMake_TEST_COMMAND) + if(msg) string(REPLACE ";" "\" \"" command "\"${RunCMake_TEST_COMMAND}\"") + if(RunCMake_TEST_OPTIONS) + string(REPLACE ";" "\" \"" options "\"${RunCMake_TEST_OPTIONS}\"") + string(APPEND command " ${options}") + endif() string(APPEND msg "Command was:\n command> ${command}\n") endif() if(msg) -- cgit v0.12 From 7b0ab0439d58b72617e6cbcb9d357a388da83f2b Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 9 Mar 2021 06:22:45 -0500 Subject: Tests: Fix FortranModules test with Intel compiler on Windows The test regularly fails updating the `vc*.pdb` compiler-generated PDB file. Add the `/Z7` flag as the compiler suggests for this. --- Tests/FortranModules/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tests/FortranModules/CMakeLists.txt b/Tests/FortranModules/CMakeLists.txt index b7a6f68..94f5939 100644 --- a/Tests/FortranModules/CMakeLists.txt +++ b/Tests/FortranModules/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required (VERSION 3.9) project(FortranModules Fortran) +if("${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "^Intel(LLVM)?;MSVC$") + string(APPEND CMAKE_Fortran_FLAGS_DEBUG " -Z7") + string(APPEND CMAKE_Fortran_FLAGS_RELWITHDEBINFO " -Z7") +endif() + if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}") endif() -- cgit v0.12 From 100016e9cb31aad7b642a9733409c7294cd6652f Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 4 Mar 2021 11:51:03 -0500 Subject: cmSystemTools: add utilities to copy a file with error handling --- Source/cmSystemTools.cxx | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Source/cmSystemTools.h | 18 ++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index db5b1ac..87ba152 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -87,6 +87,7 @@ # include # include +# include #endif #if defined(_WIN32) && \ @@ -990,6 +991,51 @@ bool cmMoveFile(std::wstring const& oldname, std::wstring const& newname, } #endif +bool cmSystemTools::CopySingleFile(const std::string& oldname, + const std::string& newname) +{ + return cmSystemTools::CopySingleFile(oldname, newname, CopyWhen::Always) == + CopyResult::Success; +} + +cmSystemTools::CopyResult cmSystemTools::CopySingleFile( + std::string const& oldname, std::string const& newname, CopyWhen when, + std::string* err) +{ + switch (when) { + case CopyWhen::Always: + break; + case CopyWhen::OnlyIfDifferent: + if (!FilesDiffer(oldname, newname)) { + return CopyResult::Success; + } + break; + } + + mode_t perm = 0; + bool perms = SystemTools::GetPermissions(oldname, perm); + + // If files are the same do not copy + if (SystemTools::SameFile(oldname, newname)) { + return CopyResult::Success; + } + + if (!cmsys::SystemTools::CloneFileContent(oldname, newname)) { + // if cloning did not succeed, fall back to blockwise copy + if (!cmsys::SystemTools::CopyFileContentBlockwise(oldname, newname)) { + ReportError(err); + return CopyResult::Failure; + } + } + if (perms) { + if (!SystemTools::SetPermissions(newname, perm)) { + ReportError(err); + return CopyResult::Failure; + } + } + return CopyResult::Success; +} + bool cmSystemTools::RenameFile(const std::string& oldname, const std::string& newname) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 3cc032c..2ff4c5d 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -128,6 +128,24 @@ public: static bool SimpleGlob(const std::string& glob, std::vector& files, int type = 0); + enum class CopyWhen + { + Always, + OnlyIfDifferent, + }; + enum class CopyResult + { + Success, + Failure, + }; + + /** Copy a file. */ + static bool CopySingleFile(const std::string& oldname, + const std::string& newname); + static CopyResult CopySingleFile(std::string const& oldname, + std::string const& newname, CopyWhen when, + std::string* err = nullptr); + enum class Replace { Yes, -- cgit v0.12 From 9af6e2e7b2940d5ba4d138f0df5950a675ec41c0 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 26 Feb 2021 11:49:50 -0500 Subject: Ninja: Use new wincodepage tool to determine encoding Ninja 1.11 and later uses UTF-8 on Windows when possible, and includes a tool that reports the code page in use. Use this tool to determine what encoding to write the Ninja files in. Fixes: #21866 --- Source/cmGlobalNinjaGenerator.cxx | 65 ++++++++++++++++++++++++++++++++++----- Source/cmGlobalNinjaGenerator.h | 5 +++ Source/cmLocalNinjaGenerator.cxx | 5 ++- 3 files changed, 66 insertions(+), 9 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 7eac169..36be45c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -503,14 +504,7 @@ std::unique_ptr cmGlobalNinjaGenerator::CreateLocalGenerator( codecvt::Encoding cmGlobalNinjaGenerator::GetMakefileEncoding() const { -#ifdef _WIN32 - // Ninja on Windows does not support non-ANSI characters. - // https://github.com/ninja-build/ninja/issues/1195 - return codecvt::ANSI; -#else - // No encoding conversion needed on other platforms. - return codecvt::None; -#endif + return this->NinjaExpectedEncoding; } void cmGlobalNinjaGenerator::GetDocumentation(cmDocumentationEntry& entry) @@ -731,6 +725,61 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() this->NinjaSupportsMetadataOnRegeneration = !cmSystemTools::VersionCompare( cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), RequiredNinjaVersionForMetadataOnRegeneration().c_str()); +#ifdef _WIN32 + this->NinjaSupportsCodePage = !cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, this->NinjaVersion.c_str(), + RequiredNinjaVersionForCodePage().c_str()); + if (this->NinjaSupportsCodePage) { + this->CheckNinjaCodePage(); + } else { + this->NinjaExpectedEncoding = codecvt::ANSI; + } +#endif +} + +void cmGlobalNinjaGenerator::CheckNinjaCodePage() +{ + std::vector command{ this->NinjaCommand, "-t", "wincodepage" }; + std::string output; + std::string error; + int result; + if (!cmSystemTools::RunSingleCommand(command, &output, &error, &result, + nullptr, cmSystemTools::OUTPUT_NONE)) { + this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, + cmStrCat("Running\n '", + cmJoin(command, "' '"), + "'\n" + "failed with:\n ", + error)); + cmSystemTools::SetFatalErrorOccured(); + } else if (result == 0) { + std::istringstream outputStream(output); + std::string line; + bool found = false; + while (cmSystemTools::GetLineFromStream(outputStream, line)) { + if (cmHasLiteralPrefix(line, "Build file encoding: ")) { + cm::string_view lineView(line); + cm::string_view encoding = + lineView.substr(cmStrLen("Build file encoding: ")); + if (encoding == "UTF-8") { + // Ninja expects UTF-8. We use that internally. No conversion needed. + this->NinjaExpectedEncoding = codecvt::None; + } else { + this->NinjaExpectedEncoding = codecvt::ANSI; + } + found = true; + break; + } + } + if (!found) { + this->GetCMakeInstance()->IssueMessage( + MessageType::WARNING, + "Could not determine Ninja's code page, defaulting to UTF-8"); + this->NinjaExpectedEncoding = codecvt::None; + } + } else { + this->NinjaExpectedEncoding = codecvt::ANSI; + } } bool cmGlobalNinjaGenerator::CheckLanguages( diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 0c919ef..9f31708 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -388,6 +388,7 @@ public: { return "1.10.2"; } + static std::string RequiredNinjaVersionForCodePage() { return "1.11"; } bool SupportsConsolePool() const; bool SupportsImplicitOuts() const; bool SupportsManifestRestat() const; @@ -474,6 +475,7 @@ private: std::string GetEditCacheCommand() const override; bool FindMakeProgram(cmMakefile* mf) override; void CheckNinjaFeatures(); + void CheckNinjaCodePage(); bool CheckLanguages(std::vector const& languages, cmMakefile* mf) const override; bool CheckFortran(cmMakefile* mf) const; @@ -568,6 +570,9 @@ private: bool NinjaSupportsUnconditionalRecompactTool = false; bool NinjaSupportsMultipleOutputs = false; bool NinjaSupportsMetadataOnRegeneration = false; + bool NinjaSupportsCodePage = false; + + codecvt::Encoding NinjaExpectedEncoding = codecvt::None; bool DiagnosedCxxModuleSupport = false; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 8ed411a..050c907 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -97,9 +97,12 @@ void cmLocalNinjaGenerator::Generate() // contains any non-ASCII characters and dependency checking will fail. // As a workaround, leave the msvc_deps_prefix UTF-8 encoded even though // the rest of the file is ANSI encoded. - if (GetConsoleOutputCP() == CP_UTF8 && GetACP() != CP_UTF8) { + if (GetConsoleOutputCP() == CP_UTF8 && GetACP() != CP_UTF8 && + this->GetGlobalGenerator()->GetMakefileEncoding() != codecvt::None) { this->GetRulesFileStream().WriteRaw(showIncludesPrefix); } else { + // Ninja 1.11 and above uses the UTF-8 code page if it's supported, so + // in that case we can write it normally without using raw bytes. this->GetRulesFileStream() << showIncludesPrefix; } #else -- cgit v0.12 From b227a9565eb06dcc6e59bfa31e6939edf1ddbaad Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 22 Feb 2021 11:58:52 -0500 Subject: cmake: configure preset add support for --install-prefix mapping --- Help/manual/OPTIONS_BUILD.txt | 3 +- Help/manual/cmake-presets.7.rst | 6 ++ Help/manual/presets/schema.json | 94 +++++++++++++++++++++- Help/release/dev/cmake-install-prefix-command.rst | 3 + Source/cmCMakePresetsFile.cxx | 25 +++++- Source/cmCMakePresetsFile.h | 2 + Source/cmake.cxx | 20 ++++- .../FuturePresetInstallDirField-result.txt | 1 + .../FuturePresetInstallDirField-stderr.txt | 2 + .../FuturePresetInstallDirField.json.in | 11 +++ Tests/RunCMake/CMakePresets/GoodInstall.json.in | 30 +++++++ .../CMakePresets/GoodInstallCommandLine.cmake | 3 + .../RunCMake/CMakePresets/GoodInstallDefault.cmake | 3 + .../RunCMake/CMakePresets/GoodInstallInherit.cmake | 3 + .../CMakePresets/GoodInstallOverride.cmake | 3 + Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 8 ++ .../CommandLine/install-prefix-no-arg-result.txt | 1 + .../CommandLine/install-prefix-no-arg-stderr.txt | 1 + Tests/RunCMake/IfacePaths/RunCMakeTest.cmake | 2 +- 19 files changed, 212 insertions(+), 9 deletions(-) create mode 100644 Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-result.txt create mode 100644 Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/FuturePresetInstallDirField.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodInstall.json.in create mode 100644 Tests/RunCMake/CMakePresets/GoodInstallCommandLine.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInstallDefault.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInstallInherit.cmake create mode 100644 Tests/RunCMake/CMakePresets/GoodInstallOverride.cmake create mode 100644 Tests/RunCMake/CommandLine/install-prefix-no-arg-result.txt create mode 100644 Tests/RunCMake/CommandLine/install-prefix-no-arg-stderr.txt diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index 251672e..c4f9be8 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -77,7 +77,8 @@ :variable:`CMAKE_GENERATOR_PLATFORM` variable for details. ``--install-prefix `` - Specify the installation prefix, :variable:`CMAKE_INSTALL_PREFIX`. + Specify the installation directory, used by the + :variable:`CMAKE_INSTALL_PREFIX` variable. Must be an absolute path. ``-Wno-dev`` Suppress developer warnings. diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 467818d..3d2ada8 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -183,6 +183,12 @@ that may contain the following fields: specified, it must be inherited from the ``inherits`` preset (unless this preset is ``hidden``). +``installDir`` + + An optional string representing the path to the installation directory. + This field supports `macro expansion`_. If a relative path is specified, + it is calculated relative to the source directory. + ``cmakeExecutable`` An optional string representing the path to the CMake executable to use diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index ffbd7fe..a5025bb 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -11,7 +11,7 @@ }, "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"}, "vendor": { "$ref": "#/definitions/vendor" }, - "configurePresets": { "$ref": "#/definitions/configurePresets"} + "configurePresets": { "$ref": "#/definitions/configurePresetsV1"} }, "additionalProperties": false }, @@ -19,11 +19,25 @@ "properties": { "version": { "const": 2, + "description": "A requVired integer representing the version of the JSON schema." + }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"}, + "vendor": { "$ref": "#/definitions/vendor" }, + "configurePresets": { "$ref": "#/definitions/configurePresetsV1"}, + "buildPresets": { "$ref": "#/definitions/buildPresets"}, + "testPresets": { "$ref": "#/definitions/testPresets"} + }, + "additionalProperties": false + }, + { + "properties": { + "version": { + "const": 3, "description": "A required integer representing the version of the JSON schema." }, "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"}, "vendor": { "$ref": "#/definitions/vendor" }, - "configurePresets": { "$ref": "#/definitions/configurePresets"}, + "configurePresets": { "$ref": "#/definitions/configurePresetsV3"}, "buildPresets": { "$ref": "#/definitions/buildPresets"}, "testPresets": { "$ref": "#/definitions/testPresets"} }, @@ -58,7 +72,21 @@ "description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, the keys should be a vendor-specific domain name followed by a /-separated path. For example, the Example IDE 1.0 could use example.com/ExampleIDE/1.0. The value of each field can be anything desired by the vendor, though will typically be a map.", "properties": {} }, - "configurePresets": { + "configurePresetsItemsV3": { + "type": "array", + "description": "A configure preset object.", + "items": { + "type": "object", + "description": "A configure preset object.", + "properties": { + "installDir": { + "type": "string", + "description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, it must be inherited from the inherits preset (unless this preset is hidden)." + } + } + } + }, + "configurePresetsItemsV1": { "type": "array", "description": "An optional array of configure preset objects.", "items": { @@ -302,6 +330,66 @@ }, "additionalProperties": false } + } + } + }, + "configurePresetsV3": { + "type": "array", + "description": "An optional array of configure preset objects.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsItemsV1" }, + { "$ref": "#/definitions/configurePresetsItemsV3" } + ], + "items": { + "properties": { + "name": {}, + "hidden": {}, + "inherits": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "generator": {}, + "architecture": {}, + "toolset": {}, + "binaryDir": {}, + "installDir": {}, + "cmakeExecutable": {}, + "cacheVariables": {}, + "environment": {}, + "warnings": {}, + "errors": {}, + "debug": {} + }, + "required": [ + "name" + ], + "additionalProperties": false + } + }, + "configurePresetsV1": { + "type": "array", + "description": "An optional array of configure preset objects.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsItemsV1" } + ], + "items": { + "properties": { + "name": {}, + "hidden": {}, + "inherits": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "generator": {}, + "architecture": {}, + "toolset": {}, + "binaryDir": {}, + "cmakeExecutable": {}, + "cacheVariables": {}, + "environment": {}, + "warnings": {}, + "errors": {}, + "debug": {} }, "required": [ "name" diff --git a/Help/release/dev/cmake-install-prefix-command.rst b/Help/release/dev/cmake-install-prefix-command.rst index a5b140a..2de5d91 100644 --- a/Help/release/dev/cmake-install-prefix-command.rst +++ b/Help/release/dev/cmake-install-prefix-command.rst @@ -3,3 +3,6 @@ cmake-install-prefix-command * The :manual:`cmake(1)` command gained the ``--install-prefix `` command line option to specify the location of the install prefix. + +* :manual:`cmake-presets(7)` configure preset gained support for specifying + the install prefix. diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index c8d69b8..e9e8c4c 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -57,7 +57,7 @@ using TestPreset = cmCMakePresetsFile::TestPreset; using ArchToolsetStrategy = cmCMakePresetsFile::ArchToolsetStrategy; constexpr int MIN_VERSION = 1; -constexpr int MAX_VERSION = 2; +constexpr int MAX_VERSION = 3; struct CMakeVersion { @@ -327,6 +327,8 @@ auto const ConfigurePresetHelper = .Bind("toolset"_s, ToolsetHelper, false) .Bind("binaryDir"_s, &ConfigurePreset::BinaryDir, PresetStringHelper, false) + .Bind("installDir"_s, &ConfigurePreset::InstallDir, PresetStringHelper, + false) .Bind("cmakeExecutable"_s, nullptr, PresetStringHelper, false) .Bind("cacheVariables"_s, &ConfigurePreset::CacheVariables, VariablesHelper, false) @@ -872,6 +874,17 @@ bool ExpandMacros(const cmCMakePresetsFile& file, out->BinaryDir = cmSystemTools::CollapseFullPath(binaryDir); cmSystemTools::ConvertToUnixSlashes(out->BinaryDir); + if (!preset.InstallDir.empty()) { + std::string installDir = preset.InstallDir; + CHECK_EXPAND(out, installDir, macroExpanders) + + if (!cmSystemTools::FileIsFullPath(installDir)) { + installDir = cmStrCat(file.SourceDir, '/', installDir); + } + out->InstallDir = cmSystemTools::CollapseFullPath(installDir); + cmSystemTools::ConvertToUnixSlashes(out->InstallDir); + } + for (auto& variable : out->CacheVariables) { if (variable.second) { CHECK_EXPAND(out, variable.second->Value, macroExpanders) @@ -1174,6 +1187,7 @@ cmCMakePresetsFile::ConfigurePreset::VisitPresetInherit( preset.ToolsetStrategy = parent.ToolsetStrategy; } InheritString(preset.BinaryDir, parent.BinaryDir); + InheritString(preset.InstallDir, parent.InstallDir); InheritOptionalValue(preset.WarnDev, parent.WarnDev); InheritOptionalValue(preset.ErrorDev, parent.ErrorDev); InheritOptionalValue(preset.WarnDeprecated, parent.WarnDeprecated); @@ -1502,6 +1516,9 @@ const char* cmCMakePresetsFile::ResultToString(ReadFileResult result) case ReadFileResult::BUILD_TEST_PRESETS_UNSUPPORTED: return "File version must be 2 or higher for build and test preset " "support."; + case ReadFileResult::INSTALL_PREFIX_UNSUPPORTED: + return "File version must be 3 or higher for installDir preset " + "support."; } return "Unknown error"; @@ -1571,6 +1588,12 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( .second) { return ReadFileResult::DUPLICATE_PRESETS; } + + // Support for installDir presets added in version 3. + if (v < 3 && !preset.InstallDir.empty()) { + return ReadFileResult::INSTALL_PREFIX_UNSUPPORTED; + } + this->ConfigurePresetOrder.push_back(preset.Name); } diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h index e92c86b..517215d 100644 --- a/Source/cmCMakePresetsFile.h +++ b/Source/cmCMakePresetsFile.h @@ -32,6 +32,7 @@ public: USER_PRESET_INHERITANCE, INVALID_MACRO_EXPANSION, BUILD_TEST_PRESETS_UNSUPPORTED, + INSTALL_PREFIX_UNSUPPORTED, }; enum class ArchToolsetStrategy @@ -102,6 +103,7 @@ public: std::string Toolset; cm::optional ToolsetStrategy; std::string BinaryDir; + std::string InstallDir; std::map> CacheVariables; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index f96badd..b12eeee 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -28,6 +28,7 @@ #include "cm_sys_stat.h" +#include "cmCMakePath.h" #include "cmCMakePresetsFile.h" #include "cmCommandLineArgument.h" #include "cmCommands.h" @@ -496,11 +497,16 @@ bool cmake::SetCacheArgs(const std::vector& args) auto PrefixLambda = [&](std::string const& path, cmake* state) -> bool { const std::string var = "CMAKE_INSTALL_PREFIX"; cmStateEnums::CacheEntryType type = cmStateEnums::PATH; + cmCMakePath absolutePath(path); + if (absolutePath.IsAbsolute()) { #ifndef CMAKE_BOOTSTRAP - state->UnprocessedPresetVariables.erase(var); + state->UnprocessedPresetVariables.erase(var); #endif - state->ProcessCacheArg(var, path, type); - return true; + state->ProcessCacheArg(var, path, type); + return true; + } + cmSystemTools::Error("Absolute paths are required for --install-prefix"); + return false; }; std::vector arguments = { @@ -1224,6 +1230,14 @@ void cmake::SetArgs(const std::vector& args) this->UnprocessedPresetVariables = expandedPreset->CacheVariables; this->UnprocessedPresetEnvironment = expandedPreset->Environment; + if (!expandedPreset->InstallDir.empty() && + this->State->GetInitializedCacheValue("CMAKE_INSTALL_PREFIX") == + nullptr) { + this->UnprocessedPresetVariables["CMAKE_INSTALL_PREFIX"] = { + "PATH", expandedPreset->InstallDir + }; + } + if (!expandedPreset->ArchitectureStrategy || expandedPreset->ArchitectureStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set) { diff --git a/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-result.txt b/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-stderr.txt b/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-stderr.txt new file mode 100644 index 0000000..36123bd --- /dev/null +++ b/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField: File version must be 3 or higher for installDir preset support.$ diff --git a/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField.json.in b/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField.json.in new file mode 100644 index 0000000..2e5f7d5 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/FuturePresetInstallDirField.json.in @@ -0,0 +1,11 @@ +{ + "version": 1, + "configurePresets": [ + { + "name": "FuturePresetInstallDirField", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "installDir": "${sourceDir}/install" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/GoodInstall.json.in b/Tests/RunCMake/CMakePresets/GoodInstall.json.in new file mode 100644 index 0000000..6287c65 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInstall.json.in @@ -0,0 +1,30 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "GoodInstallDefault", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build/${presetName}", + "installDir": "${sourceDir}/build/install_dir1" + }, + { + "name": "GoodInstallInherit", + "inherits": "GoodInstallDefault", + "cacheVariables": { + "CMAKE_INSTALL_PREFIX": { + "type": "PATH", + "value": "${sourceDir}/build/bad_path" + } + } + }, + { + "name": "GoodInstallOverride", + "inherits": "GoodInstallInherit", + "installDir": "${sourceDir}/build/install_dir2" + }, + { + "name": "GoodInstallCommandLine", + "inherits": "GoodInstallOverride" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/GoodInstallCommandLine.cmake b/Tests/RunCMake/CMakePresets/GoodInstallCommandLine.cmake new file mode 100644 index 0000000..a4f6178 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInstallCommandLine.cmake @@ -0,0 +1,3 @@ +include("${RunCMake_SOURCE_DIR}/TestVariable.cmake") + +test_variable("CMAKE_INSTALL_PREFIX" "PATH" "${RunCMake_SOURCE_DIR}/path/passed/on/command_line") diff --git a/Tests/RunCMake/CMakePresets/GoodInstallDefault.cmake b/Tests/RunCMake/CMakePresets/GoodInstallDefault.cmake new file mode 100644 index 0000000..656fda0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInstallDefault.cmake @@ -0,0 +1,3 @@ +include("${RunCMake_SOURCE_DIR}/TestVariable.cmake") + +test_variable("CMAKE_INSTALL_PREFIX" "PATH" "${CMAKE_SOURCE_DIR}/build/install_dir1") diff --git a/Tests/RunCMake/CMakePresets/GoodInstallInherit.cmake b/Tests/RunCMake/CMakePresets/GoodInstallInherit.cmake new file mode 100644 index 0000000..656fda0 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInstallInherit.cmake @@ -0,0 +1,3 @@ +include("${RunCMake_SOURCE_DIR}/TestVariable.cmake") + +test_variable("CMAKE_INSTALL_PREFIX" "PATH" "${CMAKE_SOURCE_DIR}/build/install_dir1") diff --git a/Tests/RunCMake/CMakePresets/GoodInstallOverride.cmake b/Tests/RunCMake/CMakePresets/GoodInstallOverride.cmake new file mode 100644 index 0000000..3d12b07 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/GoodInstallOverride.cmake @@ -0,0 +1,3 @@ +include("${RunCMake_SOURCE_DIR}/TestVariable.cmake") + +test_variable("CMAKE_INSTALL_PREFIX" "PATH" "${CMAKE_SOURCE_DIR}/build/install_dir2") diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index dfc56ee..ee21130 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -94,6 +94,7 @@ run_cmake_presets(InvalidVariableValue) run_cmake_presets(ExtraRootField) run_cmake_presets(ExtraPresetField) run_cmake_presets(ExtraVariableField) +run_cmake_presets(FuturePresetInstallDirField) run_cmake_presets(InvalidPresetVendor) set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) run_cmake_presets(DuplicatePresets) @@ -181,6 +182,13 @@ run_cmake_presets(GoodInheritanceMulti) run_cmake_presets(GoodInheritanceMultiSecond) run_cmake_presets(GoodInheritanceMacro) +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/GoodInstall.json.in") +run_cmake_presets(GoodInstallDefault) +run_cmake_presets(GoodInstallInherit) +run_cmake_presets(GoodInstallOverride) +run_cmake_presets(GoodInstallCommandLine "--install-prefix=${RunCMake_SOURCE_DIR}/path/passed/on/command_line") + +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/CMakePresets.json.in") # Test bad preset arguments run_cmake_presets(VendorMacro) run_cmake_presets(InvalidGenerator) diff --git a/Tests/RunCMake/CommandLine/install-prefix-no-arg-result.txt b/Tests/RunCMake/CommandLine/install-prefix-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-prefix-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/install-prefix-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/install-prefix-no-arg-stderr.txt new file mode 100644 index 0000000..a464c70 --- /dev/null +++ b/Tests/RunCMake/CommandLine/install-prefix-no-arg-stderr.txt @@ -0,0 +1 @@ +^CMake Error: No install directory specified for --install-prefix diff --git a/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake b/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake index 6530aee..c84e95e 100644 --- a/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake +++ b/Tests/RunCMake/IfacePaths/RunCMakeTest.cmake @@ -79,7 +79,7 @@ foreach(policyStatus NEW OLD "") set(policySuffix -CMP0052-${policyStatus}) endif() set(RunCMake_TEST_OPTIONS - "--install-prefix=${RunCMake_BINARY_DIR}/prefix" ${policyOption} + "--install-prefix ${RunCMake_BINARY_DIR}/prefix" ${policyOption} "-DTEST_FILE=${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface.cmake" ) # Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run -- cgit v0.12 From 400536c3179ddbfedd28dc4739d1b1cd785d02b4 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 9 Mar 2021 14:35:49 -0500 Subject: cmCommandLineArgument: trim leading empty spaces --- Source/cmCommandLineArgument.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/cmCommandLineArgument.h b/Source/cmCommandLineArgument.h index cbedf0a..6b75da0 100644 --- a/Source/cmCommandLineArgument.h +++ b/Source/cmCommandLineArgument.h @@ -110,6 +110,10 @@ struct cmCommandLineArgument } } if (parseState == ParseMode::Valid) { + if (possible_value[0] == ' ') { + possible_value.remove_prefix(1); + } + parseState = this->StoreCall(std::string(possible_value), std::forward(state)...) ? ParseMode::Valid -- cgit v0.12 From bef1cc77effd833c75f6fb526055cba3df115059 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 10 Mar 2021 00:01:13 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ee17d40..c93283a 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210309) +set(CMake_VERSION_PATCH 20210310) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 00ecddd9ebcbfc0cc4c2bd4e49ae56db59b465ea Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 10 Mar 2021 10:04:05 -0500 Subject: Tests: Enable Framework test case with spaces everywhere possible --- Tests/CMakeLists.txt | 1 + Tests/Framework/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 3a05317..0430afb 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -804,6 +804,7 @@ if(BUILD_TESTING) ${build_generator_args} --build-project Framework --build-options + -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES} "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/Framework/Install" --test-command bar) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Framework") diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt index aabf6b4..6e82f86 100644 --- a/Tests/Framework/CMakeLists.txt +++ b/Tests/Framework/CMakeLists.txt @@ -83,7 +83,7 @@ if(NOT XCODE OR NOT XCODE_VERSION VERSION_LESS 5) target_link_libraries(barStatic fooStatic) endif() -if(XCODE) +if(MAKE_SUPPORTS_SPACES AND NOT CMAKE_GENERATOR STREQUAL "Watcom WMake") add_library(space SHARED space.c) set_target_properties(space PROPERTIES FRAMEWORK TRUE -- cgit v0.12 From 088444211e942a3587f4af5ef76c3654f2562364 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 4 Mar 2021 11:50:10 -0500 Subject: file: add `COPY_FILE` subcommand The `file(COPY)` subcommand is overloaded and busy for such a simple operation. Instead, make a simpler subcommand with error handling support. --- Help/command/file.rst | 23 ++++++ Help/release/dev/file-COPY_FILE.rst | 4 + Source/cmFileCommand.cxx | 92 ++++++++++++++++++++++ .../RunCMake/file/COPY_FILE-arg-missing-result.txt | 1 + .../RunCMake/file/COPY_FILE-arg-missing-stderr.txt | 3 + Tests/RunCMake/file/COPY_FILE-arg-missing.cmake | 1 + .../RunCMake/file/COPY_FILE-arg-unknown-result.txt | 1 + .../RunCMake/file/COPY_FILE-arg-unknown-stderr.txt | 5 ++ Tests/RunCMake/file/COPY_FILE-arg-unknown.cmake | 1 + .../file/COPY_FILE-dir-to-file-capture-stdout.txt | 1 + .../file/COPY_FILE-dir-to-file-capture.cmake | 8 ++ .../file/COPY_FILE-dir-to-file-fail-result.txt | 1 + .../file/COPY_FILE-dir-to-file-fail-stderr.txt | 6 ++ .../RunCMake/file/COPY_FILE-dir-to-file-fail.cmake | 4 + .../COPY_FILE-dirlink-to-file-capture-stdout.txt | 1 + .../file/COPY_FILE-dirlink-to-file-capture.cmake | 8 ++ .../file/COPY_FILE-dirlink-to-file-fail-result.txt | 1 + .../file/COPY_FILE-dirlink-to-file-fail-stderr.txt | 6 ++ .../file/COPY_FILE-dirlink-to-file-fail.cmake | 4 + .../COPY_FILE-file-ONLY_IF_DIFFERENT-capture.cmake | 9 +++ ...OPY_FILE-file-ONLY_IF_DIFFERENT-fail-result.txt | 1 + ...OPY_FILE-file-ONLY_IF_DIFFERENT-fail-stderr.txt | 6 ++ .../COPY_FILE-file-ONLY_IF_DIFFERENT-fail.cmake | 5 ++ ..._FILE-file-ONLY_IF_DIFFERENT-no-overwrite.cmake | 12 +++ Tests/RunCMake/file/COPY_FILE-file-replace.cmake | 9 +++ .../file/COPY_FILE-file-to-dir-capture-stdout.txt | 1 + .../file/COPY_FILE-file-to-dir-capture.cmake | 9 +++ .../file/COPY_FILE-file-to-dir-fail-result.txt | 1 + .../file/COPY_FILE-file-to-dir-fail-stderr.txt | 6 ++ .../RunCMake/file/COPY_FILE-file-to-dir-fail.cmake | 5 ++ Tests/RunCMake/file/COPY_FILE-file-to-file.cmake | 10 +++ Tests/RunCMake/file/COPY_FILE-link-to-file.cmake | 10 +++ Tests/RunCMake/file/RunCMakeTest.cmake | 15 ++++ 33 files changed, 270 insertions(+) create mode 100644 Help/release/dev/file-COPY_FILE.rst create mode 100644 Tests/RunCMake/file/COPY_FILE-arg-missing-result.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-arg-missing-stderr.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-arg-missing.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-arg-unknown-result.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-arg-unknown-stderr.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-arg-unknown.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-dir-to-file-capture-stdout.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-dir-to-file-capture.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-result.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-stderr.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-dir-to-file-fail.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture-stdout.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-result.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-stderr.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-capture.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-result.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-stderr.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-replace.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-to-dir-capture-stdout.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-file-to-dir-capture.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-result.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-stderr.txt create mode 100644 Tests/RunCMake/file/COPY_FILE-file-to-dir-fail.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-file-to-file.cmake create mode 100644 Tests/RunCMake/file/COPY_FILE-link-to-file.cmake diff --git a/Help/command/file.rst b/Help/command/file.rst index 9cde90c..445a408 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -39,6 +39,7 @@ Synopsis `Filesystem`_ file({`GLOB`_ | `GLOB_RECURSE`_} [...] [...]) file(`RENAME`_ [...]) + file(`COPY_FILE`_ [...]) file({`REMOVE`_ | `REMOVE_RECURSE`_ } [...]) file(`MAKE_DIRECTORY`_ [...]) file({`COPY`_ | `INSTALL`_} ... DESTINATION [...]) @@ -683,6 +684,28 @@ The options are: If ``RESULT `` is used, the result variable will be set to ``NO_REPLACE``. Otherwise, an error is emitted. +.. _COPY_FILE: + +.. code-block:: cmake + + file(COPY_FILE + [RESULT ] + [ONLY_IF_DIFFERENT]) + +Copy a file from ```` to ````. Directories are not +supported. Symlinks are ignored and ````'s content is read and +written to ```` as a new file. + +The options are: + +``RESULT `` + Set ```` variable to ``0`` on success or an error message otherwise. + If ``RESULT`` is not specified and the operation fails, an error is emitted. + +``ONLY_IF_DIFFERENT`` + If the ```` path already exists, do not replace it if it is the + same as ````. Otherwise, an error is emitted. + .. _REMOVE: .. _REMOVE_RECURSE: diff --git a/Help/release/dev/file-COPY_FILE.rst b/Help/release/dev/file-COPY_FILE.rst new file mode 100644 index 0000000..2f0cdf0 --- /dev/null +++ b/Help/release/dev/file-COPY_FILE.rst @@ -0,0 +1,4 @@ +file-COPY_ONLY +-------------- + +* The :command:`file(COPY_FILE)` command was added to copy a file to another. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 065b845..1c73d0d 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1379,6 +1379,97 @@ bool HandleRename(std::vector const& args, return false; } +bool HandleCopyFile(std::vector const& args, + cmExecutionStatus& status) +{ + if (args.size() < 3) { + status.SetError("COPY_FILE must be called with at least two additional " + "arguments"); + return false; + } + + // Compute full path for old and new names. + std::string oldname = args[1]; + if (!cmsys::SystemTools::FileIsFullPath(oldname)) { + oldname = + cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', args[1]); + } + std::string newname = args[2]; + if (!cmsys::SystemTools::FileIsFullPath(newname)) { + newname = + cmStrCat(status.GetMakefile().GetCurrentSourceDirectory(), '/', args[2]); + } + + struct Arguments + { + bool OnlyIfDifferent = false; + std::string Result; + }; + + static auto const parser = + cmArgumentParser{} + .Bind("ONLY_IF_DIFFERENT"_s, &Arguments::OnlyIfDifferent) + .Bind("RESULT"_s, &Arguments::Result); + + std::vector unconsumedArgs; + Arguments const arguments = + parser.Parse(cmMakeRange(args).advance(3), &unconsumedArgs); + if (!unconsumedArgs.empty()) { + status.SetError("COPY_FILE unknown argument:\n " + + unconsumedArgs.front()); + return false; + } + + bool result = true; + if (cmsys::SystemTools::FileIsDirectory(oldname)) { + if (!arguments.Result.empty()) { + status.GetMakefile().AddDefinition(arguments.Result, + "cannot copy a directory"); + } else { + status.SetError( + cmStrCat("COPY_FILE cannot copy a directory\n ", oldname)); + result = false; + } + return result; + } + if (cmsys::SystemTools::FileIsDirectory(newname)) { + if (!arguments.Result.empty()) { + status.GetMakefile().AddDefinition(arguments.Result, + "cannot copy to a directory"); + } else { + status.SetError( + cmStrCat("COPY_FILE cannot copy to a directory\n ", newname)); + result = false; + } + return result; + } + + cmSystemTools::CopyWhen when; + if (arguments.OnlyIfDifferent) { + when = cmSystemTools::CopyWhen::OnlyIfDifferent; + } else { + when = cmSystemTools::CopyWhen::Always; + } + + std::string err; + if (cmSystemTools::CopySingleFile(oldname, newname, when, &err) == + cmSystemTools::CopyResult::Success) { + if (!arguments.Result.empty()) { + status.GetMakefile().AddDefinition(arguments.Result, "0"); + } + } else { + if (!arguments.Result.empty()) { + status.GetMakefile().AddDefinition(arguments.Result, err); + } else { + status.SetError(cmStrCat("COPY_FILE failed to copy\n ", oldname, + "\nto\n ", newname, "\nbecause: ", err, "\n")); + result = false; + } + } + + return result; +} + bool HandleRemoveImpl(std::vector const& args, bool recurse, cmExecutionStatus& status) { @@ -3609,6 +3700,7 @@ bool cmFileCommand(std::vector const& args, { "GLOB_RECURSE"_s, HandleGlobRecurseCommand }, { "MAKE_DIRECTORY"_s, HandleMakeDirectoryCommand }, { "RENAME"_s, HandleRename }, + { "COPY_FILE"_s, HandleCopyFile }, { "REMOVE"_s, HandleRemove }, { "REMOVE_RECURSE"_s, HandleRemoveRecurse }, { "COPY"_s, HandleCopyCommand }, diff --git a/Tests/RunCMake/file/COPY_FILE-arg-missing-result.txt b/Tests/RunCMake/file/COPY_FILE-arg-missing-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-arg-missing-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/COPY_FILE-arg-missing-stderr.txt b/Tests/RunCMake/file/COPY_FILE-arg-missing-stderr.txt new file mode 100644 index 0000000..2ba38b6 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-arg-missing-stderr.txt @@ -0,0 +1,3 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file/COPY_FILE-arg-missing.cmake:1 \(file\): + file COPY_FILE must be called with at least two additional arguments diff --git a/Tests/RunCMake/file/COPY_FILE-arg-missing.cmake b/Tests/RunCMake/file/COPY_FILE-arg-missing.cmake new file mode 100644 index 0000000..0e56c38 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-arg-missing.cmake @@ -0,0 +1 @@ +file(COPY_FILE "old") diff --git a/Tests/RunCMake/file/COPY_FILE-arg-unknown-result.txt b/Tests/RunCMake/file/COPY_FILE-arg-unknown-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-arg-unknown-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/COPY_FILE-arg-unknown-stderr.txt b/Tests/RunCMake/file/COPY_FILE-arg-unknown-stderr.txt new file mode 100644 index 0000000..e5ccd33 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-arg-unknown-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file/COPY_FILE-arg-unknown.cmake:1 \(file\): + file COPY_FILE unknown argument: + + unknown$ diff --git a/Tests/RunCMake/file/COPY_FILE-arg-unknown.cmake b/Tests/RunCMake/file/COPY_FILE-arg-unknown.cmake new file mode 100644 index 0000000..835f39e --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-arg-unknown.cmake @@ -0,0 +1 @@ +file(COPY_FILE "old" "new" unknown) diff --git a/Tests/RunCMake/file/COPY_FILE-dir-to-file-capture-stdout.txt b/Tests/RunCMake/file/COPY_FILE-dir-to-file-capture-stdout.txt new file mode 100644 index 0000000..45b3d27 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dir-to-file-capture-stdout.txt @@ -0,0 +1 @@ +^-- file\(COPY_FILE\) failed with result: cannot copy a directory diff --git a/Tests/RunCMake/file/COPY_FILE-dir-to-file-capture.cmake b/Tests/RunCMake/file/COPY_FILE-dir-to-file-capture.cmake new file mode 100644 index 0000000..acec05a --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dir-to-file-capture.cmake @@ -0,0 +1,8 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(MAKE_DIRECTORY "${oldname}") +file(COPY_FILE "${oldname}" "${newname}" RESULT result) +message(STATUS "file(COPY_FILE) failed with result: ${result}") +if(EXISTS "${newname}") + message(FATAL_ERROR "The new name exists:\n ${newname}") +endif() diff --git a/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-result.txt b/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-stderr.txt b/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-stderr.txt new file mode 100644 index 0000000..2fe8bec --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail.cmake:[0-9] \(file\): + file COPY_FILE cannot copy a directory + + [^ +]*/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail-build/input diff --git a/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail.cmake b/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail.cmake new file mode 100644 index 0000000..a86ba8d --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dir-to-file-fail.cmake @@ -0,0 +1,4 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(MAKE_DIRECTORY "${oldname}") +file(COPY_FILE "${oldname}" "${newname}") diff --git a/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture-stdout.txt b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture-stdout.txt new file mode 100644 index 0000000..45b3d27 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture-stdout.txt @@ -0,0 +1 @@ +^-- file\(COPY_FILE\) failed with result: cannot copy a directory diff --git a/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture.cmake b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture.cmake new file mode 100644 index 0000000..acec05a --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-capture.cmake @@ -0,0 +1,8 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(MAKE_DIRECTORY "${oldname}") +file(COPY_FILE "${oldname}" "${newname}" RESULT result) +message(STATUS "file(COPY_FILE) failed with result: ${result}") +if(EXISTS "${newname}") + message(FATAL_ERROR "The new name exists:\n ${newname}") +endif() diff --git a/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-result.txt b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-stderr.txt b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-stderr.txt new file mode 100644 index 0000000..c58dc2c --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail.cmake:[0-9] \(file\): + file COPY_FILE cannot copy a directory + + [^ +]*/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail-build/input diff --git a/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail.cmake b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail.cmake new file mode 100644 index 0000000..a86ba8d --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-dirlink-to-file-fail.cmake @@ -0,0 +1,4 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(MAKE_DIRECTORY "${oldname}") +file(COPY_FILE "${oldname}" "${newname}") diff --git a/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-capture.cmake b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-capture.cmake new file mode 100644 index 0000000..028220e --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-capture.cmake @@ -0,0 +1,9 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +file(MAKE_DIRECTORY "${newname}") +file(COPY_FILE "${oldname}" "${newname}" RESULT result ONLY_IF_DIFFERENT) +message(STATUS "file(COPY_FILE) failed with result: ${result}") +if(NOT EXISTS "${oldname}") + message(FATAL_ERROR "The old name still does not exist:\n ${oldname}") +endif() diff --git a/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-result.txt b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-stderr.txt b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-stderr.txt new file mode 100644 index 0000000..fd5ceee --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail.cmake:[0-9] \(file\): + file COPY_FILE cannot copy to a directory + + [^ +]*/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail-build/output diff --git a/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail.cmake b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail.cmake new file mode 100644 index 0000000..a56b4e7 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-fail.cmake @@ -0,0 +1,5 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +file(MAKE_DIRECTORY "${newname}") +file(COPY_FILE "${oldname}" "${newname}" ONLY_IF_DIFFERENT) diff --git a/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite.cmake b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite.cmake new file mode 100644 index 0000000..059a308 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite.cmake @@ -0,0 +1,12 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +execute_process(COMMAND "${CMAKE_COMMAND} -E sleep 1") +file(WRITE "${newname}" "") +file(TIMESTAMP "${newname}" before_copy UTC) +file(COPY_FILE "${oldname}" "${newname}" RESULT result ONLY_IF_DIFFERENT) +file(TIMESTAMP "${newname}" after_copy UTC) +if (NOT before_copy STREQUAL after_copy) + message(FATAL_ERROR + "${newname} was modified even though ONLY_IF_DIFFERENT was specified") +endif () diff --git a/Tests/RunCMake/file/COPY_FILE-file-replace.cmake b/Tests/RunCMake/file/COPY_FILE-file-replace.cmake new file mode 100644 index 0000000..40e4290 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-replace.cmake @@ -0,0 +1,9 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "a") +file(WRITE "${newname}" "b") +file(COPY_FILE "${oldname}" "${newname}") +file(READ "${newname}" new) +if(NOT "${new}" STREQUAL "a") + message(FATAL_ERROR "New name:\n ${newname}\ndoes not contain expected content 'a'.") +endif() diff --git a/Tests/RunCMake/file/COPY_FILE-file-to-dir-capture-stdout.txt b/Tests/RunCMake/file/COPY_FILE-file-to-dir-capture-stdout.txt new file mode 100644 index 0000000..24f969f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-to-dir-capture-stdout.txt @@ -0,0 +1 @@ +^-- file\(COPY_FILE\) failed with result: cannot copy to a directory diff --git a/Tests/RunCMake/file/COPY_FILE-file-to-dir-capture.cmake b/Tests/RunCMake/file/COPY_FILE-file-to-dir-capture.cmake new file mode 100644 index 0000000..98621c6 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-to-dir-capture.cmake @@ -0,0 +1,9 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +file(MAKE_DIRECTORY "${newname}") +file(COPY_FILE "${oldname}" "${newname}" RESULT result) +message(STATUS "file(COPY_FILE) failed with result: ${result}") +if(NOT EXISTS "${oldname}") + message(FATAL_ERROR "The old name does not exist:\n ${oldname}") +endif() diff --git a/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-result.txt b/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-stderr.txt b/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-stderr.txt new file mode 100644 index 0000000..ba2a027 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at [^ +]*/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail.cmake:[0-9] \(file\): + file COPY_FILE cannot copy to a directory + + [^ +]*/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail-build/output diff --git a/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail.cmake b/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail.cmake new file mode 100644 index 0000000..c2628dd --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-to-dir-fail.cmake @@ -0,0 +1,5 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +file(MAKE_DIRECTORY "${newname}") +file(COPY_FILE "${oldname}" "${newname}") diff --git a/Tests/RunCMake/file/COPY_FILE-file-to-file.cmake b/Tests/RunCMake/file/COPY_FILE-file-to-file.cmake new file mode 100644 index 0000000..26b702a --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-file-to-file.cmake @@ -0,0 +1,10 @@ +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${oldname}" "") +file(COPY_FILE "${oldname}" "${newname}") +if(NOT EXISTS "${oldname}") + message(FATAL_ERROR "The old name does not exist:\n ${oldname}") +endif() +if(NOT EXISTS "${newname}") + message(FATAL_ERROR "The new name does not exist:\n ${newname}") +endif() diff --git a/Tests/RunCMake/file/COPY_FILE-link-to-file.cmake b/Tests/RunCMake/file/COPY_FILE-link-to-file.cmake new file mode 100644 index 0000000..93a0204 --- /dev/null +++ b/Tests/RunCMake/file/COPY_FILE-link-to-file.cmake @@ -0,0 +1,10 @@ +set(lnkname "${CMAKE_CURRENT_BINARY_DIR}/link") +set(oldname "${CMAKE_CURRENT_BINARY_DIR}/input") +set(newname "${CMAKE_CURRENT_BINARY_DIR}/output") +file(WRITE "${lnkname}" "a") +file(CREATE_LINK "${lnkname}" "${oldname}") +file(COPY_FILE "${oldname}" "${newname}") +file(READ "${newname}" new) +if(NOT "${new}" STREQUAL "a") + message(FATAL_ERROR "New name:\n ${newname}\ndoes not contain expected content 'a'.") +endif() diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index f74832c..b4ea9ba 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -50,6 +50,21 @@ run_cmake(SIZE-error-does-not-exist) run_cmake(REMOVE-empty) +run_cmake_script(COPY_FILE-file-replace) +run_cmake_script(COPY_FILE-dir-to-file-capture) +run_cmake_script(COPY_FILE-dir-to-file-fail) +run_cmake_script(COPY_FILE-dirlink-to-file-capture) +run_cmake_script(COPY_FILE-dirlink-to-file-fail) +run_cmake_script(COPY_FILE-file-to-file) +run_cmake_script(COPY_FILE-file-to-dir-capture) +run_cmake_script(COPY_FILE-file-to-dir-fail) +run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-capture) +run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-fail) +run_cmake_script(COPY_FILE-file-ONLY_IF_DIFFERENT-no-overwrite) +run_cmake_script(COPY_FILE-link-to-file) +run_cmake_script(COPY_FILE-arg-missing) +run_cmake_script(COPY_FILE-arg-unknown) + run_cmake_script(RENAME-file-replace) run_cmake_script(RENAME-file-to-file) run_cmake_script(RENAME-file-to-dir-capture) -- cgit v0.12 From f42b048b9ca35d8637de6caa2bc6dad8904793dc Mon Sep 17 00:00:00 2001 From: Olivier Iffrig Date: Fri, 5 Mar 2021 18:41:23 +0000 Subject: Tests: Check symlinks to directories in RunCMake.CPackSymlinks Regression test for issue #21886 --- Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake | 1 + .../RunCMake/CPackSymlinks/SrcSymlinksCheck.cmake | 21 +++++++++++++++++++++ .../CPackSymlinks/SrcSymlinksTar-stdout.txt | 7 +++---- Tests/RunCMake/CPackSymlinks/testcpacksym.tar | Bin 10240 -> 20480 bytes 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/CPackSymlinks/SrcSymlinksCheck.cmake diff --git a/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake b/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake index 439d95e..5a8b7a0 100644 --- a/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPackSymlinks/RunCMakeTest.cmake @@ -15,6 +15,7 @@ function(run_cpack_symlink_test) run_cmake_command(SrcSymlinksCPack ${CMAKE_CPACK_COMMAND} --config CPackSourceConfig.cmake ) + run_cmake_script(SrcSymlinksCheck) endfunction() run_cpack_symlink_test() diff --git a/Tests/RunCMake/CPackSymlinks/SrcSymlinksCheck.cmake b/Tests/RunCMake/CPackSymlinks/SrcSymlinksCheck.cmake new file mode 100644 index 0000000..0041c92 --- /dev/null +++ b/Tests/RunCMake/CPackSymlinks/SrcSymlinksCheck.cmake @@ -0,0 +1,21 @@ +set(dir ${CMAKE_CURRENT_SOURCE_DIR}) + +set(tarball ${dir}/SrcSymlinks-0.1-Source.tar.gz) +set(extrdir ${dir}/SrcSymlinks-0.1-Source) + +message(STATUS "Extracting ${tarball} in ${dir}...") +execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ${tarball} + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE output + WORKING_DIRECTORY ${dir}) +message(STATUS "result='${result}'") +message(STATUS "output='${output}'") + +if(NOT ${result} EQUAL 0) + message(FATAL_ERROR "Cannot unpack source tarball") +endif() + +if(NOT EXISTS ${extrdir}/dirlink/src.h) + message(FATAL_ERROR "${extrdir}/dirlink/src.h not found") +endif() diff --git a/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt b/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt index 24ad124..8b1ae57 100644 --- a/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt +++ b/Tests/RunCMake/CPackSymlinks/SrcSymlinksTar-stdout.txt @@ -1,7 +1,6 @@ -^x CMakeLists.txt -x cygwin/ -x cygwin/build.sh -x cygwin/setup.patch +^x build.sh +x CMakeLists.txt +x dirlink x include/ x include/src.h x link.h diff --git a/Tests/RunCMake/CPackSymlinks/testcpacksym.tar b/Tests/RunCMake/CPackSymlinks/testcpacksym.tar index a44c656..c24af48 100644 Binary files a/Tests/RunCMake/CPackSymlinks/testcpacksym.tar and b/Tests/RunCMake/CPackSymlinks/testcpacksym.tar differ -- cgit v0.12 From 8dacf533a90a89c6812e9081c3632c9f60158bc0 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 11 Mar 2021 00:01:17 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c93283a..b0ed132 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210310) +set(CMake_VERSION_PATCH 20210311) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 01cc8bf93084d91d0a1e2258a3b7307ef5ec5852 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 2 Mar 2021 15:05:32 -0500 Subject: ExternalData: use `file(COPY_FILE)` instead of forking CMake --- Modules/ExternalData.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index b439636..032e423 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -944,7 +944,7 @@ function(_ExternalData_link_or_copy src dst) execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${tgt}" "${tmp}" RESULT_VARIABLE result) else() # Create a copy. - execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${src}" "${tmp}" RESULT_VARIABLE result) + file(COPY_FILE "${src}" "${tmp}" RESULT result) endif() if(result) file(REMOVE "${tmp}") -- cgit v0.12 From b6c022eaa27abcc265a5961b22e5e0c44df88752 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 2 Mar 2021 14:51:22 -0500 Subject: ExternalData: use `file(CREATE_LINK)` This avoids spawning a new CMake command which isn't necessary. --- Modules/ExternalData.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 032e423..1850e74 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -941,7 +941,8 @@ function(_ExternalData_link_or_copy src dst) file(RELATIVE_PATH tgt "${dst_dir}" "${src}") endif() endif() - execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${tgt}" "${tmp}" RESULT_VARIABLE result) + # Create link (falling back to copying if there's a problem). + file(CREATE_LINK "${tgt}" "${tmp}" RESULT result COPY_ON_ERROR SYMBOLIC) else() # Create a copy. file(COPY_FILE "${src}" "${tmp}" RESULT result) -- cgit v0.12 From bb9a701a2b90f002c87c01b4a9f8019f2c7f8385 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 11 Mar 2021 08:55:05 -0500 Subject: CMakePrintHelpers: Work around CACHE argument of set() Fixes: #21919 --- Modules/CMakePrintHelpers.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/CMakePrintHelpers.cmake b/Modules/CMakePrintHelpers.cmake index d652ffa..8c25a73 100644 --- a/Modules/CMakePrintHelpers.cmake +++ b/Modules/CMakePrintHelpers.cmake @@ -101,7 +101,10 @@ function(cmake_print_properties) if(CPP_CACHE_ENTRIES) set(items ${CPP_CACHE_ENTRIES}) set(mode ${mode} CACHE_ENTRIES) - set(keyword CACHE) + # This is a workaround for the fact that passing `CACHE` as an argument to + # set() causes a cache variable to be set. + set(keyword "") + string(APPEND keyword CACHE) endif() if(NOT mode) -- cgit v0.12 From 887e0c6c7b2ea0d3489b72afb5c60b93e402a23f Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 12 Mar 2021 00:01:17 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b0ed132..e5a0bec 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210311) +set(CMake_VERSION_PATCH 20210312) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 74eda8ab1f21ad7ba37dd1fa4f21e158f01d7f1c Mon Sep 17 00:00:00 2001 From: Yauheni Khnykin Date: Mon, 8 Mar 2021 17:57:35 +0100 Subject: Tests: Add XCTest cases to cover output directory selection Fixes: #21800 --- Tests/RunCMake/XcodeProject/RunCMakeTest.cmake | 26 +++++++++++++++++++++++ Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake | 17 +++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 8b03216..c8b75eb 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -387,4 +387,30 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 8) XcodeRemoveExcessiveISystemSDK(iphoneos) XcodeRemoveExcessiveISystemSDK(iphonesimulator) endif() + +if (XCODE_VERSION VERSION_GREATER_EQUAL 7.3) + function(xctest_add_bundle_test SystemName SDK BuildSystemVersion ExpectedOutputDir) + set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/DeploymentTarget-${SystemName}-${SDK}-${BuildSystemVersion}-build) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_SYSTEM_NAME=${SystemName}" + "-DCMAKE_OSX_SYSROOT=${SDK}" + "-DTEST_EXPECTED_OUTPUT_DIR=${ExpectedOutputDir}") + unset(RunCMake_GENERATOR_TOOLSET) + if(BuildSystemVersion) + set(RunCMake_GENERATOR_TOOLSET "buildsystem=${BuildSystemVersion}") + endif() + run_cmake(XCTestAddBundle) + endfunction() + + if(XCODE_VERSION VERSION_GREATER_EQUAL 12) + xctest_add_bundle_test(Darwin macosx "1" "$/PlugIns") + xctest_add_bundle_test(Darwin macosx "12" "$/PlugIns") + xctest_add_bundle_test(iOS iphoneos "1" "$/PlugIns") + xctest_add_bundle_test(iOS iphoneos "12" "$") + else() + xctest_add_bundle_test(Darwin macosx "" "$/PlugIns") + xctest_add_bundle_test(iOS iphoneos "" "$/PlugIns") + endif() +endif() # Please add macOS-only tests above before the device-specific tests. diff --git a/Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake b/Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake new file mode 100644 index 0000000..444c730 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XCTestAddBundle.cmake @@ -0,0 +1,17 @@ +enable_language(Swift) +find_package(XCTest REQUIRED) + +add_executable(TestedApp MACOSX_BUNDLE EXCLUDE_FROM_ALL foo.swift) + +xctest_add_bundle(TestingAppBundle TestedApp foo.swift) + +get_target_property(_lib_output_dir TestingAppBundle LIBRARY_OUTPUT_DIRECTORY) + +if (NOT DEFINED TEST_EXPECTED_OUTPUT_DIR) + message(FATAL_ERROR "Testing variable TEST_EXPECTED_OUTPUT_DIR is not set") +endif() + +if (NOT _lib_output_dir STREQUAL TEST_EXPECTED_OUTPUT_DIR) + message(SEND_ERROR "Property LIBRARY_OUTPUT_DIRECTORY is expected to be ${TEST_EXPECTED_OUTPUT_DIR} " + "but was ${_lib_output_dir}") +endif() -- cgit v0.12 From 982f7bb5063453d3c0be102c917bb660ec21978b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 13 Mar 2021 00:01:18 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e5a0bec..46a7dee 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210312) +set(CMake_VERSION_PATCH 20210313) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 12624ebd7ee1380b5e5aa0bc3bcbb03c4d9aec73 Mon Sep 17 00:00:00 2001 From: vvs31415 Date: Sat, 13 Mar 2021 07:00:00 -0500 Subject: Source: Reduce c_str() usage --- .../CTest/cmCTestEmptyBinaryDirectoryCommand.cxx | 2 +- Source/CTest/cmCTestRunScriptCommand.cxx | 4 ++-- Source/CTest/cmCTestScriptHandler.cxx | 23 ++++++++++------------ Source/CTest/cmCTestScriptHandler.h | 12 ++++++----- Source/CTest/cmCTestTestHandler.cxx | 10 ++++------ Source/cmCTest.cxx | 6 +++--- Source/cmFindLibraryCommand.cxx | 2 +- Source/cmListCommand.cxx | 12 +++++------ Source/cmOrderDirectories.cxx | 2 +- Source/cmStringCommand.cxx | 4 ++-- Source/cmcmd.cxx | 20 +++++++++---------- 11 files changed, 47 insertions(+), 50 deletions(-) diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx index 051c117..af495bb 100644 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx @@ -16,7 +16,7 @@ bool cmCTestEmptyBinaryDirectoryCommand::InitialPass( return false; } - if (!cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str())) { + if (!cmCTestScriptHandler::EmptyBinaryDirectory(args[0])) { std::ostringstream ostr; ostr << "problem removing the binary directory: " << args[0]; this->SetError(ostr.str()); diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx index f59ca57..7661d4d 100644 --- a/Source/CTest/cmCTestRunScriptCommand.cxx +++ b/Source/CTest/cmCTestRunScriptCommand.cxx @@ -37,8 +37,8 @@ bool cmCTestRunScriptCommand::InitialPass(std::vector const& args, ++i; } else { int ret; - cmCTestScriptHandler::RunScript(this->CTest, this->Makefile, - args[i].c_str(), !np, &ret); + cmCTestScriptHandler::RunScript(this->CTest, this->Makefile, args[i], + !np, &ret); this->Makefile->AddDefinition(returnVariable, std::to_string(ret)); } } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4808c36..ff0b179 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -91,7 +90,7 @@ void cmCTestScriptHandler::Initialize() cmCTestScriptHandler::~cmCTestScriptHandler() = default; // just adds an argument to the vector -void cmCTestScriptHandler::AddConfigurationScript(const char* script, +void cmCTestScriptHandler::AddConfigurationScript(const std::string& script, bool pscope) { this->ConfigurationScripts.emplace_back(script); @@ -676,7 +675,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // clear the binary directory? if (this->EmptyBinDir) { - if (!cmCTestScriptHandler::EmptyBinaryDirectory(this->BinaryDir.c_str())) { + if (!cmCTestScriptHandler::EmptyBinaryDirectory(this->BinaryDir)) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem removing the binary directory" << std::endl); } @@ -724,8 +723,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // put the initial cache into the bin dir if (!this->InitialCache.empty()) { - if (!cmCTestScriptHandler::WriteInitialCache(this->BinaryDir.c_str(), - this->InitialCache.c_str())) { + if (!cmCTestScriptHandler::WriteInitialCache(this->BinaryDir, + this->InitialCache)) { this->RestoreBackupDirectories(); return 9; } @@ -812,8 +811,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard() return 0; } -bool cmCTestScriptHandler::WriteInitialCache(const char* directory, - const char* text) +bool cmCTestScriptHandler::WriteInitialCache(const std::string& directory, + const std::string& text) { std::string cacheFile = cmStrCat(directory, "/CMakeCache.txt"); cmGeneratedFileStream fout(cacheFile); @@ -821,9 +820,7 @@ bool cmCTestScriptHandler::WriteInitialCache(const char* directory, return false; } - if (text != nullptr) { - fout.write(text, strlen(text)); - } + fout.write(text.data(), text.size()); // Make sure the operating system has finished writing the file // before closing it. This will ensure the file is finished before @@ -852,7 +849,7 @@ void cmCTestScriptHandler::RestoreBackupDirectories() } bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf, - const char* sname, bool InProcess, + const std::string& sname, bool InProcess, int* returnValue) { auto sh = cm::make_unique(); @@ -866,10 +863,10 @@ bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf, return true; } -bool cmCTestScriptHandler::EmptyBinaryDirectory(const char* sname) +bool cmCTestScriptHandler::EmptyBinaryDirectory(const std::string& sname) { // try to avoid deleting root - if (!sname || strlen(sname) < 2) { + if (sname.size() < 2) { return false; } diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h index 8eb9658..b7764b2 100644 --- a/Source/CTest/cmCTestScriptHandler.h +++ b/Source/CTest/cmCTestScriptHandler.h @@ -62,7 +62,7 @@ public: /** * Add a script to run, and if is should run in the current process */ - void AddConfigurationScript(const char*, bool pscope); + void AddConfigurationScript(const std::string&, bool pscope); /** * Run a dashboard using a specified confiuration script @@ -72,19 +72,21 @@ public: /* * Run a script */ - static bool RunScript(cmCTest* ctest, cmMakefile* mf, const char* script, - bool InProcess, int* returnValue); + static bool RunScript(cmCTest* ctest, cmMakefile* mf, + const std::string& script, bool InProcess, + int* returnValue); int RunCurrentScript(); /* * Empty Binary Directory */ - static bool EmptyBinaryDirectory(const char* dir); + static bool EmptyBinaryDirectory(const std::string& dir); /* * Write an initial CMakeCache.txt from the given contents. */ - static bool WriteInitialCache(const char* directory, const char* text); + static bool WriteInitialCache(const std::string& directory, + const std::string& text); /* * Some elapsed time handling functions diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 1cb5d00..42c4d5e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1705,18 +1705,16 @@ bool cmCTestTestHandler::ParseResourceGroupsProperty( bool cmCTestTestHandler::GetListOfTests() { if (!this->IncludeLabelRegExp.empty()) { - this->IncludeLabelRegularExpression.compile( - this->IncludeLabelRegExp.c_str()); + this->IncludeLabelRegularExpression.compile(this->IncludeLabelRegExp); } if (!this->ExcludeLabelRegExp.empty()) { - this->ExcludeLabelRegularExpression.compile( - this->ExcludeLabelRegExp.c_str()); + this->ExcludeLabelRegularExpression.compile(this->ExcludeLabelRegExp); } if (!this->IncludeRegExp.empty()) { - this->IncludeTestsRegularExpression.compile(this->IncludeRegExp.c_str()); + this->IncludeTestsRegularExpression.compile(this->IncludeRegExp); } if (!this->ExcludeRegExp.empty()) { - this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp.c_str()); + this->ExcludeTestsRegularExpression.compile(this->ExcludeRegExp); } cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Constructing a list of tests" << std::endl, this->Quiet); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 620ba19..77b4441 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2221,7 +2221,7 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector& args, cmCTestScriptHandler* ch = this->GetScriptHandler(); // -SR is an internal argument, -SP should be ignored when it is passed if (!SRArgumentSpecified) { - ch->AddConfigurationScript(args[i].c_str(), false); + ch->AddConfigurationScript(args[i], false); } } @@ -2231,7 +2231,7 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector& args, this->Impl->RunConfigurationScript = true; i++; cmCTestScriptHandler* ch = this->GetScriptHandler(); - ch->AddConfigurationScript(args[i].c_str(), true); + ch->AddConfigurationScript(args[i], true); } if (this->CheckArgument(arg, "-S"_s, "--script") && i < args.size() - 1) { @@ -2240,7 +2240,7 @@ void cmCTest::HandleScriptArguments(size_t& i, std::vector& args, cmCTestScriptHandler* ch = this->GetScriptHandler(); // -SR is an internal argument, -S should be ignored when it is passed if (!SRArgumentSpecified) { - ch->AddConfigurationScript(args[i].c_str(), true); + ch->AddConfigurationScript(args[i], true); } } } diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 49b1bd7..d85ba8f 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -374,7 +374,7 @@ void cmFindLibraryHelper::AddName(std::string const& name) regex += "(\\.[0-9]+\\.[0-9]+)?"; } regex += "$"; - entry.Regex.compile(regex.c_str()); + entry.Regex.compile(regex); this->Names.push_back(std::move(entry)); } diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 1bafdf7..09cd88e 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -34,7 +34,7 @@ namespace { -bool GetIndexArg(char const* arg, int* idx, cmMakefile& mf) +bool GetIndexArg(const std::string& arg, int* idx, cmMakefile& mf) { long value; if (!cmStrToLong(arg, &value)) { @@ -189,7 +189,7 @@ bool HandleGetCommand(std::vector const& args, size_t nitem = varArgsExpanded.size(); for (cc = 2; cc < args.size() - 1; cc++) { int item; - if (!GetIndexArg(args[cc].c_str(), &item, status.GetMakefile())) { + if (!GetIndexArg(args[cc], &item, status.GetMakefile())) { status.SetError(cmStrCat("index: ", args[cc], " is not a valid index")); return false; } @@ -401,7 +401,7 @@ bool HandleInsertCommand(std::vector const& args, // expand the variable int item; - if (!GetIndexArg(args[2].c_str(), &item, status.GetMakefile())) { + if (!GetIndexArg(args[2], &item, status.GetMakefile())) { status.SetError(cmStrCat("index: ", args[2], " is not a valid index")); return false; } @@ -1326,11 +1326,11 @@ bool HandleSublistCommand(std::vector const& args, int start; int length; - if (!GetIndexArg(args[2].c_str(), &start, status.GetMakefile())) { + if (!GetIndexArg(args[2], &start, status.GetMakefile())) { status.SetError(cmStrCat("index: ", args[2], " is not a valid index")); return false; } - if (!GetIndexArg(args[3].c_str(), &length, status.GetMakefile())) { + if (!GetIndexArg(args[3], &length, status.GetMakefile())) { status.SetError(cmStrCat("index: ", args[3], " is not a valid index")); return false; } @@ -1389,7 +1389,7 @@ bool HandleRemoveAtCommand(std::vector const& args, size_t nitem = varArgsExpanded.size(); for (cc = 2; cc < args.size(); ++cc) { int item; - if (!GetIndexArg(args[cc].c_str(), &item, status.GetMakefile())) { + if (!GetIndexArg(args[cc], &item, status.GetMakefile())) { status.SetError(cmStrCat("index: ", args[cc], " is not a valid index")); return false; } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 0369af0..68f40a9 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -359,7 +359,7 @@ void cmOrderDirectories::SetLinkExtensionInfo( std::string const& removeExtRegex) { this->LinkExtensions = linkExtensions; - this->RemoveLibraryExtension.compile(removeExtRegex.c_str()); + this->RemoveLibraryExtension.compile(removeExtRegex); } void cmOrderDirectories::CollectOriginalDirectories() diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 23fc3e0..5fa309d 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -241,7 +241,7 @@ bool RegexMatch(std::vector const& args, status.GetMakefile().ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; - if (!re.compile(regex.c_str())) { + if (!re.compile(regex)) { std::string e = "sub-command REGEX, mode MATCH failed to compile regex \"" + regex + "\"."; @@ -283,7 +283,7 @@ bool RegexMatchAll(std::vector const& args, status.GetMakefile().ClearMatches(); // Compile the regular expression. cmsys::RegularExpression re; - if (!re.compile(regex.c_str())) { + if (!re.compile(regex)) { std::string e = "sub-command REGEX, mode MATCHALL failed to compile regex \"" + regex + "\"."; diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 6713cc3..9ba4b93 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -74,7 +74,7 @@ int cmcmd_cmake_ninja_dyndep(std::vector::const_iterator argBeg, std::vector::const_iterator argEnd); namespace { -void CMakeCommandUsage(const char* program) +void CMakeCommandUsage(std::string const& program) { std::ostringstream errorStream; @@ -704,7 +704,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, } else if (args[2] == "--ignore-eol") { filesDiffer = cmsys::SystemTools::TextFilesDiffer(args[3], args[4]); } else { - CMakeCommandUsage(args[0].c_str()); + CMakeCommandUsage(args[0]); return 2; } @@ -1085,7 +1085,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, std::string const& directory = args[2]; if (!cmSystemTools::FileExists(directory)) { cmSystemTools::Error("Directory does not exist for chdir command: " + - args[2]); + directory); return 1; } @@ -1152,7 +1152,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, << "\n"; return 1; } - if (!cmSystemTools::CreateSymlink(args[2], args[3])) { + if (!cmSystemTools::CreateSymlink(args[2], destinationFileName)) { return 1; } return 0; @@ -1161,12 +1161,12 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, // Command to create a hard link. Fails on platforms not // supporting them. if (args[1] == "create_hardlink" && args.size() == 4) { - const char* SouceFileName = args[2].c_str(); - const char* destinationFileName = args[3].c_str(); + std::string const& sourceFileName = args[2]; + std::string const& destinationFileName = args[3]; - if (!cmSystemTools::FileExists(SouceFileName)) { + if (!cmSystemTools::FileExists(sourceFileName)) { std::cerr << "failed to create hard link because source path '" - << SouceFileName << "' does not exist \n"; + << sourceFileName << "' does not exist \n"; return 1; } @@ -1180,7 +1180,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, return 1; } - if (!cmSystemTools::CreateLink(args[2], args[3])) { + if (!cmSystemTools::CreateLink(sourceFileName, destinationFileName)) { return 1; } return 0; @@ -1560,7 +1560,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, } } - CMakeCommandUsage(args[0].c_str()); + CMakeCommandUsage(args[0]); return 1; } -- cgit v0.12 From d4053aabce9c10a83dc3522a599ae12846689050 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 14 Mar 2021 00:01:09 -0500 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 46a7dee..ed4368d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210313) +set(CMake_VERSION_PATCH 20210314) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 948b379e26a4d64490ceea894649d907b4fa2fef Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 15 Mar 2021 00:01:19 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ed4368d..ff82f8f 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210314) +set(CMake_VERSION_PATCH 20210315) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From c13f75982f784cc85f6c0a88c6efe917fe3b72c7 Mon Sep 17 00:00:00 2001 From: Elsie Hupp <9206310+elsiehupp@users.noreply.github.com> Date: Sun, 14 Mar 2021 17:35:20 -0400 Subject: Help: Clarify configure_file #cmakedefine01 syntax and behavior Fixes: #21935 --- Help/command/configure_file.rst | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Help/command/configure_file.rst b/Help/command/configure_file.rst index 63ea84d..8f082e8 100644 --- a/Help/command/configure_file.rst +++ b/Help/command/configure_file.rst @@ -36,8 +36,30 @@ or depending on whether ``VAR`` is set in CMake to any value not considered a false constant by the :command:`if` command. The "..." content on the line after the variable name, if any, is processed as above. -Input file lines of the form ``#cmakedefine01 VAR`` will be replaced with -either ``#define VAR 1`` or ``#define VAR 0`` similarly. + +Unlike lines of the form ``#cmakedefine VAR ...``, in lines of the form +``#cmakedefine01 VAR``, ``VAR`` itself will expand to ``VAR 0`` or ``VAR 1`` +rather than being assigned the value ``...``. Therefore, input lines of the form + +.. code-block:: c + + #cmakedefine01 VAR + +will be replaced with either + +.. code-block:: c + + #define VAR 0 + +or + +.. code-block:: c + + #define VAR 1 + +Input lines of the form ``#cmakedefine01 VAR ...`` will expand +as ``#cmakedefine01 VAR ... 0`` or ``#cmakedefine01 VAR ... 0``, +which may lead to undefined behavior. .. versionadded:: 3.10 The result lines (with the exception of the ``#undef`` comments) can be -- cgit v0.12 From ad19da011d5702da3407a17bf45f3d39ec651639 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 11 Mar 2021 12:02:13 -0500 Subject: Refactor: Add cmSystemTools::GetSystemName() And use it for CMAKE_HOST_SYSTEM_NAME and CMAKE_SYSTEM_NAME. --- Help/release/dev/cmake-system-name-version.rst | 10 +++++ Modules/CMakeDetermineSystem.cmake | 39 ++++-------------- Source/cmStateSnapshot.cxx | 55 ++++++++++---------------- Source/cmSystemTools.cxx | 47 ++++++++++++++++++++++ Source/cmSystemTools.h | 3 ++ 5 files changed, 88 insertions(+), 66 deletions(-) create mode 100644 Help/release/dev/cmake-system-name-version.rst diff --git a/Help/release/dev/cmake-system-name-version.rst b/Help/release/dev/cmake-system-name-version.rst new file mode 100644 index 0000000..9cfe401 --- /dev/null +++ b/Help/release/dev/cmake-system-name-version.rst @@ -0,0 +1,10 @@ +cmake-system-name-version +------------------------- + +* :variable:`CMAKE_HOST_SYSTEM_NAME`'s undocumented version-stripping behavior + has been moved earlier, before :command:`project` or + :command:`enable_language` is called. +* :variable:`CMAKE_SYSTEM_NAME`'s undocumented version-stripping behavior has + been removed entirely. If it is set by a ``-D`` flag or by a + :manual:`toolchain file `, it is left unaltered, even if + it still contains a version number. diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index bae270d..c3f2b74 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -158,37 +158,14 @@ endif() include(Platform/${CMAKE_SYSTEM_NAME}-Determine OPTIONAL) -macro(ADJUST_CMAKE_SYSTEM_VARIABLES _PREFIX) - if(NOT ${_PREFIX}_NAME) - set(${_PREFIX}_NAME "UnknownOS") - endif() - - # fix for BSD/OS , remove the / - if(${_PREFIX}_NAME MATCHES BSD.OS) - set(${_PREFIX}_NAME BSDOS) - endif() - - # fix for GNU/kFreeBSD, remove the GNU/ - if(${_PREFIX}_NAME MATCHES kFreeBSD) - set(${_PREFIX}_NAME kFreeBSD) - endif() - - # fix for CYGWIN which has windows version in it - if(${_PREFIX}_NAME MATCHES CYGWIN) - set(${_PREFIX}_NAME CYGWIN) - endif() - - # set CMAKE_SYSTEM to the CMAKE_SYSTEM_NAME - set(${_PREFIX} ${${_PREFIX}_NAME}) - # if there is a CMAKE_SYSTEM_VERSION then add a -${CMAKE_SYSTEM_VERSION} - if(${_PREFIX}_VERSION) - set(${_PREFIX} ${${_PREFIX}}-${${_PREFIX}_VERSION}) - endif() - -endmacro() - -ADJUST_CMAKE_SYSTEM_VARIABLES(CMAKE_SYSTEM) -ADJUST_CMAKE_SYSTEM_VARIABLES(CMAKE_HOST_SYSTEM) +set(CMAKE_SYSTEM ${CMAKE_SYSTEM_NAME}) +if(CMAKE_SYSTEM_VERSION) + string(APPEND CMAKE_SYSTEM -${CMAKE_SYSTEM_VERSION}) +endif() +set(CMAKE_HOST_SYSTEM ${CMAKE_HOST_SYSTEM_NAME}) +if(CMAKE_HOST_SYSTEM_VERSION) + string(APPEND CMAKE_HOST_SYSTEM -${CMAKE_HOST_SYSTEM_VERSION}) +endif() # this file is also executed from cpack, then we don't need to generate these files # in this case there is no CMAKE_BINARY_DIR diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 1e20abb..fbf47ef 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -16,16 +16,9 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStatePrivate.h" +#include "cmSystemTools.h" #include "cmVersion.h" -#if !defined(_WIN32) -# include -#endif - -#if defined(__CYGWIN__) -# include "cmSystemTools.h" -#endif - cmStateSnapshot::cmStateSnapshot(cmState* state) : State(state) { @@ -292,34 +285,26 @@ void InitializeContentFromParent(T& parentContent, T& thisContent, void cmStateSnapshot::SetDefaultDefinitions() { -/* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. - With CMake must separate between target and host platform. In most cases - the tests for WIN32, UNIX and APPLE will be for the target system, so an - additional set of variables for the host system is required -> - CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. - WIN32, UNIX and APPLE are now set in the platform files in - Modules/Platforms/. - To keep cmake scripts (-P) and custom language and compiler modules - working, these variables are still also set here in this place, but they - will be reset in CMakeSystemSpecificInformation.cmake before the platform - files are executed. */ -#if defined(_WIN32) - this->SetDefinition("WIN32", "1"); - this->SetDefinition("CMAKE_HOST_WIN32", "1"); - this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", "Windows"); -#else - this->SetDefinition("UNIX", "1"); - this->SetDefinition("CMAKE_HOST_UNIX", "1"); - -# if defined(__ANDROID__) - this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", "Android"); -# else - struct utsname uts_name; - if (uname(&uts_name) >= 0) { - this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", uts_name.sysname); + /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. + With CMake must separate between target and host platform. In most cases + the tests for WIN32, UNIX and APPLE will be for the target system, so an + additional set of variables for the host system is required -> + CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. + WIN32, UNIX and APPLE are now set in the platform files in + Modules/Platforms/. + To keep cmake scripts (-P) and custom language and compiler modules + working, these variables are still also set here in this place, but they + will be reset in CMakeSystemSpecificInformation.cmake before the platform + files are executed. */ + cm::string_view hostSystemName = cmSystemTools::GetSystemName(); + this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", hostSystemName); + if (hostSystemName == "Windows") { + this->SetDefinition("WIN32", "1"); + this->SetDefinition("CMAKE_HOST_WIN32", "1"); + } else { + this->SetDefinition("UNIX", "1"); + this->SetDefinition("CMAKE_HOST_UNIX", "1"); } -# endif -#endif #if defined(__CYGWIN__) std::string legacy; if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) && diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 87ba152..e8e1018 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -103,6 +103,10 @@ # include /* for malloc/free on QNX */ #endif +#if !defined(_WIN32) && !defined(__ANDROID__) +# include +#endif + namespace { cmSystemTools::InterruptCallback s_InterruptCallback; @@ -3207,3 +3211,46 @@ bool cmSystemTools::CreateLink(const std::string& origName, return true; } + +cm::string_view cmSystemTools::GetSystemName() +{ +#if defined(_WIN32) + return "Windows"; +#elif defined(__ANDROID__) + return "Android"; +#else + static struct utsname uts_name; + static bool initialized = false; + static cm::string_view systemName; + if (initialized) { + return systemName; + } + if (uname(&uts_name) >= 0) { + initialized = true; + systemName = uts_name.sysname; + + if (cmIsOff(systemName)) { + systemName = "UnknownOS"; + } + + // fix for BSD/OS, remove the / + static const cmsys::RegularExpression bsdOsRegex("BSD.OS"); + cmsys::RegularExpressionMatch match; + if (bsdOsRegex.find(uts_name.sysname, match)) { + systemName = "BSDOS"; + } + + // fix for GNU/kFreeBSD, remove the GNU/ + if (systemName.find("kFreeBSD") != cm::string_view::npos) { + systemName = "kFreeBSD"; + } + + // fix for CYGWIN which has windows version in it + if (systemName.find("CYGWIN") != cm::string_view::npos) { + systemName = "CYGWIN"; + } + return systemName; + } + return ""; +#endif +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 2ff4c5d..5620899 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -498,6 +498,9 @@ public: const std::string& newName, std::string* errorMessage = nullptr); + /** Get the system name. */ + static cm::string_view GetSystemName(); + private: static bool s_ForceUnixPaths; static bool s_RunCommandHideConsole; -- cgit v0.12 From 69527a1979093a5fb103c1940f0f0b17d97b45e2 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 10 Mar 2021 16:30:19 -0500 Subject: Refactor: Pass CMakePresets.json version to ExpandMacros() functions --- Source/cmCMakePresetsFile.cxx | 100 ++++++++++++++++++++++++++---------------- Source/cmCMakePresetsFile.h | 7 +++ 2 files changed, 68 insertions(+), 39 deletions(-) diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index e9e8c4c..e9caecd 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -28,9 +28,9 @@ return _result; \ } -#define CHECK_EXPAND(out, field, expanders) \ +#define CHECK_EXPAND(out, field, expanders, version) \ { \ - switch (ExpandMacros(field, expanders)) { \ + switch (ExpandMacros(field, expanders, version)) { \ case ExpandMacroResult::Error: \ return false; \ case ExpandMacroResult::Ignore: \ @@ -849,16 +849,19 @@ enum class ExpandMacroResult }; using MacroExpander = std::function; + const std::string&, const std::string&, std::string&, int version)>; ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, - const std::vector& macroExpanders); + const std::vector& macroExpanders, + int version); ExpandMacroResult ExpandMacros( - std::string& out, const std::vector& macroExpanders); -ExpandMacroResult ExpandMacro( - std::string& out, const std::string& macroNamespace, - const std::string& macroName, - const std::vector& macroExpanders); + std::string& out, const std::vector& macroExpanders, + int version); +ExpandMacroResult ExpandMacro(std::string& out, + const std::string& macroNamespace, + const std::string& macroName, + const std::vector& macroExpanders, + int version); bool ExpandMacros(const cmCMakePresetsFile& file, const ConfigurePreset& preset, @@ -866,7 +869,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const std::vector& macroExpanders) { std::string binaryDir = preset.BinaryDir; - CHECK_EXPAND(out, binaryDir, macroExpanders) + CHECK_EXPAND(out, binaryDir, macroExpanders, file.GetVersion(preset)) if (!cmSystemTools::FileIsFullPath(binaryDir)) { binaryDir = cmStrCat(file.SourceDir, '/', binaryDir); @@ -876,7 +879,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, if (!preset.InstallDir.empty()) { std::string installDir = preset.InstallDir; - CHECK_EXPAND(out, installDir, macroExpanders) + CHECK_EXPAND(out, installDir, macroExpanders, file.GetVersion(preset)) if (!cmSystemTools::FileIsFullPath(installDir)) { installDir = cmStrCat(file.SourceDir, '/', installDir); @@ -887,67 +890,76 @@ bool ExpandMacros(const cmCMakePresetsFile& file, for (auto& variable : out->CacheVariables) { if (variable.second) { - CHECK_EXPAND(out, variable.second->Value, macroExpanders) + CHECK_EXPAND(out, variable.second->Value, macroExpanders, + file.GetVersion(preset)) } } return true; } -bool ExpandMacros(const cmCMakePresetsFile&, const BuildPreset&, +bool ExpandMacros(const cmCMakePresetsFile& file, const BuildPreset& preset, cm::optional& out, const std::vector& macroExpanders) { for (auto& target : out->Targets) { - CHECK_EXPAND(out, target, macroExpanders) + CHECK_EXPAND(out, target, macroExpanders, file.GetVersion(preset)) } for (auto& nativeToolOption : out->NativeToolOptions) { - CHECK_EXPAND(out, nativeToolOption, macroExpanders) + CHECK_EXPAND(out, nativeToolOption, macroExpanders, + file.GetVersion(preset)) } return true; } -bool ExpandMacros(const cmCMakePresetsFile&, const TestPreset&, +bool ExpandMacros(const cmCMakePresetsFile& file, const TestPreset& preset, cm::optional& out, const std::vector& macroExpanders) { for (auto& overwrite : out->OverwriteConfigurationFile) { - CHECK_EXPAND(out, overwrite, macroExpanders); + CHECK_EXPAND(out, overwrite, macroExpanders, file.GetVersion(preset)); } if (out->Output) { - CHECK_EXPAND(out, out->Output->OutputLogFile, macroExpanders) + CHECK_EXPAND(out, out->Output->OutputLogFile, macroExpanders, + file.GetVersion(preset)) } if (out->Filter) { if (out->Filter->Include) { - CHECK_EXPAND(out, out->Filter->Include->Name, macroExpanders) - CHECK_EXPAND(out, out->Filter->Include->Label, macroExpanders) + CHECK_EXPAND(out, out->Filter->Include->Name, macroExpanders, + file.GetVersion(preset)) + CHECK_EXPAND(out, out->Filter->Include->Label, macroExpanders, + file.GetVersion(preset)) if (out->Filter->Include->Index) { CHECK_EXPAND(out, out->Filter->Include->Index->IndexFile, - macroExpanders); + macroExpanders, file.GetVersion(preset)); } } if (out->Filter->Exclude) { - CHECK_EXPAND(out, out->Filter->Exclude->Name, macroExpanders) - CHECK_EXPAND(out, out->Filter->Exclude->Label, macroExpanders) + CHECK_EXPAND(out, out->Filter->Exclude->Name, macroExpanders, + file.GetVersion(preset)) + CHECK_EXPAND(out, out->Filter->Exclude->Label, macroExpanders, + file.GetVersion(preset)) if (out->Filter->Exclude->Fixtures) { - CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Any, macroExpanders) + CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Any, macroExpanders, + file.GetVersion(preset)) CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Setup, - macroExpanders) + macroExpanders, file.GetVersion(preset)) CHECK_EXPAND(out, out->Filter->Exclude->Fixtures->Cleanup, - macroExpanders) + macroExpanders, file.GetVersion(preset)) } } } if (out->Execution) { - CHECK_EXPAND(out, out->Execution->ResourceSpecFile, macroExpanders) + CHECK_EXPAND(out, out->Execution->ResourceSpecFile, macroExpanders, + file.GetVersion(preset)) } return true; @@ -968,8 +980,8 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, MacroExpander defaultMacroExpander = [&file, &preset](const std::string& macroNamespace, - const std::string& macroName, - std::string& macroOut) -> ExpandMacroResult { + const std::string& macroName, std::string& macroOut, + int /*version*/) -> ExpandMacroResult { if (macroNamespace.empty()) { if (macroName == "sourceDir") { macroOut += file.SourceDir; @@ -1006,11 +1018,12 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, MacroExpander environmentMacroExpander = [¯oExpanders, &out, &envCycles]( const std::string& macroNamespace, const std::string& macroName, - std::string& result) -> ExpandMacroResult { + std::string& result, int version) -> ExpandMacroResult { if (macroNamespace == "env" && !macroName.empty() && out) { auto v = out->Environment.find(macroName); if (v != out->Environment.end() && v->second) { - auto e = VisitEnv(*v->second, envCycles[macroName], macroExpanders); + auto e = + VisitEnv(*v->second, envCycles[macroName], macroExpanders, version); if (e != ExpandMacroResult::Ok) { return e; } @@ -1038,7 +1051,8 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, for (auto& v : out->Environment) { if (v.second) { - switch (VisitEnv(*v.second, envCycles[v.first], macroExpanders)) { + switch (VisitEnv(*v.second, envCycles[v.first], macroExpanders, + file.GetVersion(preset))) { case ExpandMacroResult::Error: return false; case ExpandMacroResult::Ignore: @@ -1054,7 +1068,8 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, } ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, - const std::vector& macroExpanders) + const std::vector& macroExpanders, + int version) { if (status == CycleStatus::Verified) { return ExpandMacroResult::Ok; @@ -1064,7 +1079,7 @@ ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, } status = CycleStatus::InProgress; - auto e = ExpandMacros(value, macroExpanders); + auto e = ExpandMacros(value, macroExpanders, version); if (e != ExpandMacroResult::Ok) { return e; } @@ -1073,7 +1088,8 @@ ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, } ExpandMacroResult ExpandMacros( - std::string& out, const std::vector& macroExpanders) + std::string& out, const std::vector& macroExpanders, + int version) { std::string result; std::string macroNamespace; @@ -1120,8 +1136,8 @@ ExpandMacroResult ExpandMacros( case State::MacroName: if (c == '}') { - auto e = - ExpandMacro(result, macroNamespace, macroName, macroExpanders); + auto e = ExpandMacro(result, macroNamespace, macroName, + macroExpanders, version); if (e != ExpandMacroResult::Ok) { return e; } @@ -1153,10 +1169,11 @@ ExpandMacroResult ExpandMacros( ExpandMacroResult ExpandMacro(std::string& out, const std::string& macroNamespace, const std::string& macroName, - const std::vector& macroExpanders) + const std::vector& macroExpanders, + int version) { for (auto const& macroExpander : macroExpanders) { - auto result = macroExpander(macroNamespace, macroName, out); + auto result = macroExpander(macroNamespace, macroName, out, version); if (result != ExpandMacroResult::Ignore) { return result; } @@ -1549,6 +1566,11 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( if (v < MIN_VERSION || v > MAX_VERSION) { return ReadFileResult::UNRECOGNIZED_VERSION; } + if (user) { + this->UserVersion = v; + } else { + this->Version = v; + } // Support for build and test presets added in version 2. if (v < 2 && diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h index 517215d..eed0eab 100644 --- a/Source/cmCMakePresetsFile.h +++ b/Source/cmCMakePresetsFile.h @@ -294,6 +294,13 @@ public: std::vector TestPresetOrder; std::string SourceDir; + int Version; + int UserVersion; + + int GetVersion(const Preset& preset) const + { + return preset.User ? this->UserVersion : this->Version; + } static std::string GetFilename(const std::string& sourceDir); static std::string GetUserFilename(const std::string& sourceDir); -- cgit v0.12 From 79d03ab5055da1397c525c31d8cb13c30965a911 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Thu, 11 Mar 2021 09:22:37 -0500 Subject: Help: Fix version numbers in CMakePresets.json documentation --- Help/manual/cmake-presets.7.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 3d2ada8..60d0473 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -39,7 +39,7 @@ The root object recognizes the following fields: ``version`` A required integer representing the version of the JSON schema. - The supported versions are ``1`` and ``2``. + The supported versions are ``1``, ``2``, and ``3``. ``cmakeMinimumRequired`` @@ -70,17 +70,17 @@ The root object recognizes the following fields: ``configurePresets`` An optional array of `Configure Preset`_ objects. - This is allowed in preset files specifying version 1 or above. + This is allowed in preset files specifying version ``1`` or above. ``buildPresets`` An optional array of `Build Preset`_ objects. - This is allowed in preset files specifying version 2 or above. + This is allowed in preset files specifying version ``2`` or above. ``testPresets`` An optional array of `Test Preset`_ objects. - This is allowed in preset files specifying version 2 or above. + This is allowed in preset files specifying version ``2`` or above. Configure Preset ^^^^^^^^^^^^^^^^ @@ -187,7 +187,8 @@ that may contain the following fields: An optional string representing the path to the installation directory. This field supports `macro expansion`_. If a relative path is specified, - it is calculated relative to the source directory. + it is calculated relative to the source directory. This is allowed in + preset files specifying version ``3`` or above. ``cmakeExecutable`` -- cgit v0.12 From 0d497e159b5854ed050d9eb8c4e965976a03de11 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 10 Mar 2021 16:46:20 -0500 Subject: CMakePresets.json: Add ${hostSystemName} macro --- Help/manual/cmake-presets.7.rst | 6 ++++++ Help/release/dev/cmake-presets-host-system-name.rst | 5 +++++ Source/cmCMakePresetsFile.cxx | 10 +++++++++- Tests/RunCMake/CMakePresets/HostSystemName.cmake | 3 +++ Tests/RunCMake/CMakePresets/HostSystemName.json.in | 13 +++++++++++++ Tests/RunCMake/CMakePresets/HostSystemNameFuture-result.txt | 1 + Tests/RunCMake/CMakePresets/HostSystemNameFuture-stderr.txt | 2 ++ Tests/RunCMake/CMakePresets/HostSystemNameFuture.json.in | 13 +++++++++++++ Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 6 ++++++ 9 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 Help/release/dev/cmake-presets-host-system-name.rst create mode 100644 Tests/RunCMake/CMakePresets/HostSystemName.cmake create mode 100644 Tests/RunCMake/CMakePresets/HostSystemName.json.in create mode 100644 Tests/RunCMake/CMakePresets/HostSystemNameFuture-result.txt create mode 100644 Tests/RunCMake/CMakePresets/HostSystemNameFuture-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/HostSystemNameFuture.json.in diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 60d0473..5273236 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -830,6 +830,12 @@ Recognized macros include: test presets, this will evaluate to the generator specified by ``configurePreset``. +``${hostSystemName}`` + + The name of the host operating system. Contains the same value as + :variable:`CMAKE_HOST_SYSTEM_NAME`. This is allowed in preset files + specifying version ``3`` or above. + ``${dollar}`` A literal dollar sign (``$``). diff --git a/Help/release/dev/cmake-presets-host-system-name.rst b/Help/release/dev/cmake-presets-host-system-name.rst new file mode 100644 index 0000000..8036939 --- /dev/null +++ b/Help/release/dev/cmake-presets-host-system-name.rst @@ -0,0 +1,5 @@ +cmake-presets-host-system-name +------------------------------ + +* :manual:`cmake-presets(7)` gained support for a new ``${hostSystemName}`` + macro. diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index e9caecd..7726927 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -981,7 +982,7 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, MacroExpander defaultMacroExpander = [&file, &preset](const std::string& macroNamespace, const std::string& macroName, std::string& macroOut, - int /*version*/) -> ExpandMacroResult { + int version) -> ExpandMacroResult { if (macroNamespace.empty()) { if (macroName == "sourceDir") { macroOut += file.SourceDir; @@ -1010,6 +1011,13 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, macroOut += '$'; return ExpandMacroResult::Ok; } + if (macroName == "hostSystemName") { + if (version < 3) { + return ExpandMacroResult::Error; + } + macroOut += cmSystemTools::GetSystemName(); + return ExpandMacroResult::Ok; + } } return ExpandMacroResult::Ignore; diff --git a/Tests/RunCMake/CMakePresets/HostSystemName.cmake b/Tests/RunCMake/CMakePresets/HostSystemName.cmake new file mode 100644 index 0000000..dc0998a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HostSystemName.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(TEST_HOST_SYSTEM_NAME "" "${CMAKE_HOST_SYSTEM_NAME}") diff --git a/Tests/RunCMake/CMakePresets/HostSystemName.json.in b/Tests/RunCMake/CMakePresets/HostSystemName.json.in new file mode 100644 index 0000000..7fcd8c8 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HostSystemName.json.in @@ -0,0 +1,13 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "HostSystemName", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_HOST_SYSTEM_NAME": "${hostSystemName}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/HostSystemNameFuture-result.txt b/Tests/RunCMake/CMakePresets/HostSystemNameFuture-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HostSystemNameFuture-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/HostSystemNameFuture-stderr.txt b/Tests/RunCMake/CMakePresets/HostSystemNameFuture-stderr.txt new file mode 100644 index 0000000..7f4bb9a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HostSystemNameFuture-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/HostSystemNameFuture: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/HostSystemNameFuture.json.in b/Tests/RunCMake/CMakePresets/HostSystemNameFuture.json.in new file mode 100644 index 0000000..7a2f0aa --- /dev/null +++ b/Tests/RunCMake/CMakePresets/HostSystemNameFuture.json.in @@ -0,0 +1,13 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "HostSystemNameFuture", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "TEST_HOST_SYSTEM_NAME": "${hostSystemName}" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index ee21130..24ac0e9 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -261,6 +261,12 @@ set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Debug.json.in") run_cmake_presets(NoDebug) run_cmake_presets(Debug) +# Test ${hostSystemName} macro +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/HostSystemName.json.in") +run_cmake_presets(HostSystemName) +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/HostSystemNameFuture.json.in") +run_cmake_presets(HostSystemNameFuture) + # Test the example from the documentation file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example) string(REPLACE "\"generator\": \"Ninja\"" "\"generator\": \"@RunCMake_GENERATOR@\"" _example "${_example}") -- cgit v0.12 From 55233eee424816843bb0a5c820d3d4ebbdf3da27 Mon Sep 17 00:00:00 2001 From: Tobias Ribizel Date: Wed, 10 Mar 2021 14:55:43 +0100 Subject: CUDA: Add support for finding nvcc in CUDA_PATH Previously, nvcc needed to be present in PATH or specified by CUDACXX. On Windows with vcpkg, the PATH is heavily modified, which lead to nvcc not being found with the Ninja generator. --- Modules/CMakeDetermineCUDACompiler.cmake | 2 ++ Modules/CMakeDetermineCompiler.cmake | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 1ba537a..0f507ea 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -31,7 +31,9 @@ else() set(CMAKE_CUDA_COMPILER_LIST nvcc) endif() + set(_CMAKE_CUDA_COMPILER_PATHS "$ENV{CUDA_PATH}/bin") _cmake_find_compiler(CUDA) + unset(_CMAKE_CUDA_COMPILER_PATHS) else() _cmake_find_compiler_path(CUDA) endif() diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake index 2780399..6430793 100644 --- a/Modules/CMakeDetermineCompiler.cmake +++ b/Modules/CMakeDetermineCompiler.cmake @@ -68,6 +68,16 @@ macro(_cmake_find_compiler lang) ) endif() find_program(CMAKE_${lang}_COMPILER NAMES ${CMAKE_${lang}_COMPILER_LIST} DOC "${lang} compiler") + if(_CMAKE_${lang}_COMPILER_PATHS) + # As a last fall-back, search in language-specific paths + find_program(CMAKE_${lang}_COMPILER + NAMES ${CMAKE_${lang}_COMPILER_LIST} + NAMES_PER_DIR + PATHS ${_CMAKE_${lang}_COMPILER_PATHS} + DOC "${lang} compiler" + NO_DEFAULT_PATH + ) + endif() if(CMAKE_${lang}_COMPILER_INIT AND NOT CMAKE_${lang}_COMPILER) set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${CMAKE_${lang}_COMPILER_INIT}") endif() -- cgit v0.12 From 0cf1b5c5adca7061f5d65eef602eca180c8fecb7 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 16 Mar 2021 00:01:17 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ff82f8f..7c6d284 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210315) +set(CMake_VERSION_PATCH 20210316) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From ea430582f96a085e1b4d7c5125d5ca8a2266e48b Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 5 Mar 2021 11:40:22 -0500 Subject: cmInstallTargetGenerator: Drop unused GetNamelinkMode method --- Source/cmInstallTargetGenerator.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 8c5d444..b94c2a6 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -39,7 +39,6 @@ public: NamelinkModeSkip }; void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; } - NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; } std::string GetInstallFilename(const std::string& config) const; -- cgit v0.12 From f73b6879e9f93157bc3bec26ee319cf67e6b026a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 5 Mar 2021 11:41:06 -0500 Subject: cmInstallTargetGenerator: Report namelink mode with list of files --- Source/cmInstallTargetGenerator.cxx | 1 + Source/cmInstallTargetGenerator.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index bef785d..eb214fa 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -338,6 +338,7 @@ cmInstallTargetGenerator::Files cmInstallTargetGenerator::GetFiles( // Add the names based on the current namelink mode. if (haveNamelink) { + files.NamelinkMode = this->NamelinkMode; // With a namelink we need to check the mode. if (this->NamelinkMode == NamelinkModeOnly) { // Install the namelink only. diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index b94c2a6..84fce42 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -81,6 +81,7 @@ public: // Prefix for all files in To. std::string ToDir; + NamelinkModeType NamelinkMode = NamelinkModeNone; bool NoTweak = false; bool UseSourcePermissions = false; cmInstallType Type = cmInstallType(); -- cgit v0.12 From 415ead81533ead72fca8a495c3cbc17e2bf4e400 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 11 Jan 2021 10:19:38 -0500 Subject: cmFileAPICodemodel: Build map from each target to its index --- Source/cmFileAPICodemodel.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 9061109..596edd1 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -46,6 +46,9 @@ namespace { +using TargetIndexMapType = + std::unordered_map; + class Codemodel { cmFileAPI& FileAPI; @@ -94,6 +97,8 @@ class CodemodelConfig ProjectMap; std::vector Projects; + TargetIndexMapType TargetIndexMap; + void ProcessDirectories(); Json::ArrayIndex GetDirectoryIndex(cmLocalGenerator const* lg); @@ -663,6 +668,8 @@ Json::Value CodemodelConfig::DumpTarget(cmGeneratorTarget* gt, target["projectIndex"] = pi; this->Projects[pi].TargetIndexes.append(ti); + this->TargetIndexMap[gt] = ti; + return target; } -- cgit v0.12 From fd30bd93e6f4334a9cd317a1e5eb8181fffa7a42 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 11 Jan 2021 09:17:05 -0500 Subject: fileapi: Re-organize backtrace infrastructure Make it available to more parts of the codemodel object. --- Help/manual/cmake-file-api.7.rst | 76 ++++++------ Source/cmFileAPICodemodel.cxx | 168 +++++++++++++-------------- Tests/RunCMake/FileAPI/codemodel-v2-check.py | 5 +- 3 files changed, 128 insertions(+), 121 deletions(-) diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index 89739b7..133282d 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -964,40 +964,48 @@ with members: with forward slashes. ``backtraceGraph`` - A JSON object describing the graph of backtraces whose nodes are - referenced from ``backtrace`` members elsewhere. The members are: - - ``nodes`` - A JSON array listing nodes in the backtrace graph. Each entry - is a JSON object with members: - - ``file`` - An unsigned integer 0-based index into the backtrace ``files`` array. - - ``line`` - An optional member present when the node represents a line within - the file. The value is an unsigned integer 1-based line number. - - ``command`` - An optional member present when the node represents a command - invocation within the file. The value is an unsigned integer - 0-based index into the backtrace ``commands`` array. - - ``parent`` - An optional member present when the node is not the bottom of - the call stack. The value is an unsigned integer 0-based index - of another entry in the backtrace ``nodes`` array. - - ``commands`` - A JSON array listing command names referenced by backtrace nodes. - Each entry is a string specifying a command name. - - ``files`` - A JSON array listing CMake language files referenced by backtrace nodes. - Each entry is a string specifying the path to a file, represented - with forward slashes. If the file is inside the top-level source - directory then the path is specified relative to that directory. - Otherwise the path is absolute. + A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced + from ``backtrace`` members elsewhere in this "target" object. + +"codemodel" version 2 "backtrace graph" +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The ``backtraceGraph`` member of a `"codemodel" version 2 "target" object`_ +is a JSON object describing a graph of backtraces. Its nodes are referenced +from ``backtrace`` members elsewhere in the containing object. +The backtrace graph object members are: + +``nodes`` + A JSON array listing nodes in the backtrace graph. Each entry + is a JSON object with members: + + ``file`` + An unsigned integer 0-based index into the backtrace ``files`` array. + + ``line`` + An optional member present when the node represents a line within + the file. The value is an unsigned integer 1-based line number. + + ``command`` + An optional member present when the node represents a command + invocation within the file. The value is an unsigned integer + 0-based index into the backtrace ``commands`` array. + + ``parent`` + An optional member present when the node is not the bottom of + the call stack. The value is an unsigned integer 0-based index + of another entry in the backtrace ``nodes`` array. + +``commands`` + A JSON array listing command names referenced by backtrace nodes. + Each entry is a string specifying a command name. + +``files`` + A JSON array listing CMake language files referenced by backtrace nodes. + Each entry is a string specifying the path to a file, represented + with forward slashes. If the file is inside the top-level source + directory then the path is specified relative to that directory. + Otherwise the path is absolute. Object Kind "cache" ------------------- diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 596edd1..ed6ac8e 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -49,80 +49,6 @@ namespace { using TargetIndexMapType = std::unordered_map; -class Codemodel -{ - cmFileAPI& FileAPI; - unsigned long Version; - - Json::Value DumpPaths(); - Json::Value DumpConfigurations(); - Json::Value DumpConfiguration(std::string const& config); - -public: - Codemodel(cmFileAPI& fileAPI, unsigned long version); - Json::Value Dump(); -}; - -class CodemodelConfig -{ - cmFileAPI& FileAPI; - unsigned long Version; - std::string const& Config; - std::string TopSource; - std::string TopBuild; - - struct Directory - { - cmStateSnapshot Snapshot; - cmLocalGenerator const* LocalGenerator = nullptr; - Json::Value TargetIndexes = Json::arrayValue; - Json::ArrayIndex ProjectIndex; - bool HasInstallRule = false; - }; - std::map - DirectoryMap; - std::vector Directories; - - struct Project - { - cmStateSnapshot Snapshot; - static const Json::ArrayIndex NoParentIndex = - static_cast(-1); - Json::ArrayIndex ParentIndex = NoParentIndex; - Json::Value ChildIndexes = Json::arrayValue; - Json::Value DirectoryIndexes = Json::arrayValue; - Json::Value TargetIndexes = Json::arrayValue; - }; - std::map - ProjectMap; - std::vector Projects; - - TargetIndexMapType TargetIndexMap; - - void ProcessDirectories(); - - Json::ArrayIndex GetDirectoryIndex(cmLocalGenerator const* lg); - Json::ArrayIndex GetDirectoryIndex(cmStateSnapshot s); - - Json::ArrayIndex AddProject(cmStateSnapshot s); - - Json::Value DumpTargets(); - Json::Value DumpTarget(cmGeneratorTarget* gt, Json::ArrayIndex ti); - - Json::Value DumpDirectories(); - Json::Value DumpDirectory(Directory& d); - - Json::Value DumpProjects(); - Json::Value DumpProject(Project& p); - - Json::Value DumpMinimumCMakeVersion(cmStateSnapshot s); - -public: - CodemodelConfig(cmFileAPI& fileAPI, unsigned long version, - std::string const& config); - Json::Value Dump(); -}; - std::string RelativeIfUnder(std::string const& top, std::string const& in) { std::string out; @@ -136,16 +62,6 @@ std::string RelativeIfUnder(std::string const& top, std::string const& in) return out; } -std::string TargetId(cmGeneratorTarget const* gt, std::string const& topBuild) -{ - cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_256); - std::string path = RelativeIfUnder( - topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory()); - std::string hash = hasher.HashString(path); - hash.resize(20, '0'); - return gt->GetName() + CMAKE_DIRECTORY_ID_SEP + hash; -} - class JBTIndex { public: @@ -295,6 +211,90 @@ Json::Value BacktraceData::Dump() return backtraceGraph; } +class Codemodel +{ + cmFileAPI& FileAPI; + unsigned long Version; + + Json::Value DumpPaths(); + Json::Value DumpConfigurations(); + Json::Value DumpConfiguration(std::string const& config); + +public: + Codemodel(cmFileAPI& fileAPI, unsigned long version); + Json::Value Dump(); +}; + +class CodemodelConfig +{ + cmFileAPI& FileAPI; + unsigned long Version; + std::string const& Config; + std::string TopSource; + std::string TopBuild; + + struct Directory + { + cmStateSnapshot Snapshot; + cmLocalGenerator const* LocalGenerator = nullptr; + Json::Value TargetIndexes = Json::arrayValue; + Json::ArrayIndex ProjectIndex; + bool HasInstallRule = false; + }; + std::map + DirectoryMap; + std::vector Directories; + + struct Project + { + cmStateSnapshot Snapshot; + static const Json::ArrayIndex NoParentIndex = + static_cast(-1); + Json::ArrayIndex ParentIndex = NoParentIndex; + Json::Value ChildIndexes = Json::arrayValue; + Json::Value DirectoryIndexes = Json::arrayValue; + Json::Value TargetIndexes = Json::arrayValue; + }; + std::map + ProjectMap; + std::vector Projects; + + TargetIndexMapType TargetIndexMap; + + void ProcessDirectories(); + + Json::ArrayIndex GetDirectoryIndex(cmLocalGenerator const* lg); + Json::ArrayIndex GetDirectoryIndex(cmStateSnapshot s); + + Json::ArrayIndex AddProject(cmStateSnapshot s); + + Json::Value DumpTargets(); + Json::Value DumpTarget(cmGeneratorTarget* gt, Json::ArrayIndex ti); + + Json::Value DumpDirectories(); + Json::Value DumpDirectory(Directory& d); + + Json::Value DumpProjects(); + Json::Value DumpProject(Project& p); + + Json::Value DumpMinimumCMakeVersion(cmStateSnapshot s); + +public: + CodemodelConfig(cmFileAPI& fileAPI, unsigned long version, + std::string const& config); + Json::Value Dump(); +}; + +std::string TargetId(cmGeneratorTarget const* gt, std::string const& topBuild) +{ + cmCryptoHash hasher(cmCryptoHash::AlgoSHA3_256); + std::string path = RelativeIfUnder( + topBuild, gt->GetLocalGenerator()->GetCurrentBinaryDirectory()); + std::string hash = hasher.HashString(path); + hash.resize(20, '0'); + return gt->GetName() + CMAKE_DIRECTORY_ID_SEP + hash; +} + struct CompileData { struct IncludeEntry diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index df2410a..e155037 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -94,8 +94,7 @@ def check_directory(c): return _check -def check_target_backtrace_graph(t): - btg = t["backtraceGraph"] +def check_backtrace_graph(btg): assert is_dict(btg) assert sorted(btg.keys()) == ["commands", "files", "nodes"] assert is_list(btg["commands"]) @@ -148,7 +147,7 @@ def check_target(c): assert is_string(obj["name"], expected["name"]) assert matches(obj["id"], expected["id"]) assert is_string(obj["type"], expected["type"]) - check_target_backtrace_graph(obj) + check_backtrace_graph(obj["backtraceGraph"]) assert is_dict(obj["paths"]) assert sorted(obj["paths"].keys()) == ["build", "source"] -- cgit v0.12 From a12d7f70b1b97f74293d9861a1827c88ef46ec39 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 14 Jan 2021 15:10:49 -0500 Subject: fileapi: Add a "directory" object to codemodel-v2 This object will contain more detailed directory-level information. Co-Authored-by: Kyle Edwards --- Help/manual/cmake-file-api.7.rst | 37 +++++++- Help/release/dev/fileapi-codemodel-directory.rst | 8 ++ Source/cmFileAPI.cxx | 2 +- Source/cmFileAPICodemodel.cxx | 72 ++++++++++++++- .../RunCMake/CommandLine/E_capabilities-stdout.txt | 2 +- .../codemodel-v2-ClientStateful-check.cmake | 1 + .../codemodel-v2-ClientStateless-check.cmake | 1 + .../codemodel-v2-SharedStateless-check.cmake | 1 + Tests/RunCMake/FileAPI/codemodel-v2-check.py | 22 ++++- .../codemodel-v2-data/directories/external.json | 2 +- .../codemodel-v2-data/targets/c_shared_lib.json | 101 ++++++++++++++++++++- .../codemodel-v2-data/targets/cxx_shared_lib.json | 95 ++++++++++++++++++- Tests/RunCMake/FileAPI/codemodel-v2.cmake | 17 +++- Tests/RunCMake/FileAPI/cxx/CMakeLists.txt | 2 +- .../RunCMake/FileAPIExternalSource/CMakeLists.txt | 3 + 15 files changed, 351 insertions(+), 15 deletions(-) create mode 100644 Help/release/dev/fileapi-codemodel-directory.rst diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index 133282d..7c34d51 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -443,7 +443,8 @@ Version 1 does not exist to avoid confusion with that from "hasInstallRule": true, "minimumCMakeVersion": { "string": "3.14" - } + }, + "jsonFile": "" }, { "source": "sub", @@ -453,7 +454,8 @@ Version 1 does not exist to avoid confusion with that from "targetIndexes": [ 1 ], "minimumCMakeVersion": { "string": "3.14" - } + }, + "jsonFile": "" } ], "projects": [ @@ -569,6 +571,13 @@ The members specific to ``codemodel`` objects are: :command:`install` rules, i.e. whether a ``make install`` or equivalent rule is available. + ``jsonFile`` + A JSON string specifying a path relative to the codemodel file + to another JSON file containing a + `"codemodel" version 2 "directory" object`_. + + This field was added in codemodel version 2.3. + ``projects`` A JSON array of entries corresponding to the top-level project and sub-projects defined in the build system. Each (sub-)project @@ -633,6 +642,30 @@ The members specific to ``codemodel`` objects are: to another JSON file containing a `"codemodel" version 2 "target" object`_. +"codemodel" version 2 "directory" object +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A codemodel "directory" object is referenced by a `"codemodel" version 2`_ +object's ``directories`` array. Each "directory" object is a JSON object +with members: + +``paths`` + A JSON object containing members: + + ``source`` + A string specifying the path to the source directory, represented + with forward slashes. If the directory is inside the top-level + source directory then the path is specified relative to that + directory (with ``.`` for the top-level source directory itself). + Otherwise the path is absolute. + + ``build`` + A string specifying the path to the build directory, represented + with forward slashes. If the directory is inside the top-level + build directory then the path is specified relative to that + directory (with ``.`` for the top-level build directory itself). + Otherwise the path is absolute. + "codemodel" version 2 "target" object ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/release/dev/fileapi-codemodel-directory.rst b/Help/release/dev/fileapi-codemodel-directory.rst new file mode 100644 index 0000000..7dffb96 --- /dev/null +++ b/Help/release/dev/fileapi-codemodel-directory.rst @@ -0,0 +1,8 @@ +fileapi-codemodel-directory +--------------------------- + +* The :manual:`cmake-file-api(7)` "codemodel" version 2 ``version`` field has + component been updated to 2.3. + +* The :manual:`cmake-file-api(7)` "codemodel" version 2 gained a + new "directory" object containing directory-level information. diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index d2a9bec..d529f52 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -686,7 +686,7 @@ std::string cmFileAPI::NoSupportedVersion( // The "codemodel" object kind. -static unsigned int const CodeModelV2Minor = 2; +static unsigned int const CodeModelV2Minor = 3; void cmFileAPI::BuildClientRequestCodeModel( ClientRequest& r, std::vector const& versions) diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index ed6ac8e..2f36db2 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -273,6 +273,7 @@ class CodemodelConfig Json::Value DumpDirectories(); Json::Value DumpDirectory(Directory& d); + Json::Value DumpDirectoryObject(Directory& d); Json::Value DumpProjects(); Json::Value DumpProject(Project& p); @@ -372,6 +373,20 @@ struct hash } // namespace std namespace { +class DirectoryObject +{ + cmLocalGenerator const* LG = nullptr; + std::string const& Config; + std::string TopSource; + std::string TopBuild; + + Json::Value DumpPaths(); + +public: + DirectoryObject(cmLocalGenerator const* lg, std::string const& config); + Json::Value Dump(); +}; + class Target { cmGeneratorTarget* GT; @@ -684,7 +699,7 @@ Json::Value CodemodelConfig::DumpDirectories() Json::Value CodemodelConfig::DumpDirectory(Directory& d) { - Json::Value directory = Json::objectValue; + Json::Value directory = this->DumpDirectoryObject(d); std::string sourceDir = d.Snapshot.GetDirectory().GetCurrentSource(); directory["source"] = RelativeIfUnder(this->TopSource, sourceDir); @@ -724,6 +739,31 @@ Json::Value CodemodelConfig::DumpDirectory(Directory& d) return directory; } +Json::Value CodemodelConfig::DumpDirectoryObject(Directory& d) +{ + std::string prefix = "directory"; + std::string sourceDirRel = RelativeIfUnder( + this->TopSource, d.Snapshot.GetDirectory().GetCurrentSource()); + std::string buildDirRel = RelativeIfUnder( + this->TopBuild, d.Snapshot.GetDirectory().GetCurrentBinary()); + if (!cmSystemTools::FileIsFullPath(buildDirRel)) { + prefix = cmStrCat(prefix, '-', buildDirRel); + } else if (!cmSystemTools::FileIsFullPath(sourceDirRel)) { + prefix = cmStrCat(prefix, '-', sourceDirRel); + } + for (char& c : prefix) { + if (c == '/' || c == '\\') { + c = '.'; + } + } + if (!this->Config.empty()) { + prefix += "-" + this->Config; + } + + DirectoryObject dir(d.LocalGenerator, this->Config); + return this->FileAPI.MaybeJsonFile(dir.Dump(), prefix); +} + Json::Value CodemodelConfig::DumpProjects() { Json::Value projects = Json::arrayValue; @@ -767,6 +807,36 @@ Json::Value CodemodelConfig::DumpMinimumCMakeVersion(cmStateSnapshot s) return minimumCMakeVersion; } +DirectoryObject::DirectoryObject(cmLocalGenerator const* lg, + std::string const& config) + : LG(lg) + , Config(config) + , TopSource(lg->GetGlobalGenerator()->GetCMakeInstance()->GetHomeDirectory()) + , TopBuild( + lg->GetGlobalGenerator()->GetCMakeInstance()->GetHomeOutputDirectory()) +{ +} + +Json::Value DirectoryObject::Dump() +{ + Json::Value directoryObject = Json::objectValue; + directoryObject["paths"] = this->DumpPaths(); + return directoryObject; +} + +Json::Value DirectoryObject::DumpPaths() +{ + Json::Value paths = Json::objectValue; + + std::string const& sourceDir = this->LG->GetCurrentSourceDirectory(); + paths["source"] = RelativeIfUnder(this->TopSource, sourceDir); + + std::string const& buildDir = this->LG->GetCurrentBinaryDirectory(); + paths["build"] = RelativeIfUnder(this->TopBuild, buildDir); + + return paths; +} + Target::Target(cmGeneratorTarget* gt, std::string const& config) : GT(gt) , Config(config) diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index c76c92d..3df3e52 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":2}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]},{"kind":"toolchains","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":false,"version":{.*}}$ +^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":3}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]},{"kind":"toolchains","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":false,"version":{.*}}$ diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake index fb78e87..91cdf7c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake @@ -4,6 +4,7 @@ set(expect query/client-foo/query.json reply reply/codemodel-v2-[0-9a-f]+\\.json + .* reply/index-[0-9.T-]+\\.json .* ) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake index 7c6a35a..9aa9e4a 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake @@ -4,6 +4,7 @@ set(expect query/client-foo/codemodel-v2 reply reply/codemodel-v2-[0-9a-f]+\\.json + .* reply/index-[0-9.T-]+\\.json .* ) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake index cc2f31b..43d1a0b 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake @@ -3,6 +3,7 @@ set(expect query/codemodel-v2 reply reply/codemodel-v2-[0-9a-f]+\\.json + .* reply/index-[0-9.T-]+\\.json .* ) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index e155037..0e5b3b9 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -12,7 +12,7 @@ def read_codemodel_json_data(filename): def check_objects(o, g): assert is_list(o) assert len(o) == 1 - check_index_object(o[0], "codemodel", 2, 2, check_object_codemodel(g)) + check_index_object(o[0], "codemodel", 2, 3, check_object_codemodel(g)) def check_backtrace(t, b, backtrace): btg = t["backtraceGraph"] @@ -55,7 +55,7 @@ def check_backtraces(t, actual, expected): def check_directory(c): def _check(actual, expected): assert is_dict(actual) - expected_keys = ["build", "source", "projectIndex"] + expected_keys = ["build", "jsonFile", "source", "projectIndex"] assert matches(actual["build"], expected["build"]) assert is_int(actual["projectIndex"]) @@ -92,6 +92,17 @@ def check_directory(c): assert sorted(actual.keys()) == sorted(expected_keys) + assert is_string(actual["jsonFile"]) + filepath = os.path.join(reply_dir, actual["jsonFile"]) + with open(filepath) as f: + d = json.load(f) + + assert is_dict(d) + assert sorted(d.keys()) == ["paths"] + + assert is_string(d["paths"]["source"], actual["source"]) + assert is_string(d["paths"]["build"], actual["build"]) + return _check def check_backtrace_graph(btg): @@ -704,6 +715,13 @@ def gen_check_targets(c, g, inSource): if sys.platform not in ("win32", "cygwin", "msys"): for e in expected: e["artifacts"] = filter_list(lambda a: not a["_dllExtra"], e["artifacts"]) + if e["install"] is not None: + e["install"]["destinations"] = filter_list(lambda d: "_dllExtra" not in d or not d["_dllExtra"], e["install"]["destinations"]) + + else: + for e in expected: + if e["install"] is not None: + e["install"]["destinations"] = filter_list(lambda d: "_namelink" not in d or not d["_namelink"], e["install"]["destinations"]) if "aix" not in sys.platform: for e in expected: diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json index 521e3c7..0d3161c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json @@ -10,5 +10,5 @@ ], "projectName": "External", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": true } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json index 176a857..5588bd5 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json @@ -90,10 +90,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib|cyg)?c_shared_lib\\.(so|dylib|dll)$", + "nameOnDisk": "^(lib|cyg)?c_shared_lib(-1)?\\.(so|dylib|dll)$", "artifacts": [ { - "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib\\.(so|dylib|dll)$", + "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib(-1)?\\.(so|dylib|dll)$", "_dllExtra": false }, { @@ -101,13 +101,106 @@ "_dllExtra": true }, { - "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib\\.pdb$", + "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib(-1)?\\.pdb$", "_dllExtra": true } ], "build": "^\\.$", "source": "^\\.$", - "install": null, + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "lib", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_dllExtra": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_namelink": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 46, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] + }, "link": { "language": "C", "lto": true, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json index 171a4f5..e5e1d0d 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json @@ -83,7 +83,100 @@ ], "build": "^cxx$", "source": "^cxx$", - "install": null, + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "lib", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_dllExtra": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_namelink": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 46, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] + }, "link": { "language": "CXX", "lto": null, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index 2405954..528f075 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -35,4 +35,19 @@ if(_ipo) file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "") endif() -install(TARGETS cxx_exe) +install(TARGETS cxx_exe COMPONENT Tools EXPORT FooTargets) + +set_target_properties(c_shared_lib PROPERTIES VERSION 1.2.3 SOVERSION 1) +install(TARGETS c_shared_lib cxx_shared_lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION lib + LIBRARY DESTINATION lib NAMELINK_SKIP + ) +install(TARGETS c_shared_lib cxx_shared_lib LIBRARY NAMELINK_ONLY) + +install(FILES empty.h TYPE INCLUDE RENAME empty-renamed.h OPTIONAL) +install(FILES codemodel-v2.cmake empty.h DESTINATION include) +install(DIRECTORY . dir cxx/ OPTIONAL DESTINATION dir1) +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/dir" "${CMAKE_CURRENT_SOURCE_DIR}/cxx/" DESTINATION dir2) +install(EXPORT FooTargets DESTINATION lib/cmake/foo) +install(SCRIPT InstallScript.cmake) diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt index 76235f5..95c803f 100644 --- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt @@ -16,7 +16,7 @@ target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib) target_compile_options(cxx_exe PUBLIC TargetCompileOptions) target_link_options(cxx_exe PUBLIC TargetLinkOptions) -target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir") +target_link_directories(cxx_exe PUBLIC "$") target_precompile_headers(cxx_exe PUBLIC ../empty.h) diff --git a/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt b/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt index b3ca660..2865864 100644 --- a/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt +++ b/Tests/RunCMake/FileAPIExternalSource/CMakeLists.txt @@ -11,3 +11,6 @@ set_property(SOURCE empty.c PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY target_include_directories(generated_exe SYSTEM PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") target_compile_definitions(generated_exe PRIVATE GENERATED_EXE=1 -DTGT_DUMMY) set_source_files_properties(empty.c PROPERTIES COMPILE_OPTIONS SRC_COMPILE_OPTIONS_DUMMY) + +install(DIRECTORY . DESTINATION dir3) +install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} EXCLUDE_FROM_ALL DESTINATION dir4) -- cgit v0.12 From eae2256a529250e4fda639a79a9edddef6604f12 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 14 Jan 2021 16:17:56 -0500 Subject: fileapi: Add backtraceGraph to codemodel-v2 "directory" object Co-Authored-by: Kyle Edwards --- Help/manual/cmake-file-api.7.rst | 12 ++++++++---- Source/cmFileAPICodemodel.cxx | 13 +++++++++++++ Tests/RunCMake/FileAPI/codemodel-v2-check.py | 4 +++- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index 7c34d51..088ec2e 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -666,6 +666,10 @@ with members: directory (with ``.`` for the top-level build directory itself). Otherwise the path is absolute. +``backtraceGraph`` + A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced + from ``backtrace`` members elsewhere in this "directory" object. + "codemodel" version 2 "target" object ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1003,10 +1007,10 @@ with members: "codemodel" version 2 "backtrace graph" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The ``backtraceGraph`` member of a `"codemodel" version 2 "target" object`_ -is a JSON object describing a graph of backtraces. Its nodes are referenced -from ``backtrace`` members elsewhere in the containing object. -The backtrace graph object members are: +The ``backtraceGraph`` member of a `"codemodel" version 2 "directory" object`_, +or `"codemodel" version 2 "target" object`_ is a JSON object describing a +graph of backtraces. Its nodes are referenced from ``backtrace`` members +elsewhere in the containing object. The backtrace graph object members are: ``nodes`` A JSON array listing nodes in the backtrace graph. Each entry diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 2f36db2..e7bfc61 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -379,6 +379,9 @@ class DirectoryObject std::string const& Config; std::string TopSource; std::string TopBuild; + BacktraceData Backtraces; + + void AddBacktrace(Json::Value& object, cmListFileBacktrace const& bt); Json::Value DumpPaths(); @@ -814,6 +817,7 @@ DirectoryObject::DirectoryObject(cmLocalGenerator const* lg, , TopSource(lg->GetGlobalGenerator()->GetCMakeInstance()->GetHomeDirectory()) , TopBuild( lg->GetGlobalGenerator()->GetCMakeInstance()->GetHomeOutputDirectory()) + , Backtraces(this->TopSource) { } @@ -821,9 +825,18 @@ Json::Value DirectoryObject::Dump() { Json::Value directoryObject = Json::objectValue; directoryObject["paths"] = this->DumpPaths(); + directoryObject["backtraceGraph"] = this->Backtraces.Dump(); return directoryObject; } +void DirectoryObject::AddBacktrace(Json::Value& object, + cmListFileBacktrace const& bt) +{ + if (JBTIndex backtrace = this->Backtraces.Add(bt)) { + object["backtrace"] = backtrace.Index; + } +} + Json::Value DirectoryObject::DumpPaths() { Json::Value paths = Json::objectValue; diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 0e5b3b9..900faf9 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -98,11 +98,13 @@ def check_directory(c): d = json.load(f) assert is_dict(d) - assert sorted(d.keys()) == ["paths"] + assert sorted(d.keys()) == ["backtraceGraph", "paths"] assert is_string(d["paths"]["source"], actual["source"]) assert is_string(d["paths"]["build"], actual["build"]) + check_backtrace_graph(d["backtraceGraph"]) + return _check def check_backtrace_graph(btg): -- cgit v0.12 From 049bf98f63f386bdc174c3872c7ef1c658041cf4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 21 Jan 2021 13:17:19 -0500 Subject: fileapi: Add installers to codemodel-v2 "directory" object Co-Authored-by: Kyle Edwards --- Help/manual/cmake-file-api.7.rst | 148 ++++++ Help/release/dev/fileapi-codemodel-directory.rst | 2 + Source/cmFileAPICodemodel.cxx | 220 ++++++++- Tests/RunCMake/FileAPI/codemodel-v2-check.py | 93 +++- .../codemodel-v2-data/directories/alias.json | 3 +- .../codemodel-v2-data/directories/custom.json | 3 +- .../FileAPI/codemodel-v2-data/directories/cxx.json | 3 +- .../FileAPI/codemodel-v2-data/directories/dir.json | 3 +- .../codemodel-v2-data/directories/dir_dir.json | 3 +- .../codemodel-v2-data/directories/external.json | 66 ++- .../codemodel-v2-data/directories/imported.json | 3 +- .../codemodel-v2-data/directories/interface.json | 3 +- .../codemodel-v2-data/directories/object.json | 66 ++- .../FileAPI/codemodel-v2-data/directories/top.json | 546 ++++++++++++++++++++- 14 files changed, 1148 insertions(+), 14 deletions(-) diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index 088ec2e..cbc3d6d 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -666,6 +666,154 @@ with members: directory (with ``.`` for the top-level build directory itself). Otherwise the path is absolute. +``installers`` + A JSON array of entries corresponding to :command:`install` rules. + Each entry is a JSON object containing members: + + ``component`` + A string specifying the component selected by the corresponding + :command:`install` command invocation. + + ``destination`` + Optional member that is present for specific ``type`` values below. + The value is a string specifying the install destination path. + The path may be absolute or relative to the install prefix. + + ``paths`` + Optional member that is present for specific ``type`` values below. + The value is a JSON array of entries corresponding to the paths + (files or directories) to be installed. Each entry is one of: + + * A string specifying the path from which a file or directory + is to be installed. The portion of the path not preceded by + a ``/`` also specifies the path (name) to which the file + or directory is to be installed under the destination. + + * A JSON object with members: + + ``from`` + A string specifying the path from which a file or directory + is to be installed. + + ``to`` + A string specifying the path to which the file or directory + is to be installed under the destination. + + In both cases the paths are represented with forward slashes. If + the "from" path is inside the top-level directory documented by the + corresponding ``type`` value, then the path is specified relative + to that directory. Otherwise the path is absolute. + + ``type`` + A string specifying the type of installation rule. The value is one + of the following, with some variants providing additional members: + + ``file`` + An :command:`install(FILES)` or :command:`install(PROGRAMS)` call. + The ``destination`` and ``paths`` members are populated, with paths + under the top-level *source* directory expressed relative to it. + The ``isOptional`` member may exist. + This type has no additional members. + + ``directory`` + An :command:`install(DIRECTORY)` call. + The ``destination`` and ``paths`` members are populated, with paths + under the top-level *source* directory expressed relative to it. + The ``isOptional`` member may exist. + This type has no additional members. + + ``target`` + An :command:`install(TARGETS)` call. + The ``destination`` and ``paths`` members are populated, with paths + under the top-level *build* directory expressed relative to it. + The ``isOptional`` member may exist. + This type has additional members ``targetId``, ``targetIndex``, + ``targetIsImportLibrary``, and ``targetInstallNamelink``. + + ``export`` + An :command:`install(EXPORT)` call. + The ``destination`` and ``paths`` members are populated, with paths + under the top-level *build* directory expressed relative to it. + The ``paths`` entries refer to files generated automatically by + CMake for installation, and their actual values are considered + private implementation details. + This type has additional members ``exportName`` and ``exportTargets``. + + ``script`` + An :command:`install(SCRIPT)` call. + This type has additional member ``scriptFile``. + + ``code`` + An :command:`install(CODE)` call. + This type has no additional members. + + ``isExcludeFromAll`` + Optional member that is present with boolean value ``true`` when + :command:`install` is called with the ``EXCLUDE_FROM_ALL`` option. + + ``isOptional`` + Optional member that is present with boolean value ``true`` when + :command:`install` is called with the ``OPTIONAL`` option. + This is allowed when ``type`` is ``file``, ``directory``, or ``target``. + + ``targetId`` + Optional member that is present when ``type`` is ``target``. + The value is a string uniquely identifying the target to be installed. + This matches the ``id`` member of the target in the main + "codemodel" object's ``targets`` array. + + ``targetIndex`` + Optional member that is present when ``type`` is ``target``. + The value is an unsigned integer 0-based index into the main "codemodel" + object's ``targets`` array for the target to be installed. + + ``targetIsImportLibrary`` + Optional member that is present when ``type`` is ``target`` and + the installer is for a Windows DLL import library file or for an + AIX linker import file. If present, it has boolean value ``true``. + + ``targetInstallNamelink`` + Optional member that is present when ``type`` is ``target`` and + the installer corresponds to a target that may use symbolic links + to implement the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` + target properties. + The value is a string indicating how the installer is supposed to + handle the symlinks: ``skip`` means the installer should skip the + symlinks and install only the real file, and ``only`` means the + installer should install only the symlinks and not the real file. + In all cases the ``paths`` member lists what it actually installs. + + ``exportName`` + Optional member that is present when ``type`` is ``export``. + The value is a string specifying the name of the export. + + ``exportTargets`` + Optional member that is present when ``type`` is ``export``. + The value is a JSON array of entries corresponding to the targets + included in the export. Each entry is a JSON object with members: + + ``id`` + A string uniquely identifying the target. This matches + the ``id`` member of the target in the main "codemodel" + object's ``targets`` array. + + ``index`` + An unsigned integer 0-based index into the main "codemodel" + object's ``targets`` array for the target. + + ``scriptFile`` + Optional member that is present when ``type`` is ``script``. + The value is a string specifying the path to the script file on disk, + represented with forward slashes. If the file is inside the top-level + source directory then the path is specified relative to that directory. + Otherwise the path is absolute. + + ``backtrace`` + Optional member that is present when a CMake language backtrace to + the :command:`install` or other command invocation that added this + installer is available. The value is an unsigned integer 0-based + index into the ``backtraceGraph`` member's ``nodes`` array. + ``backtraceGraph`` A `"codemodel" version 2 "backtrace graph"`_ whose nodes are referenced from ``backtrace`` members elsewhere in this "directory" object. diff --git a/Help/release/dev/fileapi-codemodel-directory.rst b/Help/release/dev/fileapi-codemodel-directory.rst index 7dffb96..f6515fd 100644 --- a/Help/release/dev/fileapi-codemodel-directory.rst +++ b/Help/release/dev/fileapi-codemodel-directory.rst @@ -6,3 +6,5 @@ fileapi-codemodel-directory * The :manual:`cmake-file-api(7)` "codemodel" version 2 gained a new "directory" object containing directory-level information. + This includes a list of installers generated by the :command:`install` + command. diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index e7bfc61..6b8757c 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -20,11 +20,16 @@ #include #include "cmCryptoHash.h" +#include "cmExportSet.h" #include "cmFileAPI.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmInstallDirectoryGenerator.h" +#include "cmInstallExportGenerator.h" +#include "cmInstallFilesGenerator.h" #include "cmInstallGenerator.h" +#include "cmInstallScriptGenerator.h" #include "cmInstallSubdirectoryGenerator.h" #include "cmInstallTargetGenerator.h" #include "cmLinkLineComputer.h" @@ -42,6 +47,7 @@ #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" +#include "cmTargetExport.h" #include "cmake.h" namespace { @@ -377,6 +383,7 @@ class DirectoryObject { cmLocalGenerator const* LG = nullptr; std::string const& Config; + TargetIndexMapType& TargetIndexMap; std::string TopSource; std::string TopBuild; BacktraceData Backtraces; @@ -384,9 +391,16 @@ class DirectoryObject void AddBacktrace(Json::Value& object, cmListFileBacktrace const& bt); Json::Value DumpPaths(); + Json::Value DumpInstallers(); + Json::Value DumpInstaller(cmInstallGenerator* gen); + Json::Value DumpInstallerExportTargets(cmExportSet* exp); + Json::Value DumpInstallerPath(std::string const& top, + std::string const& fromPathIn, + std::string const& toPath); public: - DirectoryObject(cmLocalGenerator const* lg, std::string const& config); + DirectoryObject(cmLocalGenerator const* lg, std::string const& config, + TargetIndexMapType& targetIndexMap); Json::Value Dump(); }; @@ -763,7 +777,7 @@ Json::Value CodemodelConfig::DumpDirectoryObject(Directory& d) prefix += "-" + this->Config; } - DirectoryObject dir(d.LocalGenerator, this->Config); + DirectoryObject dir(d.LocalGenerator, this->Config, this->TargetIndexMap); return this->FileAPI.MaybeJsonFile(dir.Dump(), prefix); } @@ -811,9 +825,11 @@ Json::Value CodemodelConfig::DumpMinimumCMakeVersion(cmStateSnapshot s) } DirectoryObject::DirectoryObject(cmLocalGenerator const* lg, - std::string const& config) + std::string const& config, + TargetIndexMapType& targetIndexMap) : LG(lg) , Config(config) + , TargetIndexMap(targetIndexMap) , TopSource(lg->GetGlobalGenerator()->GetCMakeInstance()->GetHomeDirectory()) , TopBuild( lg->GetGlobalGenerator()->GetCMakeInstance()->GetHomeOutputDirectory()) @@ -825,6 +841,7 @@ Json::Value DirectoryObject::Dump() { Json::Value directoryObject = Json::objectValue; directoryObject["paths"] = this->DumpPaths(); + directoryObject["installers"] = this->DumpInstallers(); directoryObject["backtraceGraph"] = this->Backtraces.Dump(); return directoryObject; } @@ -850,6 +867,203 @@ Json::Value DirectoryObject::DumpPaths() return paths; } +Json::Value DirectoryObject::DumpInstallers() +{ + Json::Value installers = Json::arrayValue; + for (const auto& gen : this->LG->GetMakefile()->GetInstallGenerators()) { + Json::Value installer = this->DumpInstaller(gen.get()); + if (!installer.empty()) { + installers.append(std::move(installer)); // NOLINT(*) + } + } + return installers; +} + +Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) +{ + Json::Value installer = Json::objectValue; + + // Exclude subdirectory installers. They are implementation details. + if (dynamic_cast(gen)) { + return installer; + } + + // Exclude installers not used in this configuration. + if (!gen->InstallsForConfig(this->Config)) { + return installer; + } + + // Add fields specific to each kind of install generator. + if (auto* installTarget = dynamic_cast(gen)) { + cmInstallTargetGenerator::Files const& files = + installTarget->GetFiles(this->Config); + if (files.From.empty()) { + return installer; + } + + installer["type"] = "target"; + installer["destination"] = installTarget->GetDestination(this->Config); + installer["targetId"] = + TargetId(installTarget->GetTarget(), this->TopBuild); + installer["targetIndex"] = + this->TargetIndexMap[installTarget->GetTarget()]; + + std::string fromDir = files.FromDir; + if (!fromDir.empty()) { + fromDir.push_back('/'); + } + + std::string toDir = files.ToDir; + if (!toDir.empty()) { + toDir.push_back('/'); + } + + Json::Value paths = Json::arrayValue; + for (size_t i = 0; i < files.From.size(); ++i) { + std::string const& fromPath = cmStrCat(fromDir, files.From[i]); + std::string const& toPath = cmStrCat(toDir, files.To[i]); + paths.append(this->DumpInstallerPath(this->TopBuild, fromPath, toPath)); + } + installer["paths"] = std::move(paths); + + if (installTarget->GetOptional()) { + installer["isOptional"] = true; + } + + if (installTarget->IsImportLibrary()) { + installer["targetIsImportLibrary"] = true; + } + + switch (files.NamelinkMode) { + case cmInstallTargetGenerator::NamelinkModeNone: + break; + case cmInstallTargetGenerator::NamelinkModeOnly: + installer["targetInstallNamelink"] = "only"; + break; + case cmInstallTargetGenerator::NamelinkModeSkip: + installer["targetInstallNamelink"] = "skip"; + break; + } + + // FIXME: Parse FilePermissions to provide structured information. + // FIXME: Thread EXPORT name through from install() call. + } else if (auto* installFiles = + dynamic_cast(gen)) { + std::vector const& files = + installFiles->GetFiles(this->Config); + if (files.empty()) { + return installer; + } + + installer["type"] = "file"; + installer["destination"] = installFiles->GetDestination(this->Config); + Json::Value paths = Json::arrayValue; + std::string const& rename = installFiles->GetRename(this->Config); + if (!rename.empty() && files.size() == 1) { + paths.append(this->DumpInstallerPath(this->TopSource, files[0], rename)); + } else { + for (std::string const& file : installFiles->GetFiles(this->Config)) { + paths.append(RelativeIfUnder(this->TopSource, file)); + } + } + installer["paths"] = std::move(paths); + if (installFiles->GetOptional()) { + installer["isOptional"] = true; + } + // FIXME: Parse FilePermissions to provide structured information. + } else if (auto* installDir = + dynamic_cast(gen)) { + std::vector const& dirs = + installDir->GetDirectories(this->Config); + if (dirs.empty()) { + return installer; + } + + installer["type"] = "directory"; + installer["destination"] = installDir->GetDestination(this->Config); + Json::Value paths = Json::arrayValue; + for (std::string const& dir : dirs) { + if (cmHasLiteralSuffix(dir, "/")) { + paths.append(this->DumpInstallerPath( + this->TopSource, dir.substr(0, dir.size() - 1), ".")); + } else { + paths.append(this->DumpInstallerPath( + this->TopSource, dir, cmSystemTools::GetFilenameName(dir))); + } + } + installer["paths"] = std::move(paths); + if (installDir->GetOptional()) { + installer["isOptional"] = true; + } + // FIXME: Parse FilePermissions, DirPermissions, and LiteralArguments. + // to provide structured information. + } else if (auto* installExport = + dynamic_cast(gen)) { + installer["type"] = "export"; + installer["destination"] = installExport->GetDestination(); + cmExportSet* exportSet = installExport->GetExportSet(); + installer["exportName"] = exportSet->GetName(); + installer["exportTargets"] = this->DumpInstallerExportTargets(exportSet); + Json::Value paths = Json::arrayValue; + paths.append( + RelativeIfUnder(this->TopBuild, installExport->GetMainImportFile())); + installer["paths"] = std::move(paths); + } else if (auto* installScript = + dynamic_cast(gen)) { + if (installScript->IsCode()) { + installer["type"] = "code"; + } else { + installer["type"] = "script"; + installer["scriptFile"] = RelativeIfUnder( + this->TopSource, installScript->GetScript(this->Config)); + } + } + + // Add fields common to all install generators. + installer["component"] = gen->GetComponent(); + if (gen->GetExcludeFromAll()) { + installer["isExcludeFromAll"] = true; + } + this->AddBacktrace(installer, gen->GetBacktrace()); + + return installer; +} + +Json::Value DirectoryObject::DumpInstallerExportTargets(cmExportSet* exp) +{ + Json::Value targets = Json::arrayValue; + for (auto const& targetExport : exp->GetTargetExports()) { + Json::Value target = Json::objectValue; + target["id"] = TargetId(targetExport->Target, this->TopBuild); + target["index"] = this->TargetIndexMap[targetExport->Target]; + targets.append(std::move(target)); // NOLINT(*) + } + return targets; +} + +Json::Value DirectoryObject::DumpInstallerPath(std::string const& top, + std::string const& fromPathIn, + std::string const& toPath) +{ + Json::Value installPath; + + std::string fromPath = RelativeIfUnder(top, fromPathIn); + + // If toPath is the last component of fromPath, use just fromPath. + if (toPath.find_first_of('/') == std::string::npos && + cmHasSuffix(fromPath, toPath) && + (fromPath.size() == toPath.size() || + fromPath[fromPath.size() - toPath.size() - 1] == '/')) { + installPath = fromPath; + } else { + installPath = Json::objectValue; + installPath["from"] = fromPath; + installPath["to"] = toPath; + } + + return installPath; +} + Target::Target(cmGeneratorTarget* gt, std::string const& config) : GT(gt) , Config(config) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 900faf9..0d718a4 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -98,13 +98,90 @@ def check_directory(c): d = json.load(f) assert is_dict(d) - assert sorted(d.keys()) == ["backtraceGraph", "paths"] + assert sorted(d.keys()) == ["backtraceGraph", "installers", "paths"] assert is_string(d["paths"]["source"], actual["source"]) assert is_string(d["paths"]["build"], actual["build"]) check_backtrace_graph(d["backtraceGraph"]) + assert is_list(d["installers"]) + assert len(d["installers"]) == len(expected["installers"]) + for a, e in zip(d["installers"], expected["installers"]): + assert is_dict(a) + expected_keys = ["component", "type"] + + assert is_string(a["component"], e["component"]) + assert is_string(a["type"], e["type"]) + + if e["destination"] is not None: + expected_keys.append("destination") + assert is_string(a["destination"], e["destination"]) + + if e["paths"] is not None: + expected_keys.append("paths") + assert is_list(a["paths"]) + assert len(a["paths"]) == len(e["paths"]) + + for ap, ep in zip(a["paths"], e["paths"]): + if is_string(ep): + assert matches(ap, ep) + else: + assert is_dict(ap) + assert sorted(ap.keys()) == ["from", "to"] + assert matches(ap["from"], ep["from"]) + assert matches(ap["to"], ep["to"]) + + if e["isExcludeFromAll"] is not None: + expected_keys.append("isExcludeFromAll") + assert is_bool(a["isExcludeFromAll"], e["isExcludeFromAll"]) + + if e["isOptional"] is not None: + expected_keys.append("isOptional") + assert is_bool(a["isOptional"], e["isOptional"]) + + if e["targetId"] is not None: + expected_keys.append("targetId") + assert matches(a["targetId"], e["targetId"]) + + if e["targetIndex"] is not None: + expected_keys.append("targetIndex") + assert is_int(a["targetIndex"]) + assert c["targets"][a["targetIndex"]]["name"] == e["targetIndex"] + + if e["targetIsImportLibrary"] is not None: + expected_keys.append("targetIsImportLibrary") + assert is_bool(a["targetIsImportLibrary"], e["targetIsImportLibrary"]) + + if e["targetInstallNamelink"] is not None: + expected_keys.append("targetInstallNamelink") + assert is_string(a["targetInstallNamelink"], e["targetInstallNamelink"]) + + if e["exportName"] is not None: + expected_keys.append("exportName") + assert is_string(a["exportName"], e["exportName"]) + + if e["exportTargets"] is not None: + expected_keys.append("exportTargets") + assert is_list(a["exportTargets"]) + assert len(a["exportTargets"]) == len(e["exportTargets"]) + for at, et in zip(a["exportTargets"], e["exportTargets"]): + assert is_dict(at) + assert sorted(at.keys()) == ["id", "index"] + assert matches(at["id"], et["id"]) + assert is_int(at["index"]) + assert c["targets"][at["index"]]["name"] == et["index"] + + if e["scriptFile"] is not None: + expected_keys.append("scriptFile") + assert is_string(a["scriptFile"], e["scriptFile"]) + + if e["backtrace"] is not None: + expected_keys.append("backtrace") + check_backtrace(d, a["backtrace"], e["backtrace"]) + + assert sorted(a.keys()) == sorted(expected_keys) + return _check def check_backtrace_graph(btg): @@ -555,6 +632,20 @@ def gen_check_directories(c, g): for e in expected: e["targetIds"] = filter_list(lambda t: not matches(t, "^\\^(ALL_BUILD|ZERO_CHECK)"), e["targetIds"]) + if sys.platform in ("win32", "cygwin", "msys") or "aix" in sys.platform: + for e in expected: + e["installers"] = list(filter(lambda i: i["targetInstallNamelink"] is None or i["targetInstallNamelink"] == "skip", e["installers"])) + for i in e["installers"]: + i["targetInstallNamelink"] = None + + if sys.platform not in ("win32", "cygwin", "msys"): + for e in expected: + e["installers"] = list(filter(lambda i: "_dllExtra" not in i or not i["_dllExtra"], e["installers"])) + if "aix" not in sys.platform: + for i in e["installers"]: + if "pathsNamelink" in i: + i["paths"] = i["pathsNamelink"] + return expected def check_directories(c, g): diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json index 9f0c48a..6514910 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json @@ -11,5 +11,6 @@ ], "projectName": "Alias", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json index afd41f3..c89e4f9 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json @@ -11,5 +11,6 @@ ], "projectName": "Custom", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json index a51b6eb..7168306 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json @@ -17,5 +17,6 @@ ], "projectName": "Cxx", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json index afbd43a..8509f08 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json @@ -8,5 +8,6 @@ "targetIds": null, "projectName": "codemodel-v2", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json index 3737ad5..27184cd 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json @@ -6,5 +6,6 @@ "targetIds": null, "projectName": "codemodel-v2", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json index 0d3161c..55dd573 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json @@ -10,5 +10,69 @@ ], "projectName": "External", "minimumCMakeVersion": "3.12", - "hasInstallRule": true + "hasInstallRule": true, + "installers": [ + { + "component": "Unspecified", + "type": "directory", + "destination": "dir3", + "paths": [ + "^.*/Tests/RunCMake/FileAPIExternalSource/\\.$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": 15, + "command": "install", + "hasParent": true + }, + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "directory", + "destination": "dir4", + "paths": [ + "^.*/Tests/RunCMake/FileAPIExternalSource$" + ], + "isExcludeFromAll": true, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": 16, + "command": "install", + "hasParent": true + }, + { + "file": "^.*/Tests/RunCMake/FileAPIExternalSource/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json index a41b79b..d127274 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json @@ -14,5 +14,6 @@ ], "projectName": "Imported", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json index b10d496..90664dc 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json @@ -10,5 +10,6 @@ ], "projectName": "Interface", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": null, + "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/object.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/object.json index 1e647ad..ef2dd0b 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/object.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/object.json @@ -13,5 +13,69 @@ ], "projectName": "Object", "minimumCMakeVersion": "3.13", - "hasInstallRule": true + "hasInstallRule": true, + "installers": [ + { + "component": "Unspecified", + "type": "target", + "destination": "bin", + "paths": [ + "^object/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?c_object_exe(\\.exe)?$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^c_object_exe::@5ed5358f70faf8d8af7a$", + "targetIndex": "c_object_exe", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^object/CMakeLists\\.txt$", + "line": 13, + "command": "install", + "hasParent": true + }, + { + "file": "^object/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "bin", + "paths": [ + "^object/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?cxx_object_exe(\\.exe)?$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^cxx_object_exe::@5ed5358f70faf8d8af7a$", + "targetIndex": "cxx_object_exe", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^object/CMakeLists\\.txt$", + "line": 13, + "command": "install", + "hasParent": true + }, + { + "file": "^object/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index 736d1f5..ce45947 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -25,5 +25,549 @@ ], "projectName": "codemodel-v2", "minimumCMakeVersion": "3.12", - "hasInstallRule": true + "hasInstallRule": true, + "installers": [ + { + "component": "Tools", + "type": "target", + "destination": "bin", + "paths": [ + "^cxx/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?cxx_exe(\\.exe)?$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^cxx_exe::@a56b12a3f5c0529fb296$", + "targetIndex": "cxx_exe", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 38, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_shared_lib\\.(lib|dll\\.a)$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^c_shared_lib::@6890427a1f51a3e7e1df$", + "targetIndex": "c_shared_lib", + "targetIsImportLibrary": true, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "_dllExtra": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^lib/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib|cyg)?c_shared_lib(-1)?\\.(dll|so)$" + ], + "pathsNamelink": [ + "^lib/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_shared_lib\\.(so\\.1\\.2\\.3|1\\.2\\.3\\.dylib)$", + "^lib/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_shared_lib\\.(so\\.1|1\\.dylib)$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^c_shared_lib::@6890427a1f51a3e7e1df$", + "targetIndex": "c_shared_lib", + "targetIsImportLibrary": null, + "targetInstallNamelink": "skip", + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^cxx/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?cxx_shared_lib\\.(lib|dll\\.a)$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^cxx_shared_lib::@a56b12a3f5c0529fb296$", + "targetIndex": "cxx_shared_lib", + "targetIsImportLibrary": true, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "_dllExtra": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^cxx/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib|cyg)?cxx_shared_lib\\.(dll|so|dylib)$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^cxx_shared_lib::@a56b12a3f5c0529fb296$", + "targetIndex": "cxx_shared_lib", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^lib/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_shared_lib\\.(dll|so|dylib)$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": "^c_shared_lib::@6890427a1f51a3e7e1df$", + "targetIndex": "c_shared_lib", + "targetIsImportLibrary": null, + "targetInstallNamelink": "only", + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 46, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "file", + "destination": "include", + "paths": [ + { + "from": "^empty\\.h$", + "to": "^empty-renamed\\.h$" + } + ], + "isExcludeFromAll": null, + "isOptional": true, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 48, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "file", + "destination": "include", + "paths": [ + "^codemodel-v2\\.cmake$", + "^empty\\.h$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 49, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "directory", + "destination": "dir1", + "paths": [ + "^\\.$", + "^dir$", + { + "from": "^cxx$", + "to": "^\\.$" + } + ], + "isExcludeFromAll": null, + "isOptional": true, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 50, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "directory", + "destination": "dir2", + "paths": [ + { + "from": "^\\.$", + "to": "^FileAPI$" + }, + "^dir$", + { + "from": "^cxx$", + "to": "^\\.$" + } + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 51, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "export", + "destination": "lib/cmake/foo", + "paths": [ + "^CMakeFiles/Export/lib/cmake/foo/FooTargets\\.cmake$" + ], + "isExcludeFromAll": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": "FooTargets", + "exportTargets": [ + { + "id": "^cxx_exe::@a56b12a3f5c0529fb296$", + "index": "cxx_exe" + } + ], + "scriptFile": null, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 52, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "script", + "destination": null, + "paths": null, + "isExcludeFromAll": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": "InstallScript.cmake", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 53, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] } -- cgit v0.12 From ac4f83d98fd1c55e94736999d88effd50d2c0b64 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 17 Mar 2021 00:01:19 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7c6d284..bea8efd 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210316) +set(CMake_VERSION_PATCH 20210317) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 95c50da8af070999f5302ed19d807b59451d8c85 Mon Sep 17 00:00:00 2001 From: Alexander Richardson Date: Tue, 16 Mar 2021 13:19:21 +0000 Subject: Help: Document that CMAKE__FLAGS[_INIT] are strings Issue: #21944 --- Help/variable/CMAKE_LANG_FLAGS.rst | 3 +++ Help/variable/CMAKE_LANG_FLAGS_INIT.rst | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 14b2694..11864f8 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -15,3 +15,6 @@ This is initialized for each language from environment variables: Initialized by the :envvar:`CUDAFLAGS` environment variable. * ``CMAKE_Fortran_FLAGS``: Initialized by the :envvar:`FFLAGS` environment variable. + +This value is a command-line string fragment. Therefore, multiple options +should be separated by spaces, and options with spaces should be quoted. diff --git a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst index 67ff2cb..ca13a29 100644 --- a/Help/variable/CMAKE_LANG_FLAGS_INIT.rst +++ b/Help/variable/CMAKE_LANG_FLAGS_INIT.rst @@ -12,6 +12,8 @@ the contents of a ``xxxFLAGS`` environment variable will be prepended, where ``xxx`` will be language-specific but not necessarily the same as ```` (e.g. :envvar:`CXXFLAGS` for ``CXX``, :envvar:`FFLAGS` for ``Fortran``, and so on). +This value is a command-line string fragment. Therefore, multiple options +should be separated by spaces, and options with spaces should be quoted. See also the configuration-specific :variable:`CMAKE__FLAGS__INIT` variable. -- cgit v0.12 From 256c320fb6aea90f6544bcefe8dbde497b40351f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 12 Mar 2021 13:01:45 -0500 Subject: gitlab-ci: add variable for job to control its ctest build name --- .gitlab/ci/gitlab_ci.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/gitlab_ci.cmake b/.gitlab/ci/gitlab_ci.cmake index f863a27..f166215 100644 --- a/.gitlab/ci/gitlab_ci.cmake +++ b/.gitlab/ci/gitlab_ci.cmake @@ -17,7 +17,11 @@ if ("$ENV{CMAKE_CONFIGURATION}" STREQUAL "") endif () # Set the build metadata. -set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CONFIGURATION}") +if(NOT "$ENV{CMAKE_CI_BUILD_NAME}" STREQUAL "") + set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CI_BUILD_NAME}") +else() + set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CONFIGURATION}") +endif() set(CTEST_SITE "gitlab-ci") set(ctest_model "Experimental") -- cgit v0.12 From 747940157f897bfaf875a85d30dad1f1902094b9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 12 Mar 2021 13:02:43 -0500 Subject: gitlab-ci: init environment with per-CMAKE_CONFIGURATION shell scripts --- .gitlab/ci/env.sh | 14 ++++++++++++++ .gitlab/os-linux.yml | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 .gitlab/ci/env.sh diff --git a/.gitlab/ci/env.sh b/.gitlab/ci/env.sh new file mode 100644 index 0000000..7634f5d --- /dev/null +++ b/.gitlab/ci/env.sh @@ -0,0 +1,14 @@ +quietly() { + readonly log="/tmp/quietly-$RANDOM.log" + if ! "$@" >"$log" 2>&1; then + ret=$? + cat "$log" + rm -f "$log" + exit $ret + fi + rm -f "$log" +} + +if test -r ".gitlab/ci/env_${CMAKE_CONFIGURATION}.sh"; then + source ".gitlab/ci/env_${CMAKE_CONFIGURATION}.sh" +fi diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index e40760e..7496e9e 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -195,6 +195,7 @@ ## Linux-specific scripts .before_script_linux: &before_script_linux + - source .gitlab/ci/env.sh - .gitlab/ci/cmake.sh - .gitlab/ci/ninja.sh - export PATH=$PWD/.gitlab:$PWD/.gitlab/cmake/bin:$PATH @@ -251,6 +252,7 @@ stage: build script: + - source .gitlab/ci/env.sh # Bootstrap. - mkdir -p build/ # Exclude documentation. A job dependency provides it for packaging. -- cgit v0.12 From 402518904f08c2eb9b4bbcc58c70a2bc9884fb4b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 15 Mar 2021 13:27:53 -0400 Subject: gitlab-ci: add rules to enable jobs only in a nightly pipeline schedule --- .gitlab/rules.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml index b3e5342..5685463 100644 --- a/.gitlab/rules.yml +++ b/.gitlab/rules.yml @@ -6,6 +6,8 @@ when: never - if: '$CMAKE_CI_NIGHTLY == "true"' when: on_success + - if: '$CMAKE_CI_JOB_NIGHTLY == "true"' + when: never - if: '($CMAKE_CI_PROJECT_CONTINUOUS_BRANCH != "" && $CI_COMMIT_BRANCH == $CMAKE_CI_PROJECT_CONTINUOUS_BRANCH && $CMAKE_CI_JOB_CONTINUOUS == "true")' when: delayed start_in: 5 minutes @@ -24,6 +26,8 @@ when: never - if: '$CMAKE_CI_NIGHTLY == "true"' when: on_success + - if: '$CMAKE_CI_JOB_NIGHTLY == "true"' + when: never - if: '($CMAKE_CI_PROJECT_CONTINUOUS_BRANCH != "" && $CI_COMMIT_BRANCH == $CMAKE_CI_PROJECT_CONTINUOUS_BRANCH && $CMAKE_CI_JOB_CONTINUOUS == "true")' when: on_success - if: '($CMAKE_CI_NO_MR == "true" && $CI_MERGE_REQUEST_ID)' @@ -42,6 +46,8 @@ when: always - if: '$CMAKE_CI_NIGHTLY == "true"' when: on_success + - if: '$CMAKE_CI_JOB_NIGHTLY == "true"' + when: never - if: '($CMAKE_CI_NO_MR == "true" && $CI_MERGE_REQUEST_ID)' when: never - if: '$CI_MERGE_REQUEST_ID' -- cgit v0.12 From 5ea928d9d25cfd2bfea946bdd7c3ad3c92a63168 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 15 Mar 2021 13:34:16 -0400 Subject: gitlab-ci: factor out job dependencies on release-style binaries --- .gitlab-ci.yml | 20 ++++---------------- .gitlab/os-linux.yml | 12 ++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e76e41..e2e8331 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -115,10 +115,7 @@ test:debian10-ninja: - .cmake_test_linux_release - .linux_builder_tags_qt - .run_dependent - dependencies: - - build:centos6-x86_64 - needs: - - build:centos6-x86_64 + - .needs_centos6_x86_64 test:debian10-aarch64-ninja: extends: @@ -126,10 +123,7 @@ test:debian10-aarch64-ninja: - .cmake_test_linux_release - .linux_builder_tags_aarch64_qt - .run_dependent - dependencies: - - build:centos7-aarch64 - needs: - - build:centos7-aarch64 + - .needs_centos7_aarch64 variables: CMAKE_CI_NO_MR: "true" @@ -139,10 +133,7 @@ test:fedora33-makefiles: - .cmake_test_linux_release - .linux_builder_tags_qt - .run_dependent - dependencies: - - build:centos6-x86_64 - needs: - - build:centos6-x86_64 + - .needs_centos6_x86_64 test:cuda10.2-nvidia: extends: @@ -150,10 +141,7 @@ test:cuda10.2-nvidia: - .cmake_test_linux_release - .linux_builder_tags_cuda - .run_dependent - dependencies: - - build:centos6-x86_64 - needs: - - build:centos6-x86_64 + - .needs_centos6_x86_64 build:fedora33-ninja: extends: diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 7496e9e..786e293 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -30,6 +30,18 @@ variables: BOOTSTRAP_ARGS: '-- "-DCMake_DOC_ARTIFACT_PREFIX=$CI_PROJECT_DIR/build/install-doc"' +.needs_centos6_x86_64: + dependencies: + - build:centos6-x86_64 + needs: + - build:centos6-x86_64 + +.needs_centos7_aarch64: + dependencies: + - build:centos7-aarch64 + needs: + - build:centos7-aarch64 + ### Debian .debian10: -- cgit v0.12 From c07683331052bf5bd29788a73563930dd5ff2349 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 15 Mar 2021 13:37:23 -0400 Subject: gitlab-ci: add jobs testing Intel Classic compilers on Linux --- .gitlab-ci.yml | 189 ++++++++++++++++++++++ .gitlab/ci/configure_intelclassic_makefiles.cmake | 1 + .gitlab/ci/env_intelclassic_common.sh | 9 ++ .gitlab/ci/env_intelclassic_makefiles.sh | 1 + .gitlab/ci/env_intelcompiler_license.sh | 8 + .gitlab/os-linux.yml | 25 +++ 6 files changed, 233 insertions(+) create mode 100644 .gitlab/ci/configure_intelclassic_makefiles.cmake create mode 100644 .gitlab/ci/env_intelclassic_common.sh create mode 100644 .gitlab/ci/env_intelclassic_makefiles.sh create mode 100644 .gitlab/ci/env_intelcompiler_license.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e2e8331..b5e3fb0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -174,6 +174,195 @@ test:fedora33-ninja-multi: needs: - test:fedora33-ninja +test:intel2016-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2016_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016-centos7 + +test:intel2016u1-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2016u1_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016u1-centos7 + +test:intel2016u2-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2016u2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016u2-centos7 + +test:intel2017-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017-centos7 + +test:intel2017u1-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u1_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u1-centos7 + +test:intel2017u2-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u2-centos7 + +test:intel2017u3-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u3_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u3-centos7 + +test:intel2017u4-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u4_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u4-centos7 + +test:intel2017u5-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u5_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u5-centos7 + +test:intel2017u6-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u6_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u6-centos7 + +test:intel2017u7-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u7_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u7-centos7 + +test:intel2017u8-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2017u8_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u8-centos7 + +test:intel2018-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2018_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018-centos7 + +test:intel2018u1-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2018u1_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u1-centos7 + +test:intel2018u2-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2018u2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u2-centos7 + +test:intel2018u3-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2018u3_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u3-centos7 + +test:intel2018u4-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2018u4_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u4-centos7 + +test:intel2019-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2019_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019-centos7 + +test:intel2019u1-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2019u1_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u1-centos7 + +test:intel2019u2-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2019u2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u2-centos7 + +test:intel2019u3-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2019u3_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u3-centos7 + +test:intel2019u4-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2019u4_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u4-centos7 + +test:intel2020-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2020_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020-rhel8 + +test:intel2020u2-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2020u2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020u2-rhel8 + +test:intel2020u4-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2020u4_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020u4-rhel8 + +test:intel2021.1.1-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2021.1.1_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.1-rhel8 + +test:intel2021.1.2-makefiles: + extends: + - .cmake_test_linux_intelclassic_makefiles + variables: + CMAKE_CI_BUILD_NAME: intel2021.1.2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-rhel8 + build:linux-x86_64-package: extends: - .linux_package diff --git a/.gitlab/ci/configure_intelclassic_makefiles.cmake b/.gitlab/ci/configure_intelclassic_makefiles.cmake new file mode 100644 index 0000000..20863a2 --- /dev/null +++ b/.gitlab/ci/configure_intelclassic_makefiles.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/env_intelclassic_common.sh b/.gitlab/ci/env_intelclassic_common.sh new file mode 100644 index 0000000..22b1d03 --- /dev/null +++ b/.gitlab/ci/env_intelclassic_common.sh @@ -0,0 +1,9 @@ +source .gitlab/ci/env_intelcompiler_license.sh + +if test -r /opt/intel/oneapi/setvars.sh; then + source /opt/intel/oneapi/setvars.sh +elif test -r /opt/intel/bin/compilervars.sh; then + source /opt/intel/bin/compilervars.sh intel64 +fi + +export CC=icc CXX=icpc FC=ifort diff --git a/.gitlab/ci/env_intelclassic_makefiles.sh b/.gitlab/ci/env_intelclassic_makefiles.sh new file mode 100644 index 0000000..d1ff85e --- /dev/null +++ b/.gitlab/ci/env_intelclassic_makefiles.sh @@ -0,0 +1 @@ +source .gitlab/ci/env_intelclassic_common.sh diff --git a/.gitlab/ci/env_intelcompiler_license.sh b/.gitlab/ci/env_intelcompiler_license.sh new file mode 100644 index 0000000..54743b2 --- /dev/null +++ b/.gitlab/ci/env_intelcompiler_license.sh @@ -0,0 +1,8 @@ +if test -n "$CMAKE_CI_INTELCOMPILER_LICENSE"; then + if test -d /opt/intel/licenses; then + mv "$CMAKE_CI_INTELCOMPILER_LICENSE" /opt/intel/licenses/ci.lic + else + rm "$CMAKE_CI_INTELCOMPILER_LICENSE" + fi + unset CMAKE_CI_INTELCOMPILER_LICENSE +fi diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 786e293..158f107 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -140,6 +140,21 @@ CTEST_NO_WARNINGS_ALLOWED: 1 CMAKE_GENERATOR: "Unix Makefiles" +### Intel Compiler + +.intelcompiler: + image: "kitware/intelcompiler:$CMAKE_CI_INTELCOMPILER_IMAGE_TAG" + environment: + name: intel-compiler + variables: + CMAKE_ARCH: x86_64 + +.intelclassic_makefiles: + extends: .intelcompiler + variables: + CMAKE_CONFIGURATION: intelclassic_makefiles + CMAKE_GENERATOR: "Unix Makefiles" + ### CUDA builds .cuda10.2: @@ -327,3 +342,13 @@ - sccache --show-stats interruptible: true + +.cmake_test_linux_intelclassic_makefiles: + extends: + - .intelclassic_makefiles + - .cmake_test_linux_release + - .linux_builder_tags_qt + - .run_manually + - .needs_centos6_x86_64 + variables: + CMAKE_CI_JOB_NIGHTLY: "true" -- cgit v0.12 From 1610c0f0345959e388a7b106969e972889815ec6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 15 Mar 2021 14:52:25 -0400 Subject: gitlab-ci: add jobs testing Intel oneAPI compilers on Linux --- .gitlab-ci.yml | 14 ++++++++++++++ .gitlab/ci/configure_inteloneapi_makefiles.cmake | 1 + .gitlab/ci/env_inteloneapi_common.sh | 7 +++++++ .gitlab/ci/env_inteloneapi_makefiles.sh | 1 + .gitlab/os-linux.yml | 16 ++++++++++++++++ 5 files changed, 39 insertions(+) create mode 100644 .gitlab/ci/configure_inteloneapi_makefiles.cmake create mode 100644 .gitlab/ci/env_inteloneapi_common.sh create mode 100644 .gitlab/ci/env_inteloneapi_makefiles.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b5e3fb0..9f996e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -363,6 +363,20 @@ test:intel2021.1.2-makefiles: CMAKE_CI_BUILD_NAME: intel2021.1.2_makefiles CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-rhel8 +test:oneapi2021.1.1-makefiles: + extends: + - .cmake_test_linux_inteloneapi_makefiles + variables: + CMAKE_CI_BUILD_NAME: oneapi2021.1.1_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.1-rhel8 + +test:oneapi2021.1.2-makefiles: + extends: + - .cmake_test_linux_inteloneapi_makefiles + variables: + CMAKE_CI_BUILD_NAME: oneapi2021.1.2_makefiles + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-rhel8 + build:linux-x86_64-package: extends: - .linux_package diff --git a/.gitlab/ci/configure_inteloneapi_makefiles.cmake b/.gitlab/ci/configure_inteloneapi_makefiles.cmake new file mode 100644 index 0000000..20863a2 --- /dev/null +++ b/.gitlab/ci/configure_inteloneapi_makefiles.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/env_inteloneapi_common.sh b/.gitlab/ci/env_inteloneapi_common.sh new file mode 100644 index 0000000..beaf3fe --- /dev/null +++ b/.gitlab/ci/env_inteloneapi_common.sh @@ -0,0 +1,7 @@ +source .gitlab/ci/env_intelcompiler_license.sh + +if test -r /opt/intel/oneapi/setvars.sh; then + source /opt/intel/oneapi/setvars.sh +fi + +export CC=icx CXX=icpx FC=ifx diff --git a/.gitlab/ci/env_inteloneapi_makefiles.sh b/.gitlab/ci/env_inteloneapi_makefiles.sh new file mode 100644 index 0000000..eefcdda --- /dev/null +++ b/.gitlab/ci/env_inteloneapi_makefiles.sh @@ -0,0 +1 @@ +source .gitlab/ci/env_inteloneapi_common.sh diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 158f107..0229bc0 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -155,6 +155,12 @@ CMAKE_CONFIGURATION: intelclassic_makefiles CMAKE_GENERATOR: "Unix Makefiles" +.inteloneapi_makefiles: + extends: .intelcompiler + variables: + CMAKE_CONFIGURATION: inteloneapi_makefiles + CMAKE_GENERATOR: "Unix Makefiles" + ### CUDA builds .cuda10.2: @@ -352,3 +358,13 @@ - .needs_centos6_x86_64 variables: CMAKE_CI_JOB_NIGHTLY: "true" + +.cmake_test_linux_inteloneapi_makefiles: + extends: + - .inteloneapi_makefiles + - .cmake_test_linux_release + - .linux_builder_tags_qt + - .run_manually + - .needs_centos6_x86_64 + variables: + CMAKE_CI_JOB_NIGHTLY: "true" -- cgit v0.12 From 56c759b000ab5041aff9a92d51a6cc471e7d34a4 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Sat, 13 Mar 2021 15:37:19 +0200 Subject: Per-language Win32/Console flags Allows using different compilers with different flags for different languages. For example Clang with GNU-like commandline for CXX and MSVC as host compiler for CUDA. Should help with #21914. --- Modules/Platform/CYGWIN-GNU.cmake | 2 +- Modules/Platform/Windows-Clang.cmake | 4 ++-- Modules/Platform/Windows-Embarcadero.cmake | 8 +++----- Modules/Platform/Windows-GNU.cmake | 2 +- Modules/Platform/Windows-MSVC.cmake | 12 ++++++++---- Modules/Platform/Windows-OpenWatcom-C.cmake | 1 + Modules/Platform/Windows-OpenWatcom-CXX.cmake | 1 + Modules/Platform/Windows-OpenWatcom.cmake | 7 +++++-- Modules/Platform/Windows-df.cmake | 4 ++-- Source/cmLocalGenerator.cxx | 8 ++++---- Source/cmMakefileExecutableTargetGenerator.cxx | 7 +++++-- Tests/Fortran/CMakeLists.txt | 2 +- 12 files changed, 34 insertions(+), 24 deletions(-) diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 4fa14ce..b81bd4d 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -10,7 +10,6 @@ set(__CYGWIN_COMPILER_GNU 1) # TODO: Is -Wl,--enable-auto-import now always default? string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " -Wl,--enable-auto-import") -set(CMAKE_CREATE_WIN32_EXE "-mwindows") set(CMAKE_GNULD_IMAGE_VERSION "-Wl,--major-image-version,,--minor-image-version,") @@ -23,6 +22,7 @@ macro(__cygwin_compiler_gnu lang) " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") set(CMAKE_${lang}_LINK_EXECUTABLE " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") + set(CMAKE_${lang}_CREATE_WIN32_EXE "-mwindows") # No -fPIC on cygwin set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index c508ac1..7365ff5 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -71,8 +71,8 @@ macro(__windows_compiler_clang_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE " -fuse-ld=lld-link -nostartfiles -nostdlib -o -Xlinker /implib: -Xlinker /pdb: -Xlinker /version:. ${CMAKE_GNULD_IMAGE_VERSION} ") - set(CMAKE_CREATE_WIN32_EXE "-Xlinker /subsystem:windows") - set(CMAKE_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console") + set(CMAKE_${lang}_CREATE_WIN32_EXE "-Xlinker /subsystem:windows") + set(CMAKE_${lang}_CREATE_CONSOLE_EXE "-Xlinker /subsystem:console") if(NOT "${lang}" STREQUAL "ASM") set(CMAKE_${lang}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang -flto-visibility-public-std -D_MT -Xclang --dependent-lib=libcmt) diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index 8f1d024..4ecc2c2 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -51,11 +51,6 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib") # Borland cannot handle + in the file name, so mangle object file name set (CMAKE_MANGLE_OBJECT_FILE_NAMES "ON") -# extra flags for a win32 exe -set(CMAKE_CREATE_WIN32_EXE "${_tW}" ) -# extra flags for a console app -set(CMAKE_CREATE_CONSOLE_EXE "${_tC}" ) - set (CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") @@ -124,6 +119,9 @@ macro(__embarcadero_language lang) "tlib ${CMAKE_START_TEMP_FILE}/p512 /a ${CMAKE_END_TEMP_FILE}" ) + set(CMAKE_${lang}_CREATE_WIN32_EXE "${_tW}") + set(CMAKE_${lang}_CREATE_CONSOLE_EXE "${_tC}") + # Precompile Headers if (EMBARCADERO) set(CMAKE_PCH_EXTENSION .pch) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index a2e3811..e50c215 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -35,7 +35,6 @@ set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LINK_LIBRARY_FLAG "-l") set(CMAKE_LINK_DEF_FILE_FLAG "") # Empty string: passing the file is enough set(CMAKE_LINK_LIBRARY_SUFFIX "") -set(CMAKE_CREATE_WIN32_EXE "-mwindows") set(CMAKE_GNULD_IMAGE_VERSION "-Wl,--major-image-version,,--minor-image-version,") @@ -105,6 +104,7 @@ macro(__windows_compiler_gnu lang) " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") set(CMAKE_${lang}_LINK_EXECUTABLE " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") + set(CMAKE_${lang}_CREATE_WIN32_EXE "-mwindows") list(APPEND CMAKE_${lang}_ABI_FILES "Platform/Windows-GNU-${lang}-ABI") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e384af4..4223bde 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -27,12 +27,8 @@ else() endif() if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE") - set(CMAKE_CREATE_WIN32_EXE "/entry:WinMainCRTStartup") - set(CMAKE_CREATE_CONSOLE_EXE "/entry:mainACRTStartup") set(_PLATFORM_LINK_FLAGS " /subsystem:windowsce") else() - set(CMAKE_CREATE_WIN32_EXE "/subsystem:windows") - set(CMAKE_CREATE_CONSOLE_EXE "/subsystem:console") set(_PLATFORM_LINK_FLAGS "") endif() @@ -351,6 +347,14 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /version:.${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") + if(CMAKE_SYSTEM_NAME STREQUAL "WindowsCE") + set(CMAKE_${lang}_CREATE_WIN32_EXE "/entry:WinMainCRTStartup") + set(CMAKE_${lang}_CREATE_CONSOLE_EXE "/entry:mainACRTStartup") + else() + set(CMAKE_${lang}_CREATE_WIN32_EXE "/subsystem:windows") + set(CMAKE_${lang}_CREATE_CONSOLE_EXE "/subsystem:console") + endif() + set(CMAKE_PCH_EXTENSION .pch) set(CMAKE_LINK_PCH ON) if (CMAKE_${lang}_COMPILER_ID STREQUAL "Clang") diff --git a/Modules/Platform/Windows-OpenWatcom-C.cmake b/Modules/Platform/Windows-OpenWatcom-C.cmake index ce9bc45..b82a4cb 100644 --- a/Modules/Platform/Windows-OpenWatcom-C.cmake +++ b/Modules/Platform/Windows-OpenWatcom-C.cmake @@ -1 +1,2 @@ include(Platform/Windows-OpenWatcom) +__windows_open_watcom(C) diff --git a/Modules/Platform/Windows-OpenWatcom-CXX.cmake b/Modules/Platform/Windows-OpenWatcom-CXX.cmake index ce9bc45..ac90d28 100644 --- a/Modules/Platform/Windows-OpenWatcom-CXX.cmake +++ b/Modules/Platform/Windows-OpenWatcom-CXX.cmake @@ -1 +1,2 @@ include(Platform/Windows-OpenWatcom) +__windows_open_watcom(CXX) diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake index 70055da..19bcb97 100644 --- a/Modules/Platform/Windows-OpenWatcom.cmake +++ b/Modules/Platform/Windows-OpenWatcom.cmake @@ -6,8 +6,6 @@ include_guard() set(CMAKE_BUILD_TYPE_INIT Debug) -set(CMAKE_CREATE_WIN32_EXE "system nt_win" ) -set(CMAKE_CREATE_CONSOLE_EXE "system nt" ) string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system nt_dll") string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system nt_dll") @@ -30,3 +28,8 @@ if(CMAKE_CROSSCOMPILING) set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES $ENV{WATCOM}/h $ENV{WATCOM}/h/nt) endif() endif() + +macro(__windows_open_watcom lang) + set(CMAKE_${lang}_CREATE_WIN32_EXE "system nt_win") + set(CMAKE_${lang}_CREATE_CONSOLE_EXE "system nt") +endmacro() diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake index 8b824bc..c823423 100644 --- a/Modules/Platform/Windows-df.cmake +++ b/Modules/Platform/Windows-df.cmake @@ -27,8 +27,8 @@ set(CMAKE_Fortran_COMPILE_OBJECT set(CMAKE_Fortran_LINK_EXECUTABLE " ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /exe: /link ${CMAKE_END_TEMP_FILE}") -set(CMAKE_CREATE_WIN32_EXE /winapp) -set(CMAKE_CREATE_CONSOLE_EXE ) +set(CMAKE_Fortran_CREATE_WIN32_EXE /winapp) +set(CMAKE_Fortran_CREATE_CONSOLE_EXE ) # does the compiler support pdbtype and is it the newer compiler diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 79d1de0..b301c6e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1527,12 +1527,12 @@ void cmLocalGenerator::GetTargetFlags( } if (target->IsWin32Executable(config)) { - exeFlags += - this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); + exeFlags += this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", linkLanguage, "_CREATE_WIN32_EXE")); exeFlags += " "; } else { - exeFlags += - this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); + exeFlags += this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", linkLanguage, "_CREATE_CONSOLE_EXE")); exeFlags += " "; } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 1750e37..6783341 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -384,11 +384,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if (this->GeneratorTarget->IsWin32Executable( this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"))) { this->LocalGenerator->AppendFlags( - linkFlags, this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE")); + linkFlags, + this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", linkLanguage, "_CREATE_WIN32_EXE"))); } else { this->LocalGenerator->AppendFlags( linkFlags, - this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE")); + this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", linkLanguage, "_CREATE_CONSOLE_EXE"))); } // Add symbol export flags if necessary. diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 1868892..c1476be 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -131,7 +131,7 @@ else() # as a language, cmake needs language specific versions # of these variables.... if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - set(CMAKE_CREATE_CONSOLE_EXE ) + set(CMAKE_Fortran_CREATE_CONSOLE_EXE ) set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LINK_LIBRARY_FLAG "-l") set(CMAKE_LINK_LIBRARY_SUFFIX ) -- cgit v0.12 From dd952f28e9e2a3687dc9b666886d0fea0c764bbb Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 18 Mar 2021 00:01:15 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index bea8efd..163224c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210317) +set(CMake_VERSION_PATCH 20210318) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From fae7910268ca132c3eee28f8fbae9eb29516b5cc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 18 Mar 2021 01:04:02 +0100 Subject: Help: Fix typos in presets schema field descriptions --- Help/manual/presets/schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index c29d686..e2b1d95 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -19,7 +19,7 @@ "properties": { "version": { "const": 2, - "description": "A requVired integer representing the version of the JSON schema." + "description": "A required integer representing the version of the JSON schema." }, "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"}, "vendor": { "$ref": "#/definitions/vendor" }, -- cgit v0.12 From 52d3d1bdc5c099209d02e44130d352df55ffc9a0 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 18 Mar 2021 10:39:41 -0400 Subject: FindDevIL: Format documentation of provided variables --- Modules/FindDevIL.cmake | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake index 9984943..e01cdcd 100644 --- a/Modules/FindDevIL.cmake +++ b/Modules/FindDevIL.cmake @@ -12,24 +12,31 @@ http://openil.sourceforge.net/ This module sets: -:: - - IL_LIBRARIES - the name of the IL library. These include the full path to - the core DevIL library. This one has to be linked into the - application. - ILU_LIBRARIES - the name of the ILU library. Again, the full path. This - library is for filters and effects, not actual loading. It - doesn't have to be linked if the functionality it provides - is not used. - ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the - library interfaces with OpenGL. It is not strictly needed - in applications. - IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files. - DevIL_FOUND - this is set to TRUE if all the above variables were set. - This will be set to false if ILU or ILUT are not found, - even if they are not needed. In most systems, if one - library is found all the others are as well. That's the - way the DevIL developers release it. +``IL_LIBRARIES`` + The name of the IL library. These include the full path to + the core DevIL library. This one has to be linked into the + application. + +``ILU_LIBRARIES`` + The name of the ILU library. Again, the full path. This + library is for filters and effects, not actual loading. It + doesn't have to be linked if the functionality it provides + is not used. + +``ILUT_LIBRARIES`` + The name of the ILUT library. Full path. This part of the + library interfaces with OpenGL. It is not strictly needed + in applications. + +``IL_INCLUDE_DIR`` + where to find the il.h, ilu.h and ilut.h files. + +``DevIL_FOUND`` + This is set to TRUE if all the above variables were set. + This will be set to false if ILU or ILUT are not found, + even if they are not needed. In most systems, if one + library is found all the others are as well. That's the + way the DevIL developers release it. #]=======================================================================] # TODO: Add version support. -- cgit v0.12 From 73b27f6ae8c9599c9cfea13d8b3413837355ec8a Mon Sep 17 00:00:00 2001 From: Alex <10857-leha-bot@users.noreply.gitlab.kitware.com> Date: Mon, 8 Mar 2021 21:11:09 +0300 Subject: FindDevIL: add imported targets and tests Fixes: #21900 --- Help/release/dev/FindDevIL-imported-targets.rst | 4 ++ Modules/FindDevIL.cmake | 57 +++++++++++++++++++++++++ Tests/CMakeLists.txt | 1 + Tests/FindDevIL/CMakeLists.txt | 10 +++++ Tests/FindDevIL/Test/CMakeLists.txt | 29 +++++++++++++ Tests/FindDevIL/Test/main.c | 10 +++++ Tests/FindDevIL/Test/main_ilu.c | 8 ++++ 7 files changed, 119 insertions(+) create mode 100644 Help/release/dev/FindDevIL-imported-targets.rst create mode 100644 Tests/FindDevIL/CMakeLists.txt create mode 100644 Tests/FindDevIL/Test/CMakeLists.txt create mode 100644 Tests/FindDevIL/Test/main.c create mode 100644 Tests/FindDevIL/Test/main_ilu.c diff --git a/Help/release/dev/FindDevIL-imported-targets.rst b/Help/release/dev/FindDevIL-imported-targets.rst new file mode 100644 index 0000000..aa0929e --- /dev/null +++ b/Help/release/dev/FindDevIL-imported-targets.rst @@ -0,0 +1,4 @@ +FindDevIL +--------- + +* The :module:`FindDevIL` module now provides imported targets. diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake index e01cdcd..c8e5e31 100644 --- a/Modules/FindDevIL.cmake +++ b/Modules/FindDevIL.cmake @@ -10,6 +10,25 @@ FindDevIL This module locates the developer's image library. http://openil.sourceforge.net/ +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.21 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``DevIL::IL`` + Defined if the system has DevIL. + +``DevIL::ILU`` + Defined if the system has DevIL Utilities. + +``DevIL::ILUT`` + Defined if the system has DevIL Utility Toolkit. + +Result Variables +^^^^^^^^^^^^^^^^ + This module sets: ``IL_LIBRARIES`` @@ -37,6 +56,11 @@ This module sets: even if they are not needed. In most systems, if one library is found all the others are as well. That's the way the DevIL developers release it. + +``DevIL_ILUT_FOUND`` + .. versionadded:: 3.21 + + This is set to TRUE if the ILUT library is found. #]=======================================================================] # TODO: Add version support. @@ -80,3 +104,36 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(DevIL DEFAULT_MSG IL_INCLUDE_DIR) # provide legacy variable for compatibility set(IL_FOUND ${DevIL_FOUND}) + +# create imported targets ONLY if we found DevIL. +if(DevIL_FOUND) + # Report the ILUT found if ILUT_LIBRARIES contains valid path. + if (ILUT_LIBRARIES) + set(DevIL_ILUT_FOUND TRUE) + else() + set(DevIL_ILUT_FOUND FALSE) + endif() + + if(NOT TARGET DevIL::IL) + add_library(DevIL::IL UNKNOWN IMPORTED) + set_target_properties(DevIL::IL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${IL_INCLUDE_DIR}" + IMPORTED_LOCATION "${IL_LIBRARIES}") + endif() + + # DevIL Utilities target + if(NOT TARGET DevIL::ILU) + add_library(DevIL::ILU UNKNOWN IMPORTED) + set_target_properties(DevIL::ILU PROPERTIES + IMPORTED_LOCATION "${ILU_LIBRARIES}") + target_link_libraries(DevIL::ILU INTERFACE DevIL::IL) + endif() + + # ILUT (if found) + if(NOT TARGET DevIL::ILUT AND DevIL_ILUT_FOUND) + add_library(DevIL::ILUT UNKNOWN IMPORTED) + set_target_properties(DevIL::ILUT PROPERTIES + IMPORTED_LOCATION "${ILUT_LIBRARIES}") + target_link_libraries(DevIL::ILUT INTERFACE DevIL::ILU) + endif() +endif() diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0430afb..e532ace 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1424,6 +1424,7 @@ if(BUILD_TESTING) CURL Cups Doxygen + DevIL EnvModules EXPAT Fontconfig diff --git a/Tests/FindDevIL/CMakeLists.txt b/Tests/FindDevIL/CMakeLists.txt new file mode 100644 index 0000000..d37d50f --- /dev/null +++ b/Tests/FindDevIL/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindDevIL.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindDevIL/Test" + "${CMake_BINARY_DIR}/Tests/FindDevIL/Test" + ${build_generator_args} + --build-project TestFindDevIL + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) diff --git a/Tests/FindDevIL/Test/CMakeLists.txt b/Tests/FindDevIL/Test/CMakeLists.txt new file mode 100644 index 0000000..c2c1322 --- /dev/null +++ b/Tests/FindDevIL/Test/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.1) +project(TestFindDevIL C) +include(CTest) + +find_package(DevIL) + +#FIXME: check version too. +# add_definitions( +# -DCMAKE_EXPECTED_SDL_VERSION_MAJOR=${SDL_VERSION_MAJOR} +# -DCMAKE_EXPECTED_SDL_VERSION_MINOR=${SDL_VERSION_MINOR} +# -DCMAKE_EXPECTED_SDL_VERSION_PATCH=${SDL_VERSION_PATCH}) + +add_executable(test_devil_var main.c) +target_include_directories(test_devil_var PRIVATE ${IL_INCLUDE_DIRS}) +target_link_libraries(test_devil_var PRIVATE ${IL_LIBRARIES}) +add_test(NAME test_devil_var COMMAND test_devil_var) + +add_executable(test_devil_il_tgt main.c) +target_link_libraries(test_devil_il_tgt DevIL::IL) +add_test(NAME test_devil_il_tgt COMMAND test_devil_il_tgt) + +add_executable(test_devil_ilu_tgt main_ilu.c) +target_link_libraries(test_devil_ilu_tgt DevIL::ILU) + +add_executable(test_devil_ilu_var main_ilu.c) +target_include_directories(test_devil_ilu_var PRIVATE ${IL_INCLUDE_DIRS} ${ILU_INCLUDE_DIRS}) +target_link_libraries(test_devil_ilu_var ${IL_LIBRARIES} ${ILU_LIBRARIES}) + +#FIXME: Check DevIL::ILUT target diff --git a/Tests/FindDevIL/Test/main.c b/Tests/FindDevIL/Test/main.c new file mode 100644 index 0000000..4a07087 --- /dev/null +++ b/Tests/FindDevIL/Test/main.c @@ -0,0 +1,10 @@ +#include + +int main() +{ + // Test 1 requires to link to the library. + ilInit(); + + ilShutDown(); + return 0; +} diff --git a/Tests/FindDevIL/Test/main_ilu.c b/Tests/FindDevIL/Test/main_ilu.c new file mode 100644 index 0000000..a9e7819 --- /dev/null +++ b/Tests/FindDevIL/Test/main_ilu.c @@ -0,0 +1,8 @@ +#include + +int main() +{ + // IL Utilities requires only initialization. + // Unlike main DevIL there are no shutdown function. + iluInit(); +} -- cgit v0.12 From c73b847b0311a0eff0eeaa113991bce0149532a7 Mon Sep 17 00:00:00 2001 From: Marcel Ritzschke Date: Sun, 14 Mar 2021 18:14:19 +0100 Subject: VS: switch to new folder structure while keeping the old one working Fixes: #21170 --- .../CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst | 13 +++++------ Modules/CMakeDetermineCompilerId.cmake | 16 ++++++++++--- Source/cmGlobalVisualStudio10Generator.cxx | 27 ++++++++++++++++++++-- Source/cmGlobalVisualStudio10Generator.h | 9 ++++++++ Source/cmVisualStudio10TargetGenerator.cxx | 12 ++++++---- Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake | 6 ++++- .../TestToolsetCudaPathOnly-stderr.txt | 4 ++-- .../TestToolsetCudaPathOnlyOldLayout-result.txt | 1 + .../TestToolsetCudaPathOnlyOldLayout-stderr.txt | 12 ++++++++++ .../TestToolsetCudaPathOnlyOldLayout.cmake | 1 + 10 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt create mode 100644 Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt create mode 100644 Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake diff --git a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst index 74db6b1..a19e7e1 100644 --- a/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst +++ b/Help/variable/CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR.rst @@ -9,10 +9,9 @@ The :ref:`Visual Studio Generators` for VS 2010 and above support using a standalone (non-installed) NVIDIA CUDA toolkit. The path may be specified by a field in :variable:`CMAKE_GENERATOR_TOOLSET` of the form ``cuda=C:\path\to\cuda``. The given directory must at least -contain a folder ``.\nvcc`` and must provide Visual Studio integration -files in path ``.\CUDAVisualStudioIntegration\extras\ -visual_studio_integration\MSBuildExtensions\``. One can create a standalone -CUDA toolkit directory by either opening a installer with 7zip or -copying the files that are extracted by the running installer. -The value may be empty if no path to a standalone CUDA Toolkit was -specified. +contain the nvcc compiler in path ``.\bin`` and must provide Visual Studio +integration files in path ``.\extras\visual_studio_integration\ +MSBuildExtensions\``. One can create a standalone CUDA toolkit directory by +either opening a installer with 7zip or copying the files that are extracted +by the running installer. The value may be empty if no path to a standalone +CUDA Toolkit was specified. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 1595cfd..f406e5a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -452,9 +452,19 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_ItemDefinitionGroup_entry "${cuda_target}%(AdditionalOptions)-v${cuda_codegen}") set(id_PostBuildEvent_Command [[echo CMAKE_CUDA_COMPILER=$(CudaToolkitBinDir)\nvcc.exe]]) if(CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR) - set(id_CudaToolkitCustomDir "${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc") - string(CONCAT id_Import_props "") - string(CONCAT id_Import_targets "") + # check for legacy cuda custom toolkit folder structure + if(EXISTS ${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc) + set(id_CudaToolkitCustomDir "${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}nvcc") + else() + set(id_CudaToolkitCustomDir "${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}") + endif() + if(EXISTS ${CMAKE_VS_PLATFORM_TOOLSET_CUDA_CUSTOM_DIR}CUDAVisualStudioIntegration) + string(CONCAT id_Import_props "") + string(CONCAT id_Import_targets "") + else() + string(CONCAT id_Import_props "") + string(CONCAT id_Import_targets "") + endif() else() string(CONCAT id_Import_props [[]]) string(CONCAT id_Import_targets [[]]) diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 74d8135..d33c763 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -263,8 +263,8 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( bcDir = this->VCTargetsPath + "/BuildCustomizations"; } else { bcDir = this->GetPlatformToolsetCudaCustomDirString() + - "CUDAVisualStudioIntegration\\extras\\" - "visual_studio_integration\\MSBuildExtensions"; + this->GetPlatformToolsetCudaVSIntegrationSubdirString() + + "extras\\visual_studio_integration\\MSBuildExtensions"; cmSystemTools::ConvertToUnixSlashes(bcDir); } cmsys::Glob gl; @@ -470,6 +470,17 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField( if (this->GeneratorToolsetCudaCustomDir.back() != '\\') { this->GeneratorToolsetCudaCustomDir.push_back('\\'); } + /* check for legacy toolkit folder structure */ + if (cmsys::SystemTools::FileIsDirectory( + cmStrCat(this->GeneratorToolsetCudaCustomDir, "nvcc"))) { + this->GeneratorToolsetCudaNvccSubdir = "nvcc\\"; + } + if (cmsys::SystemTools::FileIsDirectory( + cmStrCat(this->GeneratorToolsetCudaCustomDir, + "CUDAVisualStudioIntegration"))) { + this->GeneratorToolsetCudaVSIntegrationSubdir = + "CUDAVisualStudioIntegration\\"; + } } else { this->GeneratorToolsetCuda = value; } @@ -787,6 +798,18 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaCustomDirString() const return this->GeneratorToolsetCudaCustomDir; } +std::string const& +cmGlobalVisualStudio10Generator::GetPlatformToolsetCudaNvccSubdirString() const +{ + return this->GeneratorToolsetCudaNvccSubdir; +} + +std::string const& cmGlobalVisualStudio10Generator:: + GetPlatformToolsetCudaVSIntegrationSubdirString() const +{ + return this->GeneratorToolsetCudaVSIntegrationSubdir; +} + cmGlobalVisualStudio10Generator::AuxToolset cmGlobalVisualStudio10Generator::FindAuxToolset(std::string&, std::string&) const diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 5e42c17..e221d4c 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -78,6 +78,13 @@ public: const char* GetPlatformToolsetCudaCustomDir() const; std::string const& GetPlatformToolsetCudaCustomDirString() const; + /** The nvcc subdirectory of a custom cuda install directory */ + std::string const& GetPlatformToolsetCudaNvccSubdirString() const; + + /** The visual studio integration subdirectory of a custom cuda install + * directory */ + std::string const& GetPlatformToolsetCudaVSIntegrationSubdirString() const; + /** Return whether we need to use No/Debug instead of false/true for GenerateDebugInformation. */ bool GetPlatformToolsetNeedsDebugEnum() const @@ -188,6 +195,8 @@ protected: std::string GeneratorToolsetCustomVCTargetsDir; std::string GeneratorToolsetCuda; std::string GeneratorToolsetCudaCustomDir; + std::string GeneratorToolsetCudaNvccSubdir; + std::string GeneratorToolsetCudaVSIntegrationSubdir; std::string DefaultPlatformToolset; std::string DefaultPlatformToolsetHostArchitecture; std::string DefaultAndroidToolset; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 965ac3e..0255d60 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -545,7 +545,7 @@ void cmVisualStudio10TargetGenerator::Generate() e1.Element( "CudaToolkitCustomDir", this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() + - "nvcc"); + this->GlobalGenerator->GetPlatformToolsetCudaNvccSubdirString()); } } @@ -654,8 +654,9 @@ void cmVisualStudio10TargetGenerator::Generate() std::string cudaPath = customDir.empty() ? "$(VCTargetsPath)\\BuildCustomizations\\" : customDir + - "CUDAVisualStudioIntegration\\extras\\" - "visual_studio_integration\\MSBuildExtensions\\"; + this->GlobalGenerator + ->GetPlatformToolsetCudaVSIntegrationSubdirString() + + "extras\\visual_studio_integration\\MSBuildExtensions\\"; Elem(e1, "Import") .Attribute("Project", std::move(cudaPath) + "CUDA " + @@ -747,8 +748,9 @@ void cmVisualStudio10TargetGenerator::Generate() std::string cudaPath = customDir.empty() ? "$(VCTargetsPath)\\BuildCustomizations\\" : customDir + - "CUDAVisualStudioIntegration\\extras\\" - "visual_studio_integration\\MSBuildExtensions\\"; + this->GlobalGenerator + ->GetPlatformToolsetCudaVSIntegrationSubdirString() + + "extras\\visual_studio_integration\\MSBuildExtensions\\"; Elem(e1, "Import") .Attribute("Project", std::move(cudaPath) + "CUDA " + diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index 75ed677..3aa791d 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -12,8 +12,12 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") run_cmake(TestToolsetCudaVersionOnly) set(RunCMake_GENERATOR_TOOLSET "cuda=0.0") run_cmake(TestToolsetCudaVersionOnly) - set(RunCMake_GENERATOR_TOOLSET "cuda=C:\\dummy\\cuda") + set(RunCMake_GENERATOR_TOOLSET "cuda=${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset") run_cmake(TestToolsetCudaPathOnly) + set(RunCMake_GENERATOR_TOOLSET "cuda=${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset") + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset/CUDAVisualStudioIntegration") + run_cmake(TestToolsetCudaPathOnlyOldLayout) + file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset") if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(TestToolsetHostArchBoth) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt index b17745f..5236787 100644 --- a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnly-stderr.txt @@ -5,8 +5,8 @@ CMake Error at CMakeLists.txt:[0-9]+ \(project\): given toolset - cuda=C:\\dummy\\cuda\\ + cuda=.*/Tests/RunCMake/CudaStandaloneToolset\\ cannot detect Visual Studio integration files in path - C:/dummy/cuda/CUDAVisualStudioIntegration/extras/visual_studio_integration/MSBuildExtensions + .*/Tests/RunCMake/CudaStandaloneToolset/extras/visual_studio_integration/MSBuildExtensions diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt new file mode 100644 index 0000000..3ce79f8 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio .* + + given toolset + + cuda=.*/Tests/RunCMake/CudaStandaloneToolset\\ + + cannot detect Visual Studio integration files in path + + .*/Tests/RunCMake/CudaStandaloneToolset/CUDAVisualStudioIntegration/extras/visual_studio_integration/MSBuildExtensions diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCudaPathOnlyOldLayout.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") -- cgit v0.12 From 87cd4f3ba0de7353b98d81cf7a677c619ec8b03b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 19 Mar 2021 00:01:17 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 163224c..88c1631 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210318) +set(CMake_VERSION_PATCH 20210319) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From ebbd475e54e0ce66dbb1b07a129a11b05cdf3dbb Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 19 Mar 2021 10:25:50 -0400 Subject: Refactor: Move cmCMakePresetsFile::ReadJSON into a separate file Some compilers complain about translation units that are too large. In order to prepare for upcoming additions to cmCMakePresetsFile, split ReadJSON into a separate file. --- Source/CMakeLists.txt | 1 + Source/cmCMakePresetsFile.cxx | 787 --------------------------------- Source/cmCMakePresetsFileReadJSON.cxx | 803 ++++++++++++++++++++++++++++++++++ 3 files changed, 804 insertions(+), 787 deletions(-) create mode 100644 Source/cmCMakePresetsFileReadJSON.cxx diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d782890..8b11a53 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -198,6 +198,7 @@ set(SRCS cmCMakePath.cxx cmCMakePresetsFile.cxx cmCMakePresetsFile.h + cmCMakePresetsFileReadJSON.cxx cmCommandArgumentParserHelper.cxx cmCommonTargetGenerator.cxx cmCommonTargetGenerator.h diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index c73ca9a..1d95953 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -9,18 +9,8 @@ #include #include -#include -#include - -#include -#include - -#include "cmsys/FStream.hxx" - -#include "cmJSONHelpers.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#include "cmVersion.h" #define CHECK_OK(expr) \ { \ @@ -51,675 +41,9 @@ enum class CycleStatus }; using ReadFileResult = cmCMakePresetsFile::ReadFileResult; -using CacheVariable = cmCMakePresetsFile::CacheVariable; using ConfigurePreset = cmCMakePresetsFile::ConfigurePreset; using BuildPreset = cmCMakePresetsFile::BuildPreset; using TestPreset = cmCMakePresetsFile::TestPreset; -using ArchToolsetStrategy = cmCMakePresetsFile::ArchToolsetStrategy; - -constexpr int MIN_VERSION = 1; -constexpr int MAX_VERSION = 3; - -struct CMakeVersion -{ - unsigned int Major = 0; - unsigned int Minor = 0; - unsigned int Patch = 0; -}; - -struct RootPresets -{ - CMakeVersion CMakeMinimumRequired; - std::vector ConfigurePresets; - std::vector BuildPresets; - std::vector TestPresets; -}; - -cmJSONHelper VendorHelper(ReadFileResult error) -{ - return [error](std::nullptr_t& /*out*/, - const Json::Value* value) -> ReadFileResult { - if (!value) { - return ReadFileResult::READ_OK; - } - - if (!value->isObject()) { - return error; - } - - return ReadFileResult::READ_OK; - }; -} - -auto const VersionIntHelper = cmJSONIntHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_VERSION); - -auto const VersionHelper = cmJSONRequiredHelper( - ReadFileResult::NO_VERSION, VersionIntHelper); - -auto const RootVersionHelper = - cmJSONObjectHelper(ReadFileResult::READ_OK, - ReadFileResult::INVALID_ROOT) - .Bind("version"_s, VersionHelper, false); - -auto const VariableStringHelper = cmJSONStringHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE); - -ReadFileResult VariableValueHelper(std::string& out, const Json::Value* value) -{ - if (!value) { - out.clear(); - return ReadFileResult::READ_OK; - } - - if (value->isBool()) { - out = value->asBool() ? "TRUE" : "FALSE"; - return ReadFileResult::READ_OK; - } - - return VariableStringHelper(out, value); -} - -auto const VariableObjectHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE, false) - .Bind("type"_s, &CacheVariable::Type, VariableStringHelper, false) - .Bind("value"_s, &CacheVariable::Value, VariableValueHelper); - -ReadFileResult VariableHelper(cm::optional& out, - const Json::Value* value) -{ - if (value->isBool()) { - out = CacheVariable{ - /*Type=*/"BOOL", - /*Value=*/value->asBool() ? "TRUE" : "FALSE", - }; - return ReadFileResult::READ_OK; - } - if (value->isString()) { - out = CacheVariable{ - /*Type=*/"", - /*Value=*/value->asString(), - }; - return ReadFileResult::READ_OK; - } - if (value->isObject()) { - out.emplace(); - return VariableObjectHelper(*out, value); - } - if (value->isNull()) { - out = cm::nullopt; - return ReadFileResult::READ_OK; - } - return ReadFileResult::INVALID_VARIABLE; -} - -auto const VariablesHelper = - cmJSONMapHelper, ReadFileResult>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, VariableHelper); - -auto const PresetStringHelper = cmJSONStringHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET); - -ReadFileResult EnvironmentHelper(cm::optional& out, - const Json::Value* value) -{ - if (!value || value->isNull()) { - out = cm::nullopt; - return ReadFileResult::READ_OK; - } - if (value->isString()) { - out = value->asString(); - return ReadFileResult::READ_OK; - } - return ReadFileResult::INVALID_PRESET; -} - -auto const EnvironmentMapHelper = - cmJSONMapHelper, ReadFileResult>( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, - EnvironmentHelper); - -auto const PresetVectorStringHelper = - cmJSONVectorHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, - PresetStringHelper); - -ReadFileResult PresetInheritsHelper(std::vector& out, - const Json::Value* value) -{ - out.clear(); - if (!value) { - return ReadFileResult::READ_OK; - } - - if (value->isString()) { - out.push_back(value->asString()); - return ReadFileResult::READ_OK; - } - - return PresetVectorStringHelper(out, value); -} - -auto const PresetBoolHelper = cmJSONBoolHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET); - -auto const PresetOptionalBoolHelper = - cmJSONOptionalHelper(ReadFileResult::READ_OK, - PresetBoolHelper); - -auto const PresetIntHelper = cmJSONIntHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET); - -auto const PresetOptionalIntHelper = cmJSONOptionalHelper( - ReadFileResult::READ_OK, PresetIntHelper); - -auto const PresetVectorIntHelper = cmJSONVectorHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, PresetIntHelper); - -auto const PresetWarningsHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("dev"_s, &ConfigurePreset::WarnDev, PresetOptionalBoolHelper, false) - .Bind("deprecated"_s, &ConfigurePreset::WarnDeprecated, - PresetOptionalBoolHelper, false) - .Bind("uninitialized"_s, &ConfigurePreset::WarnUninitialized, - PresetOptionalBoolHelper, false) - .Bind("unusedCli"_s, &ConfigurePreset::WarnUnusedCli, - PresetOptionalBoolHelper, false) - .Bind("systemVars"_s, &ConfigurePreset::WarnSystemVars, - PresetOptionalBoolHelper, false); - -auto const PresetErrorsHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("dev"_s, &ConfigurePreset::ErrorDev, PresetOptionalBoolHelper, false) - .Bind("deprecated"_s, &ConfigurePreset::ErrorDeprecated, - PresetOptionalBoolHelper, false); - -auto const PresetDebugHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("output"_s, &ConfigurePreset::DebugOutput, PresetOptionalBoolHelper, - false) - .Bind("tryCompile"_s, &ConfigurePreset::DebugTryCompile, - PresetOptionalBoolHelper, false) - .Bind("find"_s, &ConfigurePreset::DebugFind, PresetOptionalBoolHelper, - false); - -ReadFileResult ArchToolsetStrategyHelper( - cm::optional& out, const Json::Value* value) -{ - if (!value) { - out = cm::nullopt; - return ReadFileResult::READ_OK; - } - - if (!value->isString()) { - return ReadFileResult::INVALID_PRESET; - } - - if (value->asString() == "set") { - out = ArchToolsetStrategy::Set; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "external") { - out = ArchToolsetStrategy::External; - return ReadFileResult::READ_OK; - } - - return ReadFileResult::INVALID_PRESET; -} - -std::function -ArchToolsetHelper( - std::string ConfigurePreset::*valueField, - cm::optional ConfigurePreset::*strategyField) -{ - auto const objectHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("value", valueField, PresetStringHelper, false) - .Bind("strategy", strategyField, ArchToolsetStrategyHelper, false); - return [valueField, strategyField, objectHelper]( - ConfigurePreset& out, const Json::Value* value) -> ReadFileResult { - if (!value) { - (out.*valueField).clear(); - out.*strategyField = cm::nullopt; - return ReadFileResult::READ_OK; - } - - if (value->isString()) { - out.*valueField = value->asString(); - out.*strategyField = cm::nullopt; - return ReadFileResult::READ_OK; - } - - if (value->isObject()) { - return objectHelper(out, value); - } - - return ReadFileResult::INVALID_PRESET; - }; -} - -auto const ArchitectureHelper = ArchToolsetHelper( - &ConfigurePreset::Architecture, &ConfigurePreset::ArchitectureStrategy); -auto const ToolsetHelper = ArchToolsetHelper( - &ConfigurePreset::Toolset, &ConfigurePreset::ToolsetStrategy); - -auto const ConfigurePresetHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("name"_s, &ConfigurePreset::Name, PresetStringHelper) - .Bind("inherits"_s, &ConfigurePreset::Inherits, PresetInheritsHelper, - false) - .Bind("hidden"_s, &ConfigurePreset::Hidden, PresetBoolHelper, false) - .Bind("vendor"_s, nullptr, - VendorHelper(ReadFileResult::INVALID_PRESET), false) - .Bind("displayName"_s, &ConfigurePreset::DisplayName, PresetStringHelper, - false) - .Bind("description"_s, &ConfigurePreset::Description, PresetStringHelper, - false) - .Bind("generator"_s, &ConfigurePreset::Generator, PresetStringHelper, - false) - .Bind("architecture"_s, ArchitectureHelper, false) - .Bind("toolset"_s, ToolsetHelper, false) - .Bind("binaryDir"_s, &ConfigurePreset::BinaryDir, PresetStringHelper, - false) - .Bind("installDir"_s, &ConfigurePreset::InstallDir, PresetStringHelper, - false) - .Bind("cmakeExecutable"_s, nullptr, PresetStringHelper, false) - .Bind("cacheVariables"_s, &ConfigurePreset::CacheVariables, - VariablesHelper, false) - .Bind("environment"_s, &ConfigurePreset::Environment, EnvironmentMapHelper, - false) - .Bind("warnings"_s, PresetWarningsHelper, false) - .Bind("errors"_s, PresetErrorsHelper, false) - .Bind("debug"_s, PresetDebugHelper, false); - -auto const BuildPresetHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("name"_s, &BuildPreset::Name, PresetStringHelper) - .Bind("inherits"_s, &BuildPreset::Inherits, PresetInheritsHelper, false) - .Bind("hidden"_s, &BuildPreset::Hidden, PresetBoolHelper, false) - .Bind("vendor"_s, nullptr, - VendorHelper(ReadFileResult::INVALID_PRESET), false) - .Bind("displayName"_s, &BuildPreset::DisplayName, PresetStringHelper, - false) - .Bind("description"_s, &BuildPreset::Description, PresetStringHelper, - false) - .Bind("environment"_s, &BuildPreset::Environment, EnvironmentMapHelper, - false) - .Bind("configurePreset"_s, &BuildPreset::ConfigurePreset, - PresetStringHelper, false) - .Bind("inheritConfigureEnvironment"_s, - &BuildPreset::InheritConfigureEnvironment, PresetOptionalBoolHelper, - false) - .Bind("jobs"_s, &BuildPreset::Jobs, PresetOptionalIntHelper, false) - .Bind("targets"_s, &BuildPreset::Targets, PresetVectorStringHelper, false) - .Bind("configuration"_s, &BuildPreset::Configuration, PresetStringHelper, - false) - .Bind("cleanFirst"_s, &BuildPreset::CleanFirst, PresetOptionalBoolHelper, - false) - .Bind("verbose"_s, &BuildPreset::Verbose, PresetOptionalBoolHelper, false) - .Bind("nativeToolOptions"_s, &BuildPreset::NativeToolOptions, - PresetVectorStringHelper, false); - -ReadFileResult TestPresetOutputVerbosityHelper( - TestPreset::OutputOptions::VerbosityEnum& out, const Json::Value* value) -{ - if (!value) { - out = TestPreset::OutputOptions::VerbosityEnum::Default; - return ReadFileResult::READ_OK; - } - - if (!value->isString()) { - return ReadFileResult::INVALID_PRESET; - } - - if (value->asString() == "default") { - out = TestPreset::OutputOptions::VerbosityEnum::Default; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "verbose") { - out = TestPreset::OutputOptions::VerbosityEnum::Verbose; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "extra") { - out = TestPreset::OutputOptions::VerbosityEnum::Extra; - return ReadFileResult::READ_OK; - } - - return ReadFileResult::INVALID_PRESET; -} - -auto const TestPresetOptionalOutputVerbosityHelper = - cmJSONOptionalHelper(ReadFileResult::READ_OK, - TestPresetOutputVerbosityHelper); - -auto const TestPresetOptionalOutputHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("shortProgress"_s, &TestPreset::OutputOptions::ShortProgress, - PresetOptionalBoolHelper, false) - .Bind("verbosity"_s, &TestPreset::OutputOptions::Verbosity, - TestPresetOptionalOutputVerbosityHelper, false) - .Bind("debug"_s, &TestPreset::OutputOptions::Debug, - PresetOptionalBoolHelper, false) - .Bind("outputOnFailure"_s, &TestPreset::OutputOptions::OutputOnFailure, - PresetOptionalBoolHelper, false) - .Bind("quiet"_s, &TestPreset::OutputOptions::Quiet, - PresetOptionalBoolHelper, false) - .Bind("outputLogFile"_s, &TestPreset::OutputOptions::OutputLogFile, - PresetStringHelper, false) - .Bind("labelSummary"_s, &TestPreset::OutputOptions::LabelSummary, - PresetOptionalBoolHelper, false) - .Bind("subprojectSummary"_s, - &TestPreset::OutputOptions::SubprojectSummary, - PresetOptionalBoolHelper, false) - .Bind("maxPassedTestOutputSize"_s, - &TestPreset::OutputOptions::MaxPassedTestOutputSize, - PresetOptionalIntHelper, false) - .Bind("maxFailedTestOutputSize"_s, - &TestPreset::OutputOptions::MaxFailedTestOutputSize, - PresetOptionalIntHelper, false) - .Bind("maxTestNameWidth"_s, &TestPreset::OutputOptions::MaxTestNameWidth, - PresetOptionalIntHelper, false)); - -auto const TestPresetOptionalFilterIncludeIndexObjectHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper(ReadFileResult::READ_OK, - ReadFileResult::INVALID_PRESET) - .Bind("start"_s, &TestPreset::IncludeOptions::IndexOptions::Start, - PresetOptionalIntHelper, false) - .Bind("end"_s, &TestPreset::IncludeOptions::IndexOptions::End, - PresetOptionalIntHelper, false) - .Bind("stride"_s, &TestPreset::IncludeOptions::IndexOptions::Stride, - PresetOptionalIntHelper, false) - .Bind("specificTests"_s, - &TestPreset::IncludeOptions::IndexOptions::SpecificTests, - PresetVectorIntHelper, false)); - -ReadFileResult TestPresetOptionalFilterIncludeIndexHelper( - cm::optional& out, - const Json::Value* value) -{ - if (!value) { - out = cm::nullopt; - return ReadFileResult::READ_OK; - } - - if (value->isString()) { - out.emplace(); - out->IndexFile = value->asString(); - return ReadFileResult::READ_OK; - } - - if (value->isObject()) { - return TestPresetOptionalFilterIncludeIndexObjectHelper(out, value); - } - - return ReadFileResult::INVALID_PRESET; -} - -auto const TestPresetOptionalFilterIncludeHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) - .Bind("name"_s, &TestPreset::IncludeOptions::Name, PresetStringHelper, - false) - .Bind("label"_s, &TestPreset::IncludeOptions::Label, PresetStringHelper, - false) - .Bind("index"_s, &TestPreset::IncludeOptions::Index, - TestPresetOptionalFilterIncludeIndexHelper, false) - .Bind("useUnion"_s, &TestPreset::IncludeOptions::UseUnion, - PresetOptionalBoolHelper, false)); - -auto const TestPresetOptionalFilterExcludeFixturesHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper(ReadFileResult::READ_OK, - ReadFileResult::INVALID_PRESET) - .Bind("any"_s, &TestPreset::ExcludeOptions::FixturesOptions::Any, - PresetStringHelper, false) - .Bind("setup"_s, &TestPreset::ExcludeOptions::FixturesOptions::Setup, - PresetStringHelper, false) - .Bind("cleanup"_s, &TestPreset::ExcludeOptions::FixturesOptions::Cleanup, - PresetStringHelper, false)); - -auto const TestPresetOptionalFilterExcludeHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) - .Bind("name"_s, &TestPreset::ExcludeOptions::Name, PresetStringHelper, - false) - .Bind("label"_s, &TestPreset::ExcludeOptions::Label, PresetStringHelper, - false) - .Bind("fixtures"_s, &TestPreset::ExcludeOptions::Fixtures, - TestPresetOptionalFilterExcludeFixturesHelper, false)); - -ReadFileResult TestPresetExecutionShowOnlyHelper( - TestPreset::ExecutionOptions::ShowOnlyEnum& out, const Json::Value* value) -{ - if (!value || !value->isString()) { - return ReadFileResult::INVALID_PRESET; - } - - if (value->asString() == "human") { - out = TestPreset::ExecutionOptions::ShowOnlyEnum::Human; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "json-v1") { - out = TestPreset::ExecutionOptions::ShowOnlyEnum::JsonV1; - return ReadFileResult::READ_OK; - } - - return ReadFileResult::INVALID_PRESET; -} - -auto const TestPresetOptionalExecutionShowOnlyHelper = - cmJSONOptionalHelper(ReadFileResult::READ_OK, - TestPresetExecutionShowOnlyHelper); - -ReadFileResult TestPresetExecutionModeHelper( - TestPreset::ExecutionOptions::RepeatOptions::ModeEnum& out, - const Json::Value* value) -{ - if (!value) { - return ReadFileResult::READ_OK; - } - - if (!value->isString()) { - return ReadFileResult::INVALID_PRESET; - } - - if (value->asString() == "until-fail") { - out = TestPreset::ExecutionOptions::RepeatOptions::ModeEnum::UntilFail; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "until-pass") { - out = TestPreset::ExecutionOptions::RepeatOptions::ModeEnum::UntilPass; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "after-timeout") { - out = TestPreset::ExecutionOptions::RepeatOptions::ModeEnum::AfterTimeout; - return ReadFileResult::READ_OK; - } - - return ReadFileResult::INVALID_PRESET; -} - -auto const TestPresetOptionalExecutionRepeatHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper(ReadFileResult::READ_OK, - ReadFileResult::INVALID_PRESET) - .Bind("mode"_s, &TestPreset::ExecutionOptions::RepeatOptions::Mode, - TestPresetExecutionModeHelper, true) - .Bind("count"_s, &TestPreset::ExecutionOptions::RepeatOptions::Count, - PresetIntHelper, true)); - -ReadFileResult TestPresetExecutionNoTestsActionHelper( - TestPreset::ExecutionOptions::NoTestsActionEnum& out, - const Json::Value* value) -{ - if (!value) { - out = TestPreset::ExecutionOptions::NoTestsActionEnum::Default; - return ReadFileResult::READ_OK; - } - - if (!value->isString()) { - return ReadFileResult::INVALID_PRESET; - } - - if (value->asString() == "default") { - out = TestPreset::ExecutionOptions::NoTestsActionEnum::Default; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "error") { - out = TestPreset::ExecutionOptions::NoTestsActionEnum::Error; - return ReadFileResult::READ_OK; - } - - if (value->asString() == "ignore") { - out = TestPreset::ExecutionOptions::NoTestsActionEnum::Ignore; - return ReadFileResult::READ_OK; - } - - return ReadFileResult::INVALID_PRESET; -} - -auto const TestPresetOptionalExecutionNoTestsActionHelper = - cmJSONOptionalHelper(ReadFileResult::READ_OK, - TestPresetExecutionNoTestsActionHelper); - -auto const TestPresetExecutionHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) - .Bind("stopOnFailure"_s, &TestPreset::ExecutionOptions::StopOnFailure, - PresetOptionalBoolHelper, false) - .Bind("enableFailover"_s, &TestPreset::ExecutionOptions::EnableFailover, - PresetOptionalBoolHelper, false) - .Bind("jobs"_s, &TestPreset::ExecutionOptions::Jobs, - PresetOptionalIntHelper, false) - .Bind("resourceSpecFile"_s, - &TestPreset::ExecutionOptions::ResourceSpecFile, - PresetStringHelper, false) - .Bind("testLoad"_s, &TestPreset::ExecutionOptions::TestLoad, - PresetOptionalIntHelper, false) - .Bind("showOnly"_s, &TestPreset::ExecutionOptions::ShowOnly, - TestPresetOptionalExecutionShowOnlyHelper, false) - .Bind("repeat"_s, &TestPreset::ExecutionOptions::Repeat, - TestPresetOptionalExecutionRepeatHelper, false) - .Bind("interactiveDebugging"_s, - &TestPreset::ExecutionOptions::InteractiveDebugging, - PresetOptionalBoolHelper, false) - .Bind("scheduleRandom"_s, &TestPreset::ExecutionOptions::ScheduleRandom, - PresetOptionalBoolHelper, false) - .Bind("timeout"_s, &TestPreset::ExecutionOptions::Timeout, - PresetOptionalIntHelper, false) - .Bind("noTestsAction"_s, &TestPreset::ExecutionOptions::NoTestsAction, - TestPresetOptionalExecutionNoTestsActionHelper, false)); - -auto const TestPresetFilterHelper = - cmJSONOptionalHelper( - ReadFileResult::READ_OK, - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) - .Bind("include"_s, &TestPreset::FilterOptions::Include, - TestPresetOptionalFilterIncludeHelper, false) - .Bind("exclude"_s, &TestPreset::FilterOptions::Exclude, - TestPresetOptionalFilterExcludeHelper, false)); - -auto const TestPresetHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) - .Bind("name"_s, &TestPreset::Name, PresetStringHelper) - .Bind("inherits"_s, &TestPreset::Inherits, PresetInheritsHelper, false) - .Bind("hidden"_s, &TestPreset::Hidden, PresetBoolHelper, false) - .Bind("vendor"_s, nullptr, - VendorHelper(ReadFileResult::INVALID_PRESET), false) - .Bind("displayName"_s, &TestPreset::DisplayName, PresetStringHelper, false) - .Bind("description"_s, &TestPreset::Description, PresetStringHelper, false) - .Bind("environment"_s, &TestPreset::Environment, EnvironmentMapHelper, - false) - .Bind("configurePreset"_s, &TestPreset::ConfigurePreset, - PresetStringHelper, false) - .Bind("inheritConfigureEnvironment"_s, - &TestPreset::InheritConfigureEnvironment, PresetOptionalBoolHelper, - false) - .Bind("configuration"_s, &TestPreset::Configuration, PresetStringHelper, - false) - .Bind("overwriteConfigurationFile"_s, - &TestPreset::OverwriteConfigurationFile, PresetVectorStringHelper, - false) - .Bind("output"_s, &TestPreset::Output, TestPresetOptionalOutputHelper, - false) - .Bind("filter"_s, &TestPreset::Filter, TestPresetFilterHelper, false) - .Bind("execution"_s, &TestPreset::Execution, TestPresetExecutionHelper, - false); - -auto const ConfigurePresetsHelper = - cmJSONVectorHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, - ConfigurePresetHelper); - -auto const BuildPresetsHelper = - cmJSONVectorHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, - BuildPresetHelper); - -auto const TestPresetsHelper = cmJSONVectorHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, TestPresetHelper); - -auto const CMakeVersionUIntHelper = cmJSONUIntHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_VERSION); - -auto const CMakeVersionHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_CMAKE_VERSION, false) - .Bind("major"_s, &CMakeVersion::Major, CMakeVersionUIntHelper, false) - .Bind("minor"_s, &CMakeVersion::Minor, CMakeVersionUIntHelper, false) - .Bind("patch"_s, &CMakeVersion::Patch, CMakeVersionUIntHelper, false); - -auto const RootPresetsHelper = - cmJSONObjectHelper( - ReadFileResult::READ_OK, ReadFileResult::INVALID_ROOT, false) - .Bind("version"_s, nullptr, VersionHelper) - .Bind("configurePresets"_s, &RootPresets::ConfigurePresets, - ConfigurePresetsHelper, false) - .Bind("buildPresets"_s, &RootPresets::BuildPresets, BuildPresetsHelper, - false) - .Bind("testPresets"_s, &RootPresets::TestPresets, TestPresetsHelper, false) - .Bind("cmakeMinimumRequired"_s, &RootPresets::CMakeMinimumRequired, - CMakeVersionHelper, false) - .Bind("vendor"_s, nullptr, - VendorHelper(ReadFileResult::INVALID_ROOT), false); void InheritString(std::string& child, const std::string& parent) { @@ -1557,117 +881,6 @@ const char* cmCMakePresetsFile::ResultToString(ReadFileResult result) return "Unknown error"; } -cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( - const std::string& filename, bool user) -{ - cmsys::ifstream fin(filename.c_str()); - if (!fin) { - return ReadFileResult::FILE_NOT_FOUND; - } - // If there's a BOM, toss it. - cmsys::FStream::ReadBOM(fin); - - Json::Value root; - Json::CharReaderBuilder builder; - Json::CharReaderBuilder::strictMode(&builder.settings_); - if (!Json::parseFromStream(builder, fin, &root, nullptr)) { - return ReadFileResult::JSON_PARSE_ERROR; - } - - int v = 0; - auto result = RootVersionHelper(v, &root); - if (result != ReadFileResult::READ_OK) { - return result; - } - if (v < MIN_VERSION || v > MAX_VERSION) { - return ReadFileResult::UNRECOGNIZED_VERSION; - } - if (user) { - this->UserVersion = v; - } else { - this->Version = v; - } - - // Support for build and test presets added in version 2. - if (v < 2 && - (root.isMember("buildPresets") || root.isMember("testPresets"))) { - return ReadFileResult::BUILD_TEST_PRESETS_UNSUPPORTED; - } - - RootPresets presets; - if ((result = RootPresetsHelper(presets, &root)) != - ReadFileResult::READ_OK) { - return result; - } - - unsigned int currentMajor = cmVersion::GetMajorVersion(); - unsigned int currentMinor = cmVersion::GetMinorVersion(); - unsigned int currentPatch = cmVersion::GetPatchVersion(); - auto const& required = presets.CMakeMinimumRequired; - if (required.Major > currentMajor || - (required.Major == currentMajor && - (required.Minor > currentMinor || - (required.Minor == currentMinor && - (required.Patch > currentPatch))))) { - return ReadFileResult::UNRECOGNIZED_CMAKE_VERSION; - } - - for (auto& preset : presets.ConfigurePresets) { - preset.User = user; - if (preset.Name.empty()) { - return ReadFileResult::INVALID_PRESET; - } - - PresetPair presetPair; - presetPair.Unexpanded = preset; - presetPair.Expanded = cm::nullopt; - if (!this->ConfigurePresets - .emplace(std::make_pair(preset.Name, presetPair)) - .second) { - return ReadFileResult::DUPLICATE_PRESETS; - } - - // Support for installDir presets added in version 3. - if (v < 3 && !preset.InstallDir.empty()) { - return ReadFileResult::INSTALL_PREFIX_UNSUPPORTED; - } - - this->ConfigurePresetOrder.push_back(preset.Name); - } - - for (auto& preset : presets.BuildPresets) { - preset.User = user; - if (preset.Name.empty()) { - return ReadFileResult::INVALID_PRESET; - } - - PresetPair presetPair; - presetPair.Unexpanded = preset; - presetPair.Expanded = cm::nullopt; - if (!this->BuildPresets.emplace(preset.Name, presetPair).second) { - return ReadFileResult::DUPLICATE_PRESETS; - } - this->BuildPresetOrder.push_back(preset.Name); - } - - for (auto& preset : presets.TestPresets) { - preset.User = user; - if (preset.Name.empty()) { - return ReadFileResult::INVALID_PRESET; - } - - PresetPair presetPair; - presetPair.Unexpanded = preset; - presetPair.Expanded = cm::nullopt; - if (!this->TestPresets.emplace(preset.Name, presetPair).second) { - return ReadFileResult::DUPLICATE_PRESETS; - } - this->TestPresetOrder.push_back(preset.Name); - } - - return ReadFileResult::READ_OK; -} - void cmCMakePresetsFile::ClearPresets() { this->ConfigurePresets.clear(); diff --git a/Source/cmCMakePresetsFileReadJSON.cxx b/Source/cmCMakePresetsFileReadJSON.cxx new file mode 100644 index 0000000..b71b176 --- /dev/null +++ b/Source/cmCMakePresetsFileReadJSON.cxx @@ -0,0 +1,803 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "cmsys/FStream.hxx" + +#include "cmCMakePresetsFile.h" +#include "cmJSONHelpers.h" +#include "cmVersion.h" + +namespace { +using ReadFileResult = cmCMakePresetsFile::ReadFileResult; +using CacheVariable = cmCMakePresetsFile::CacheVariable; +using ConfigurePreset = cmCMakePresetsFile::ConfigurePreset; +using BuildPreset = cmCMakePresetsFile::BuildPreset; +using TestPreset = cmCMakePresetsFile::TestPreset; +using ArchToolsetStrategy = cmCMakePresetsFile::ArchToolsetStrategy; + +constexpr int MIN_VERSION = 1; +constexpr int MAX_VERSION = 3; + +struct CMakeVersion +{ + unsigned int Major = 0; + unsigned int Minor = 0; + unsigned int Patch = 0; +}; + +struct RootPresets +{ + CMakeVersion CMakeMinimumRequired; + std::vector ConfigurePresets; + std::vector BuildPresets; + std::vector TestPresets; +}; + +cmJSONHelper VendorHelper(ReadFileResult error) +{ + return [error](std::nullptr_t& /*out*/, + const Json::Value* value) -> ReadFileResult { + if (!value) { + return ReadFileResult::READ_OK; + } + + if (!value->isObject()) { + return error; + } + + return ReadFileResult::READ_OK; + }; +} + +auto const VersionIntHelper = cmJSONIntHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_VERSION); + +auto const VersionHelper = cmJSONRequiredHelper( + ReadFileResult::NO_VERSION, VersionIntHelper); + +auto const RootVersionHelper = + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_ROOT) + .Bind("version"_s, VersionHelper, false); + +auto const VariableStringHelper = cmJSONStringHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE); + +ReadFileResult VariableValueHelper(std::string& out, const Json::Value* value) +{ + if (!value) { + out.clear(); + return ReadFileResult::READ_OK; + } + + if (value->isBool()) { + out = value->asBool() ? "TRUE" : "FALSE"; + return ReadFileResult::READ_OK; + } + + return VariableStringHelper(out, value); +} + +auto const VariableObjectHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_VARIABLE, false) + .Bind("type"_s, &CacheVariable::Type, VariableStringHelper, false) + .Bind("value"_s, &CacheVariable::Value, VariableValueHelper); + +ReadFileResult VariableHelper(cm::optional& out, + const Json::Value* value) +{ + if (value->isBool()) { + out = CacheVariable{ + /*Type=*/"BOOL", + /*Value=*/value->asBool() ? "TRUE" : "FALSE", + }; + return ReadFileResult::READ_OK; + } + if (value->isString()) { + out = CacheVariable{ + /*Type=*/"", + /*Value=*/value->asString(), + }; + return ReadFileResult::READ_OK; + } + if (value->isObject()) { + out.emplace(); + return VariableObjectHelper(*out, value); + } + if (value->isNull()) { + out = cm::nullopt; + return ReadFileResult::READ_OK; + } + return ReadFileResult::INVALID_VARIABLE; +} + +auto const VariablesHelper = + cmJSONMapHelper, ReadFileResult>( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, VariableHelper); + +auto const PresetStringHelper = cmJSONStringHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET); + +ReadFileResult EnvironmentHelper(cm::optional& out, + const Json::Value* value) +{ + if (!value || value->isNull()) { + out = cm::nullopt; + return ReadFileResult::READ_OK; + } + if (value->isString()) { + out = value->asString(); + return ReadFileResult::READ_OK; + } + return ReadFileResult::INVALID_PRESET; +} + +auto const EnvironmentMapHelper = + cmJSONMapHelper, ReadFileResult>( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, + EnvironmentHelper); + +auto const PresetVectorStringHelper = + cmJSONVectorHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, + PresetStringHelper); + +ReadFileResult PresetInheritsHelper(std::vector& out, + const Json::Value* value) +{ + out.clear(); + if (!value) { + return ReadFileResult::READ_OK; + } + + if (value->isString()) { + out.push_back(value->asString()); + return ReadFileResult::READ_OK; + } + + return PresetVectorStringHelper(out, value); +} + +auto const PresetBoolHelper = cmJSONBoolHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET); + +auto const PresetOptionalBoolHelper = + cmJSONOptionalHelper(ReadFileResult::READ_OK, + PresetBoolHelper); + +auto const PresetIntHelper = cmJSONIntHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET); + +auto const PresetOptionalIntHelper = cmJSONOptionalHelper( + ReadFileResult::READ_OK, PresetIntHelper); + +auto const PresetVectorIntHelper = cmJSONVectorHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, PresetIntHelper); + +auto const PresetWarningsHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("dev"_s, &ConfigurePreset::WarnDev, PresetOptionalBoolHelper, false) + .Bind("deprecated"_s, &ConfigurePreset::WarnDeprecated, + PresetOptionalBoolHelper, false) + .Bind("uninitialized"_s, &ConfigurePreset::WarnUninitialized, + PresetOptionalBoolHelper, false) + .Bind("unusedCli"_s, &ConfigurePreset::WarnUnusedCli, + PresetOptionalBoolHelper, false) + .Bind("systemVars"_s, &ConfigurePreset::WarnSystemVars, + PresetOptionalBoolHelper, false); + +auto const PresetErrorsHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("dev"_s, &ConfigurePreset::ErrorDev, PresetOptionalBoolHelper, false) + .Bind("deprecated"_s, &ConfigurePreset::ErrorDeprecated, + PresetOptionalBoolHelper, false); + +auto const PresetDebugHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("output"_s, &ConfigurePreset::DebugOutput, PresetOptionalBoolHelper, + false) + .Bind("tryCompile"_s, &ConfigurePreset::DebugTryCompile, + PresetOptionalBoolHelper, false) + .Bind("find"_s, &ConfigurePreset::DebugFind, PresetOptionalBoolHelper, + false); + +ReadFileResult ArchToolsetStrategyHelper( + cm::optional& out, const Json::Value* value) +{ + if (!value) { + out = cm::nullopt; + return ReadFileResult::READ_OK; + } + + if (!value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "set") { + out = ArchToolsetStrategy::Set; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "external") { + out = ArchToolsetStrategy::External; + return ReadFileResult::READ_OK; + } + + return ReadFileResult::INVALID_PRESET; +} + +std::function +ArchToolsetHelper( + std::string ConfigurePreset::*valueField, + cm::optional ConfigurePreset::*strategyField) +{ + auto const objectHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("value", valueField, PresetStringHelper, false) + .Bind("strategy", strategyField, ArchToolsetStrategyHelper, false); + return [valueField, strategyField, objectHelper]( + ConfigurePreset& out, const Json::Value* value) -> ReadFileResult { + if (!value) { + (out.*valueField).clear(); + out.*strategyField = cm::nullopt; + return ReadFileResult::READ_OK; + } + + if (value->isString()) { + out.*valueField = value->asString(); + out.*strategyField = cm::nullopt; + return ReadFileResult::READ_OK; + } + + if (value->isObject()) { + return objectHelper(out, value); + } + + return ReadFileResult::INVALID_PRESET; + }; +} + +auto const ArchitectureHelper = ArchToolsetHelper( + &ConfigurePreset::Architecture, &ConfigurePreset::ArchitectureStrategy); +auto const ToolsetHelper = ArchToolsetHelper( + &ConfigurePreset::Toolset, &ConfigurePreset::ToolsetStrategy); + +auto const ConfigurePresetHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("name"_s, &ConfigurePreset::Name, PresetStringHelper) + .Bind("inherits"_s, &ConfigurePreset::Inherits, PresetInheritsHelper, + false) + .Bind("hidden"_s, &ConfigurePreset::Hidden, PresetBoolHelper, false) + .Bind("vendor"_s, nullptr, + VendorHelper(ReadFileResult::INVALID_PRESET), false) + .Bind("displayName"_s, &ConfigurePreset::DisplayName, PresetStringHelper, + false) + .Bind("description"_s, &ConfigurePreset::Description, PresetStringHelper, + false) + .Bind("generator"_s, &ConfigurePreset::Generator, PresetStringHelper, + false) + .Bind("architecture"_s, ArchitectureHelper, false) + .Bind("toolset"_s, ToolsetHelper, false) + .Bind("binaryDir"_s, &ConfigurePreset::BinaryDir, PresetStringHelper, + false) + .Bind("installDir"_s, &ConfigurePreset::InstallDir, PresetStringHelper, + false) + .Bind("cmakeExecutable"_s, nullptr, PresetStringHelper, false) + .Bind("cacheVariables"_s, &ConfigurePreset::CacheVariables, + VariablesHelper, false) + .Bind("environment"_s, &ConfigurePreset::Environment, EnvironmentMapHelper, + false) + .Bind("warnings"_s, PresetWarningsHelper, false) + .Bind("errors"_s, PresetErrorsHelper, false) + .Bind("debug"_s, PresetDebugHelper, false); + +auto const BuildPresetHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("name"_s, &BuildPreset::Name, PresetStringHelper) + .Bind("inherits"_s, &BuildPreset::Inherits, PresetInheritsHelper, false) + .Bind("hidden"_s, &BuildPreset::Hidden, PresetBoolHelper, false) + .Bind("vendor"_s, nullptr, + VendorHelper(ReadFileResult::INVALID_PRESET), false) + .Bind("displayName"_s, &BuildPreset::DisplayName, PresetStringHelper, + false) + .Bind("description"_s, &BuildPreset::Description, PresetStringHelper, + false) + .Bind("environment"_s, &BuildPreset::Environment, EnvironmentMapHelper, + false) + .Bind("configurePreset"_s, &BuildPreset::ConfigurePreset, + PresetStringHelper, false) + .Bind("inheritConfigureEnvironment"_s, + &BuildPreset::InheritConfigureEnvironment, PresetOptionalBoolHelper, + false) + .Bind("jobs"_s, &BuildPreset::Jobs, PresetOptionalIntHelper, false) + .Bind("targets"_s, &BuildPreset::Targets, PresetVectorStringHelper, false) + .Bind("configuration"_s, &BuildPreset::Configuration, PresetStringHelper, + false) + .Bind("cleanFirst"_s, &BuildPreset::CleanFirst, PresetOptionalBoolHelper, + false) + .Bind("verbose"_s, &BuildPreset::Verbose, PresetOptionalBoolHelper, false) + .Bind("nativeToolOptions"_s, &BuildPreset::NativeToolOptions, + PresetVectorStringHelper, false); + +ReadFileResult TestPresetOutputVerbosityHelper( + TestPreset::OutputOptions::VerbosityEnum& out, const Json::Value* value) +{ + if (!value) { + out = TestPreset::OutputOptions::VerbosityEnum::Default; + return ReadFileResult::READ_OK; + } + + if (!value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "default") { + out = TestPreset::OutputOptions::VerbosityEnum::Default; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "verbose") { + out = TestPreset::OutputOptions::VerbosityEnum::Verbose; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "extra") { + out = TestPreset::OutputOptions::VerbosityEnum::Extra; + return ReadFileResult::READ_OK; + } + + return ReadFileResult::INVALID_PRESET; +} + +auto const TestPresetOptionalOutputVerbosityHelper = + cmJSONOptionalHelper(ReadFileResult::READ_OK, + TestPresetOutputVerbosityHelper); + +auto const TestPresetOptionalOutputHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("shortProgress"_s, &TestPreset::OutputOptions::ShortProgress, + PresetOptionalBoolHelper, false) + .Bind("verbosity"_s, &TestPreset::OutputOptions::Verbosity, + TestPresetOptionalOutputVerbosityHelper, false) + .Bind("debug"_s, &TestPreset::OutputOptions::Debug, + PresetOptionalBoolHelper, false) + .Bind("outputOnFailure"_s, &TestPreset::OutputOptions::OutputOnFailure, + PresetOptionalBoolHelper, false) + .Bind("quiet"_s, &TestPreset::OutputOptions::Quiet, + PresetOptionalBoolHelper, false) + .Bind("outputLogFile"_s, &TestPreset::OutputOptions::OutputLogFile, + PresetStringHelper, false) + .Bind("labelSummary"_s, &TestPreset::OutputOptions::LabelSummary, + PresetOptionalBoolHelper, false) + .Bind("subprojectSummary"_s, + &TestPreset::OutputOptions::SubprojectSummary, + PresetOptionalBoolHelper, false) + .Bind("maxPassedTestOutputSize"_s, + &TestPreset::OutputOptions::MaxPassedTestOutputSize, + PresetOptionalIntHelper, false) + .Bind("maxFailedTestOutputSize"_s, + &TestPreset::OutputOptions::MaxFailedTestOutputSize, + PresetOptionalIntHelper, false) + .Bind("maxTestNameWidth"_s, &TestPreset::OutputOptions::MaxTestNameWidth, + PresetOptionalIntHelper, false)); + +auto const TestPresetOptionalFilterIncludeIndexObjectHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_PRESET) + .Bind("start"_s, &TestPreset::IncludeOptions::IndexOptions::Start, + PresetOptionalIntHelper, false) + .Bind("end"_s, &TestPreset::IncludeOptions::IndexOptions::End, + PresetOptionalIntHelper, false) + .Bind("stride"_s, &TestPreset::IncludeOptions::IndexOptions::Stride, + PresetOptionalIntHelper, false) + .Bind("specificTests"_s, + &TestPreset::IncludeOptions::IndexOptions::SpecificTests, + PresetVectorIntHelper, false)); + +ReadFileResult TestPresetOptionalFilterIncludeIndexHelper( + cm::optional& out, + const Json::Value* value) +{ + if (!value) { + out = cm::nullopt; + return ReadFileResult::READ_OK; + } + + if (value->isString()) { + out.emplace(); + out->IndexFile = value->asString(); + return ReadFileResult::READ_OK; + } + + if (value->isObject()) { + return TestPresetOptionalFilterIncludeIndexObjectHelper(out, value); + } + + return ReadFileResult::INVALID_PRESET; +} + +auto const TestPresetOptionalFilterIncludeHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) + .Bind("name"_s, &TestPreset::IncludeOptions::Name, PresetStringHelper, + false) + .Bind("label"_s, &TestPreset::IncludeOptions::Label, PresetStringHelper, + false) + .Bind("index"_s, &TestPreset::IncludeOptions::Index, + TestPresetOptionalFilterIncludeIndexHelper, false) + .Bind("useUnion"_s, &TestPreset::IncludeOptions::UseUnion, + PresetOptionalBoolHelper, false)); + +auto const TestPresetOptionalFilterExcludeFixturesHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_PRESET) + .Bind("any"_s, &TestPreset::ExcludeOptions::FixturesOptions::Any, + PresetStringHelper, false) + .Bind("setup"_s, &TestPreset::ExcludeOptions::FixturesOptions::Setup, + PresetStringHelper, false) + .Bind("cleanup"_s, &TestPreset::ExcludeOptions::FixturesOptions::Cleanup, + PresetStringHelper, false)); + +auto const TestPresetOptionalFilterExcludeHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) + .Bind("name"_s, &TestPreset::ExcludeOptions::Name, PresetStringHelper, + false) + .Bind("label"_s, &TestPreset::ExcludeOptions::Label, PresetStringHelper, + false) + .Bind("fixtures"_s, &TestPreset::ExcludeOptions::Fixtures, + TestPresetOptionalFilterExcludeFixturesHelper, false)); + +ReadFileResult TestPresetExecutionShowOnlyHelper( + TestPreset::ExecutionOptions::ShowOnlyEnum& out, const Json::Value* value) +{ + if (!value || !value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "human") { + out = TestPreset::ExecutionOptions::ShowOnlyEnum::Human; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "json-v1") { + out = TestPreset::ExecutionOptions::ShowOnlyEnum::JsonV1; + return ReadFileResult::READ_OK; + } + + return ReadFileResult::INVALID_PRESET; +} + +auto const TestPresetOptionalExecutionShowOnlyHelper = + cmJSONOptionalHelper(ReadFileResult::READ_OK, + TestPresetExecutionShowOnlyHelper); + +ReadFileResult TestPresetExecutionModeHelper( + TestPreset::ExecutionOptions::RepeatOptions::ModeEnum& out, + const Json::Value* value) +{ + if (!value) { + return ReadFileResult::READ_OK; + } + + if (!value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "until-fail") { + out = TestPreset::ExecutionOptions::RepeatOptions::ModeEnum::UntilFail; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "until-pass") { + out = TestPreset::ExecutionOptions::RepeatOptions::ModeEnum::UntilPass; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "after-timeout") { + out = TestPreset::ExecutionOptions::RepeatOptions::ModeEnum::AfterTimeout; + return ReadFileResult::READ_OK; + } + + return ReadFileResult::INVALID_PRESET; +} + +auto const TestPresetOptionalExecutionRepeatHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_PRESET) + .Bind("mode"_s, &TestPreset::ExecutionOptions::RepeatOptions::Mode, + TestPresetExecutionModeHelper, true) + .Bind("count"_s, &TestPreset::ExecutionOptions::RepeatOptions::Count, + PresetIntHelper, true)); + +ReadFileResult TestPresetExecutionNoTestsActionHelper( + TestPreset::ExecutionOptions::NoTestsActionEnum& out, + const Json::Value* value) +{ + if (!value) { + out = TestPreset::ExecutionOptions::NoTestsActionEnum::Default; + return ReadFileResult::READ_OK; + } + + if (!value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "default") { + out = TestPreset::ExecutionOptions::NoTestsActionEnum::Default; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "error") { + out = TestPreset::ExecutionOptions::NoTestsActionEnum::Error; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "ignore") { + out = TestPreset::ExecutionOptions::NoTestsActionEnum::Ignore; + return ReadFileResult::READ_OK; + } + + return ReadFileResult::INVALID_PRESET; +} + +auto const TestPresetOptionalExecutionNoTestsActionHelper = + cmJSONOptionalHelper(ReadFileResult::READ_OK, + TestPresetExecutionNoTestsActionHelper); + +auto const TestPresetExecutionHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) + .Bind("stopOnFailure"_s, &TestPreset::ExecutionOptions::StopOnFailure, + PresetOptionalBoolHelper, false) + .Bind("enableFailover"_s, &TestPreset::ExecutionOptions::EnableFailover, + PresetOptionalBoolHelper, false) + .Bind("jobs"_s, &TestPreset::ExecutionOptions::Jobs, + PresetOptionalIntHelper, false) + .Bind("resourceSpecFile"_s, + &TestPreset::ExecutionOptions::ResourceSpecFile, + PresetStringHelper, false) + .Bind("testLoad"_s, &TestPreset::ExecutionOptions::TestLoad, + PresetOptionalIntHelper, false) + .Bind("showOnly"_s, &TestPreset::ExecutionOptions::ShowOnly, + TestPresetOptionalExecutionShowOnlyHelper, false) + .Bind("repeat"_s, &TestPreset::ExecutionOptions::Repeat, + TestPresetOptionalExecutionRepeatHelper, false) + .Bind("interactiveDebugging"_s, + &TestPreset::ExecutionOptions::InteractiveDebugging, + PresetOptionalBoolHelper, false) + .Bind("scheduleRandom"_s, &TestPreset::ExecutionOptions::ScheduleRandom, + PresetOptionalBoolHelper, false) + .Bind("timeout"_s, &TestPreset::ExecutionOptions::Timeout, + PresetOptionalIntHelper, false) + .Bind("noTestsAction"_s, &TestPreset::ExecutionOptions::NoTestsAction, + TestPresetOptionalExecutionNoTestsActionHelper, false)); + +auto const TestPresetFilterHelper = + cmJSONOptionalHelper( + ReadFileResult::READ_OK, + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET) + .Bind("include"_s, &TestPreset::FilterOptions::Include, + TestPresetOptionalFilterIncludeHelper, false) + .Bind("exclude"_s, &TestPreset::FilterOptions::Exclude, + TestPresetOptionalFilterExcludeHelper, false)); + +auto const TestPresetHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("name"_s, &TestPreset::Name, PresetStringHelper) + .Bind("inherits"_s, &TestPreset::Inherits, PresetInheritsHelper, false) + .Bind("hidden"_s, &TestPreset::Hidden, PresetBoolHelper, false) + .Bind("vendor"_s, nullptr, + VendorHelper(ReadFileResult::INVALID_PRESET), false) + .Bind("displayName"_s, &TestPreset::DisplayName, PresetStringHelper, false) + .Bind("description"_s, &TestPreset::Description, PresetStringHelper, false) + .Bind("environment"_s, &TestPreset::Environment, EnvironmentMapHelper, + false) + .Bind("configurePreset"_s, &TestPreset::ConfigurePreset, + PresetStringHelper, false) + .Bind("inheritConfigureEnvironment"_s, + &TestPreset::InheritConfigureEnvironment, PresetOptionalBoolHelper, + false) + .Bind("configuration"_s, &TestPreset::Configuration, PresetStringHelper, + false) + .Bind("overwriteConfigurationFile"_s, + &TestPreset::OverwriteConfigurationFile, PresetVectorStringHelper, + false) + .Bind("output"_s, &TestPreset::Output, TestPresetOptionalOutputHelper, + false) + .Bind("filter"_s, &TestPreset::Filter, TestPresetFilterHelper, false) + .Bind("execution"_s, &TestPreset::Execution, TestPresetExecutionHelper, + false); + +auto const ConfigurePresetsHelper = + cmJSONVectorHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, + ConfigurePresetHelper); + +auto const BuildPresetsHelper = + cmJSONVectorHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, + BuildPresetHelper); + +auto const TestPresetsHelper = cmJSONVectorHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, TestPresetHelper); + +auto const CMakeVersionUIntHelper = cmJSONUIntHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_VERSION); + +auto const CMakeVersionHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_CMAKE_VERSION, false) + .Bind("major"_s, &CMakeVersion::Major, CMakeVersionUIntHelper, false) + .Bind("minor"_s, &CMakeVersion::Minor, CMakeVersionUIntHelper, false) + .Bind("patch"_s, &CMakeVersion::Patch, CMakeVersionUIntHelper, false); + +auto const RootPresetsHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_ROOT, false) + .Bind("version"_s, nullptr, VersionHelper) + .Bind("configurePresets"_s, &RootPresets::ConfigurePresets, + ConfigurePresetsHelper, false) + .Bind("buildPresets"_s, &RootPresets::BuildPresets, BuildPresetsHelper, + false) + .Bind("testPresets"_s, &RootPresets::TestPresets, TestPresetsHelper, false) + .Bind("cmakeMinimumRequired"_s, &RootPresets::CMakeMinimumRequired, + CMakeVersionHelper, false) + .Bind("vendor"_s, nullptr, + VendorHelper(ReadFileResult::INVALID_ROOT), false); +} + +cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( + const std::string& filename, bool user) +{ + cmsys::ifstream fin(filename.c_str()); + if (!fin) { + return ReadFileResult::FILE_NOT_FOUND; + } + // If there's a BOM, toss it. + cmsys::FStream::ReadBOM(fin); + + Json::Value root; + Json::CharReaderBuilder builder; + Json::CharReaderBuilder::strictMode(&builder.settings_); + if (!Json::parseFromStream(builder, fin, &root, nullptr)) { + return ReadFileResult::JSON_PARSE_ERROR; + } + + int v = 0; + auto result = RootVersionHelper(v, &root); + if (result != ReadFileResult::READ_OK) { + return result; + } + if (v < MIN_VERSION || v > MAX_VERSION) { + return ReadFileResult::UNRECOGNIZED_VERSION; + } + if (user) { + this->UserVersion = v; + } else { + this->Version = v; + } + + // Support for build and test presets added in version 2. + if (v < 2 && + (root.isMember("buildPresets") || root.isMember("testPresets"))) { + return ReadFileResult::BUILD_TEST_PRESETS_UNSUPPORTED; + } + + RootPresets presets; + if ((result = RootPresetsHelper(presets, &root)) != + ReadFileResult::READ_OK) { + return result; + } + + unsigned int currentMajor = cmVersion::GetMajorVersion(); + unsigned int currentMinor = cmVersion::GetMinorVersion(); + unsigned int currentPatch = cmVersion::GetPatchVersion(); + auto const& required = presets.CMakeMinimumRequired; + if (required.Major > currentMajor || + (required.Major == currentMajor && + (required.Minor > currentMinor || + (required.Minor == currentMinor && + (required.Patch > currentPatch))))) { + return ReadFileResult::UNRECOGNIZED_CMAKE_VERSION; + } + + for (auto& preset : presets.ConfigurePresets) { + preset.User = user; + if (preset.Name.empty()) { + return ReadFileResult::INVALID_PRESET; + } + + PresetPair presetPair; + presetPair.Unexpanded = preset; + presetPair.Expanded = cm::nullopt; + if (!this->ConfigurePresets + .emplace(std::make_pair(preset.Name, presetPair)) + .second) { + return ReadFileResult::DUPLICATE_PRESETS; + } + + // Support for installDir presets added in version 3. + if (v < 3 && !preset.InstallDir.empty()) { + return ReadFileResult::INSTALL_PREFIX_UNSUPPORTED; + } + + this->ConfigurePresetOrder.push_back(preset.Name); + } + + for (auto& preset : presets.BuildPresets) { + preset.User = user; + if (preset.Name.empty()) { + return ReadFileResult::INVALID_PRESET; + } + + PresetPair presetPair; + presetPair.Unexpanded = preset; + presetPair.Expanded = cm::nullopt; + if (!this->BuildPresets.emplace(preset.Name, presetPair).second) { + return ReadFileResult::DUPLICATE_PRESETS; + } + this->BuildPresetOrder.push_back(preset.Name); + } + + for (auto& preset : presets.TestPresets) { + preset.User = user; + if (preset.Name.empty()) { + return ReadFileResult::INVALID_PRESET; + } + + PresetPair presetPair; + presetPair.Unexpanded = preset; + presetPair.Expanded = cm::nullopt; + if (!this->TestPresets.emplace(preset.Name, presetPair).second) { + return ReadFileResult::DUPLICATE_PRESETS; + } + this->TestPresetOrder.push_back(preset.Name); + } + + return ReadFileResult::READ_OK; +} -- cgit v0.12 From ce6ea7c927b9f80f219a7783ce725bea4c24091f Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Fri, 19 Mar 2021 10:40:03 -0400 Subject: Refactor: Move some common code into separate file This code is going to be needed by both cmCMakePresetsFile and cmCMakePresetsFileReadJSON when the upcoming condition types are created. Move it into a header file. --- Source/CMakeLists.txt | 1 + Source/cmCMakePresetsFile.cxx | 20 +++----------------- Source/cmCMakePresetsFileInternal.h | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 Source/cmCMakePresetsFileInternal.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8b11a53..938745c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -198,6 +198,7 @@ set(SRCS cmCMakePath.cxx cmCMakePresetsFile.cxx cmCMakePresetsFile.h + cmCMakePresetsFileInternal.h cmCMakePresetsFileReadJSON.cxx cmCommandArgumentParserHelper.cxx cmCommonTargetGenerator.cxx diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index 1d95953..c0b0981 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -9,16 +9,10 @@ #include #include +#include "cmCMakePresetsFileInternal.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#define CHECK_OK(expr) \ - { \ - auto _result = expr; \ - if (_result != ReadFileResult::READ_OK) \ - return _result; \ - } - #define CHECK_EXPAND(out, field, expanders, version) \ { \ switch (ExpandMacros(field, expanders, version)) { \ @@ -44,6 +38,8 @@ using ReadFileResult = cmCMakePresetsFile::ReadFileResult; using ConfigurePreset = cmCMakePresetsFile::ConfigurePreset; using BuildPreset = cmCMakePresetsFile::BuildPreset; using TestPreset = cmCMakePresetsFile::TestPreset; +using ExpandMacroResult = cmCMakePresetsFileInternal::ExpandMacroResult; +using MacroExpander = cmCMakePresetsFileInternal::MacroExpander; void InheritString(std::string& child, const std::string& parent) { @@ -166,16 +162,6 @@ bool IsValidMacroNamespace(const std::string& str) [&str](const char* prefix) -> bool { return str == prefix; }); } -enum class ExpandMacroResult -{ - Ok, - Ignore, - Error, -}; - -using MacroExpander = std::function; - ExpandMacroResult VisitEnv(std::string& value, CycleStatus& status, const std::vector& macroExpanders, int version); diff --git a/Source/cmCMakePresetsFileInternal.h b/Source/cmCMakePresetsFileInternal.h new file mode 100644 index 0000000..f05b8ce --- /dev/null +++ b/Source/cmCMakePresetsFileInternal.h @@ -0,0 +1,22 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCMakePresetsFile.h" + +#define CHECK_OK(expr) \ + { \ + auto _result = expr; \ + if (_result != ReadFileResult::READ_OK) \ + return _result; \ + } + +namespace cmCMakePresetsFileInternal { +enum class ExpandMacroResult +{ + Ok, + Ignore, + Error, +}; + +using MacroExpander = std::function; +} -- cgit v0.12 From 26cf661b6495610aab1dee176666b9b6dc8fd77b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 18 Mar 2021 09:24:52 -0400 Subject: Help/guide: use GNUInstallDirs in importing-exporting example This allows the example to also show how to work on systems with different libdir settings (e.g., Debian multiarch or Red Hat multilib) rather than a regular `lib` directory. --- .../MathFunctions/CMakeLists.txt | 21 ++++++++++++--------- .../MathFunctionsComponents/Addition/CMakeLists.txt | 14 +++++++------- .../MathFunctionsComponents/CMakeLists.txt | 7 +++++-- .../SquareRoot/CMakeLists.txt | 14 +++++++------- Help/guide/importing-exporting/index.rst | 4 ++++ 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt index 9a9e40e..d277b54 100644 --- a/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt +++ b/Help/guide/importing-exporting/MathFunctions/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.15) project(MathFunctions) +# make cache variables for install destinations +include(GNUInstallDirs) + # specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -12,26 +15,26 @@ add_library(MathFunctions STATIC MathFunctions.cxx) target_include_directories(MathFunctions PUBLIC "$" - "$" + "$" ) # install the target and create export-set install(TARGETS MathFunctions EXPORT MathFunctionsTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # install header file -install(FILES MathFunctions.h DESTINATION include) +install(FILES MathFunctions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # generate and install export file install(EXPORT MathFunctionsTargets FILE MathFunctionsTargets.cmake NAMESPACE MathFunctions:: - DESTINATION lib/cmake/MathFunctions + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions ) # include CMakePackageConfigHelpers macro @@ -58,14 +61,14 @@ write_basic_package_version_file( # create config file configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" - INSTALL_DESTINATION lib/cmake/MathFunctions + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions ) # install config files install(FILES "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" - DESTINATION lib/cmake/MathFunctions + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions ) # generate the export targets for the build tree diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt index 17ad952..9de935e 100644 --- a/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt +++ b/Help/guide/importing-exporting/MathFunctionsComponents/Addition/CMakeLists.txt @@ -7,24 +7,24 @@ add_library(MathFunctions::Addition ALIAS Addition) target_include_directories(Addition PUBLIC "$" - $ + $ ) # install the target and create export-set install(TARGETS Addition EXPORT AdditionTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # install header file -install(FILES Addition.h DESTINATION include) +install(FILES Addition.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # generate and install export file install(EXPORT AdditionTargets FILE MathFunctionsAdditionTargets.cmake NAMESPACE MathFunctions:: - DESTINATION lib/cmake/MathFunctions + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions ) diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt index fd95e28..90ee89f 100644 --- a/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt +++ b/Help/guide/importing-exporting/MathFunctionsComponents/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.15) project(MathFunctionsComponents) +# make cache variables for install destinations +include(GNUInstallDirs) + # specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -24,7 +27,7 @@ write_basic_package_version_file( # create config file configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" - INSTALL_DESTINATION lib/cmake/MathFunctions + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions NO_CHECK_REQUIRED_COMPONENTS_MACRO ) @@ -32,5 +35,5 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in install(FILES "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake" - DESTINATION lib/cmake/MathFunctions + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions ) diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt index be5ae65..517c5e2 100644 --- a/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt +++ b/Help/guide/importing-exporting/MathFunctionsComponents/SquareRoot/CMakeLists.txt @@ -7,24 +7,24 @@ add_library(MathFunctions::SquareRoot ALIAS SquareRoot) target_include_directories(SquareRoot PUBLIC "$" - "$" + "$" ) # install the target and create export-set install(TARGETS SquareRoot EXPORT SquareRootTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) # install header file -install(FILES SquareRoot.h DESTINATION include) +install(FILES SquareRoot.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) # generate and install export file install(EXPORT SquareRootTargets FILE MathFunctionsSquareRootTargets.cmake NAMESPACE MathFunctions:: - DESTINATION lib/cmake/MathFunctions + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MathFunctions ) diff --git a/Help/guide/importing-exporting/index.rst b/Help/guide/importing-exporting/index.rst index 2e6e06d..3e60250 100644 --- a/Help/guide/importing-exporting/index.rst +++ b/Help/guide/importing-exporting/index.rst @@ -202,6 +202,10 @@ project. Start by specifying the :command:`cmake_minimum_required` version and :language: cmake :end-before: # create library +The :module:`GNUInstallDirs` module is included in order to provide the +project with the flexibility to install into different platform layouts by +making the directories available as cache variables. + Create a library called ``MathFunctions`` with the :command:`add_library` command: -- cgit v0.12 From e2aa44ba049e1a4f2f44c042cf34231c5bb073f0 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 18 Mar 2021 10:36:32 -0400 Subject: Tests: set CMAKE_PREFIX_PATH to the installation prefix As it is documented to be. --- Tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e532ace..d6a20bc 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1697,7 +1697,7 @@ if(BUILD_TESTING) ${build_generator_args} --build-project ${import_name} --build-options - "-DCMAKE_PREFIX_PATH:PATH=${install_dir}/lib/cmake") + "-DCMAKE_PREFIX_PATH:PATH=${install_dir}") set_tests_properties(${import_test_name} PROPERTIES DEPENDS ${export_test_name}) list(APPEND TEST_BUILD_DIRS "${import_build_dir}") endfunction() -- cgit v0.12 From 9b4390e76be7e46f2031563642f0a1cae5dbf4e8 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 20 Mar 2021 00:01:15 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 88c1631..530c2ca 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210319) +set(CMake_VERSION_PATCH 20210320) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 8f0cbaf2e03d3809f55ad674dbe5543636c0ebc6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 21 Mar 2021 00:03:25 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 530c2ca..a11fd8c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210320) +set(CMake_VERSION_PATCH 20210321) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 6d4cbf7416f8ab4d001ca08ca4e108615ea5dfb1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 22 Mar 2021 00:01:18 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a11fd8c..17f26a8 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210321) +set(CMake_VERSION_PATCH 20210322) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 7c4c4f1406f1b4a3d84248e87ce1786ee7a5d0f5 Mon Sep 17 00:00:00 2001 From: Andrew Gilewsky Date: Sun, 21 Mar 2021 18:10:57 +0300 Subject: Treat '.ixx' and '.cppm' files as C++ sources These extensions are used by convention for C++ modules and interface units with MSVC. --- Help/release/dev/cxx-module-extensions.rst | 4 ++++ Modules/CMakeCXXCompiler.cmake.in | 2 +- Source/cmMakefile.cxx | 2 +- Source/cmSourceFile.h | 2 +- Source/cmake.cxx | 6 +++--- 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/cxx-module-extensions.rst diff --git a/Help/release/dev/cxx-module-extensions.rst b/Help/release/dev/cxx-module-extensions.rst new file mode 100644 index 0000000..b9d0a8a --- /dev/null +++ b/Help/release/dev/cxx-module-extensions.rst @@ -0,0 +1,4 @@ +cxx-module-extensions +--------------------- + +* Source file extensions ``.ixx`` and ``.cppm`` are now treated as C++. diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 45acfe7..d0ce77a 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -44,7 +44,7 @@ if(CMAKE_COMPILER_IS_MINGW) set(MINGW 1) endif() set(CMAKE_CXX_COMPILER_ID_RUN 1) -set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP) +set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;mpp;CPP;ixx;cppm) set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) foreach (lang C OBJC OBJCXX) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e156625..40a67a3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1222,7 +1222,7 @@ void cmMakefile::AddCustomCommandOldStyle( // Each output must get its own copy of this rule. cmsys::RegularExpression sourceFiles( - "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|mpp|cu|m|mm|" + "\\.(C|M|c|c\\+\\+|cc|cpp|cxx|mpp|ixx|cppm|cu|m|mm|" "rc|def|r|odl|idl|hpj|bat|h|h\\+\\+|" "hm|hpp|hxx|in|txx|inl)$"); diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 76a5ded..32ed687 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -175,7 +175,7 @@ private: #define CM_HEADER_REGEX "\\.(h|hh|h\\+\\+|hm|hpp|hxx|in|txx|inl)$" #define CM_SOURCE_REGEX \ - "\\.(C|F|M|c|c\\+\\+|cc|cpp|mpp|cxx|cu|f|f90|for|fpp|ftn|m|mm|" \ + "\\.(C|F|M|c|c\\+\\+|cc|cpp|mpp|cxx|ixx|cppm|cu|f|f90|for|fpp|ftn|m|mm|" \ "rc|def|r|odl|idl|hpj|bat)$" #define CM_PCH_REGEX "cmake_pch(_[^.]+)?\\.(h|hxx)$" diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b12eeee..55a7feb 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -209,9 +209,9 @@ cmake::cmake(Role role, cmState::Mode mode) }; // The "c" extension MUST precede the "C" extension. - setupExts( - this->CLikeSourceFileExtensions, - { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "mpp", "m", "M", "mm" }); + setupExts(this->CLikeSourceFileExtensions, + { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "mpp", "m", "M", + "mm", "ixx", "cppm" }); setupExts(this->HeaderFileExtensions, { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" }); setupExts(this->CudaFileExtensions, { "cu" }); -- cgit v0.12 From 8dd8d6366576c09a44dc19d6609209ff74cd0dde Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 22 Mar 2021 13:26:00 -0400 Subject: Tests: Add RunCMake hook to describe test variants --- Tests/RunCMake/RunCMake.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 5e2f647..3ea4ae5 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -193,7 +193,7 @@ function(run_cmake test) if(msg) string(REGEX REPLACE "\n" "\n actual-out> " actual_out " actual-out> ${actual_stdout}") string(REGEX REPLACE "\n" "\n actual-err> " actual_err " actual-err> ${actual_stderr}") - message(SEND_ERROR "${test} - FAILED:\n" + message(SEND_ERROR "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - FAILED:\n" "${msg}" "${expect_out}" "Actual stdout:\n${actual_out}\n" @@ -201,7 +201,7 @@ function(run_cmake test) "Actual stderr:\n${actual_err}\n" ) else() - message(STATUS "${test} - PASSED") + message(STATUS "${test}${RunCMake_TEST_VARIANT_DESCRIPTION} - PASSED") endif() endfunction() -- cgit v0.12 From 608ef8a6fcbdd3d1a8419ff774109b8f9e5ebafb Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 4 Mar 2021 16:47:49 -0500 Subject: VS: Add a mostly-undocumented hook to load custom JSON flag tables The names and formats of our VS flag tables are internal implementation details. However, some institutions need to maintain support for non-public VS platforms and toolsets. Provide a hook that their projects can use to load custom flag table files. This helps avoid distributing a custom CMake package within such institutions. Document the hook itself, but explicitly specify that the files the hook loads are not considered a stable interface. --- Help/variable/CMAKE_GENERATOR_TOOLSET.rst | 24 +++++++++++++++ Source/cmGlobalVisualStudio10Generator.cxx | 36 ++++++++++++++++++++++ Source/cmGlobalVisualStudio10Generator.h | 2 ++ .../BadToolsetCustomFlagTableDir-result.txt | 1 + .../BadToolsetCustomFlagTableDir-stderr.txt | 11 +++++++ .../BadToolsetCustomFlagTableDir.cmake | 1 + Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake | 25 +++++++++++++++ .../TestToolsetCustomFlagTableDir-check.cmake | 24 +++++++++++++++ .../TestToolsetCustomFlagTableDir.cmake | 3 ++ .../RunCMake/GeneratorToolset/VsNormal-stdout.txt | 2 ++ Tests/RunCMake/GeneratorToolset/VsNormal.cmake | 6 ++++ Tests/RunCMake/GeneratorToolset/main.c | 4 +++ 12 files changed, 139 insertions(+) create mode 100644 Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-result.txt create mode 100644 Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-stderr.txt create mode 100644 Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir.cmake create mode 100644 Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir-check.cmake create mode 100644 Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir.cmake create mode 100644 Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt create mode 100644 Tests/RunCMake/GeneratorToolset/VsNormal.cmake create mode 100644 Tests/RunCMake/GeneratorToolset/main.c diff --git a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst index 53ad2f3..45f2d32 100644 --- a/Help/variable/CMAKE_GENERATOR_TOOLSET.rst +++ b/Help/variable/CMAKE_GENERATOR_TOOLSET.rst @@ -63,3 +63,27 @@ Supported pairs are: Specify an alternative ``VCTargetsPath`` value for Visual Studio project files. This allows use of VS platform extension configuration files (``.props`` and ``.targets``) that are not installed with VS. + +Visual Studio Toolset Customization +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +**These are unstable interfaces with no compatibility guarantees** +because they hook into undocumented internal CMake implementation details. +Institutions may use these to internally maintain support for non-public +Visual Studio platforms and toolsets, but must accept responsibility to +make updates as changes are made to CMake. + +Additional ``key=value`` pairs are available: + +``customFlagTableDir=`` + .. versionadded:: 3.21 + + Specify the absolute path to a directory from which to load custom + flag tables stored as JSON documents with file names of the form + ``__.json`` or ``_.json``, + where ```` is the :variable:`CMAKE_VS_PLATFORM_NAME`, + ```` is the :variable:`CMAKE_VS_PLATFORM_TOOLSET`, + and ```` is the tool for which the flag table is meant. + **This naming pattern is an internal CMake implementation detail.** + The ```` names are undocumented. The format of the ``.json`` + flag table files is undocumented. diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index d33c763..93fbe37 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -231,6 +231,23 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( return false; } + if (!this->CustomFlagTableDir.empty() && + !(cmSystemTools::FileIsFullPath(this->CustomFlagTableDir) && + cmSystemTools::FileIsDirectory(this->CustomFlagTableDir))) { + std::ostringstream e; + /* clang-format off */ + e << + "Generator\n" + " " << this->GetName() << "\n" + "given toolset\n" + " customFlagTableDir=" << this->CustomFlagTableDir << "\n" + "that is not an absolute path to an existing directory."; + /* clang-format on */ + mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + if (cmHasLiteralPrefix(this->GetPlatformToolsetString(), "v140")) { // The GenerateDebugInformation link setting for the v140 toolset // in VS 2015 was originally an enum with "No" and "Debug" values, @@ -486,6 +503,11 @@ bool cmGlobalVisualStudio10Generator::ProcessGeneratorToolsetField( } return true; } + if (key == "customFlagTableDir") { + this->CustomFlagTableDir = value; + cmSystemTools::ConvertToUnixSlashes(this->CustomFlagTableDir); + return true; + } if (key == "version") { this->GeneratorToolsetVersion = value; return true; @@ -1375,6 +1397,20 @@ static cmIDEFlagTable const* cmLoadFlagTableJson( cm::optional cmGlobalVisualStudio10Generator::FindFlagTable( cm::string_view toolsetName, cm::string_view table) const { + if (!this->CustomFlagTableDir.empty()) { + std::string customFlagTableFile = + cmStrCat(this->CustomFlagTableDir, '/', this->GetPlatformName(), '_', + toolsetName, '_', table, ".json"); + if (cmSystemTools::FileExists(customFlagTableFile)) { + return customFlagTableFile; + } + customFlagTableFile = + cmStrCat(this->CustomFlagTableDir, '/', this->GetPlatformName(), '_', + table, ".json"); + if (cmSystemTools::FileExists(customFlagTableFile)) { + return customFlagTableFile; + } + } std::string fullPath = cmStrCat(cmSystemTools::GetCMakeRoot(), "/Templates/MSBuild/FlagTables/", toolsetName, '_', table, ".json"); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index e221d4c..2596720 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -262,6 +262,8 @@ private: cm::optional FindFlagTable(cm::string_view toolsetName, cm::string_view table) const; + std::string CustomFlagTableDir; + std::string CustomVCTargetsPath; std::string VCTargetsPath; bool FindVCTargetsPath(cmMakefile* mf); diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-result.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-stderr.txt b/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-stderr.txt new file mode 100644 index 0000000..d8b6c5e --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at CMakeLists.txt:[0-9]+ \(project\): + Generator + + Visual Studio [^ +]* + + given toolset + + customFlagTableDir=does_not_exist + + that is not an absolute path to an existing directory.$ diff --git a/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir.cmake b/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir.cmake new file mode 100644 index 0000000..2fc38e5 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/BadToolsetCustomFlagTableDir.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR "This should not be reached!") diff --git a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake index 3aa791d..faed8f7 100644 --- a/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorToolset/RunCMakeTest.cmake @@ -1,5 +1,11 @@ include(RunCMake) +if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") + run_cmake(VsNormal) + include("${RunCMake_BINARY_DIR}/VsNormal-build/defaults.cmake" OPTIONAL) + message(STATUS "VsNormal: platform='${VsNormal_Platform}' toolset='${VsNormal_Toolset}'") +endif() + set(RunCMake_GENERATOR_TOOLSET "") run_cmake(NoToolset) @@ -18,6 +24,25 @@ if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[012456]") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset/CUDAVisualStudioIntegration") run_cmake(TestToolsetCudaPathOnlyOldLayout) file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/CudaStandaloneToolset") + if (VsNormal_Platform MATCHES "^(x64|Win32)$" AND + EXISTS "${CMAKE_ROOT}/Templates/MSBuild/FlagTables/${VsNormal_Toolset}_CL.json") + set(flagTableDir "${RunCMake_BINARY_DIR}/FlagTables") + file(READ "${CMAKE_ROOT}/Templates/MSBuild/FlagTables/${VsNormal_Toolset}_CL.json" flagTableContent) + string(REPLACE [["WX-"]] [["TESTWX-"]] flagTableContent "${flagTableContent}") + file(REMOVE_RECURSE "${flagTableDir}") + file(WRITE "${flagTableDir}/${VsNormal_Platform}_${VsNormal_Toolset}_CL.json" "${flagTableContent}") + set(RunCMake_GENERATOR_TOOLSET "${VsNormal_Toolset},customFlagTableDir=${flagTableDir}") + set(RunCMake_TEST_VARIANT_DESCRIPTION ":${VsNormal_Platform}_${VsNormal_Toolset}_CL.json") + run_cmake(TestToolsetCustomFlagTableDir) + file(REMOVE_RECURSE "${flagTableDir}") + file(WRITE "${flagTableDir}/${VsNormal_Platform}_CL.json" "${flagTableContent}") + set(RunCMake_GENERATOR_TOOLSET "${VsNormal_Toolset},customFlagTableDir=${flagTableDir}") + set(RunCMake_TEST_VARIANT_DESCRIPTION ":${VsNormal_Platform}_CL.json") + run_cmake(TestToolsetCustomFlagTableDir) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_GENERATOR_TOOLSET "${VsNormal_Toolset},customFlagTableDir=does_not_exist") + run_cmake(BadToolsetCustomFlagTableDir) + endif() if("${RunCMake_GENERATOR}" MATCHES "Visual Studio 1[2456]") set(RunCMake_GENERATOR_TOOLSET "Test Toolset,host=x64") run_cmake(TestToolsetHostArchBoth) diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir-check.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir-check.cmake new file mode 100644 index 0000000..79752b1 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir-check.cmake @@ -0,0 +1,24 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/main.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file\n ${vcProjectFile}\ndoes not exist.") + return() +endif() + +set(TreatWarningAsError_FOUND FALSE) +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *([^<>]*)$") + set(TreatWarningAsError_FOUND TRUE) + set(expectedValue "false") + set(actualValue "${CMAKE_MATCH_1}") + if(NOT (${actualValue} STREQUAL ${expectedValue})) + set(RunCMake_TEST_FAILED "TreatWarningAsError \"${actualValue}\" differs from expected value \"${expectedValue}\".") + return() + endif() + endif() +endforeach() + +if(NOT TreatWarningAsError_FOUND) + set(RunCMake_TEST_FAILED "Property TreatWarningAsError not found in project file:\n ${vcProjectFile}.") + return() +endif() diff --git a/Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir.cmake b/Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir.cmake new file mode 100644 index 0000000..91c6b44 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/TestToolsetCustomFlagTableDir.cmake @@ -0,0 +1,3 @@ +enable_language(C) +string(APPEND CMAKE_C_FLAGS " -TESTWX-") +add_executable(main main.c) diff --git a/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt b/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt new file mode 100644 index 0000000..25fa3bf --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt @@ -0,0 +1,2 @@ +-- CMAKE_VS_PLATFORM_NAME='[^']+' +-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+' diff --git a/Tests/RunCMake/GeneratorToolset/VsNormal.cmake b/Tests/RunCMake/GeneratorToolset/VsNormal.cmake new file mode 100644 index 0000000..e891708 --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/VsNormal.cmake @@ -0,0 +1,6 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/defaults.cmake" "# VS Defaults +set(VsNormal_Platform [[${CMAKE_VS_PLATFORM_NAME}]]) +set(VsNormal_Toolset [[${CMAKE_VS_PLATFORM_TOOLSET}]]) +") +message(STATUS "CMAKE_VS_PLATFORM_NAME='${CMAKE_VS_PLATFORM_NAME}'") +message(STATUS "CMAKE_VS_PLATFORM_TOOLSET='${CMAKE_VS_PLATFORM_TOOLSET}'") diff --git a/Tests/RunCMake/GeneratorToolset/main.c b/Tests/RunCMake/GeneratorToolset/main.c new file mode 100644 index 0000000..8488f4e --- /dev/null +++ b/Tests/RunCMake/GeneratorToolset/main.c @@ -0,0 +1,4 @@ +int main(void) +{ + return 0; +} -- cgit v0.12 From 8bc5c8961e552a15091b7f4d2c205ce90b8f764f Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 10 Mar 2021 14:59:14 -0500 Subject: CMakePresets.json: Add the ability to conditionally disable presets --- Help/manual/cmake-presets.7.rst | 96 ++++++ Help/manual/presets/example.json | 13 +- Help/manual/presets/schema.json | 356 ++++++++++++++++++++- Help/release/dev/cmake-presets-condition.rst | 4 + Source/QtDialog/QCMake.cxx | 2 +- Source/cmCMakePresetsFile.cxx | 109 ++++++- Source/cmCMakePresetsFile.h | 10 + Source/cmCMakePresetsFileInternal.h | 80 +++++ Source/cmCMakePresetsFileReadJSON.cxx | 205 +++++++++++- Source/cmCTest.cxx | 7 + Source/cmJSONHelpers.h | 2 +- Source/cmake.cxx | 13 + .../CMakePresets/ConditionFuture-result.txt | 1 + .../CMakePresets/ConditionFuture-stderr.txt | 2 + .../RunCMake/CMakePresets/ConditionFuture.json.in | 11 + Tests/RunCMake/CMakePresets/Conditions.json.in | 349 ++++++++++++++++++++ .../CMakePresets/ListConditions-stdout.txt | 22 ++ Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 8 + Tests/RunCMake/CMakePresets/SimpleFalse-result.txt | 1 + Tests/RunCMake/CMakePresets/SimpleFalse-stderr.txt | 1 + Tests/RunCMake/CMakePresets/SimpleTrue.cmake | 0 .../CMakePresets/SubConditionNull-result.txt | 1 + .../CMakePresets/SubConditionNull-stderr.txt | 2 + .../RunCMake/CMakePresets/SubConditionNull.json.in | 14 + .../Condition-build-disabled-result.txt | 1 + .../Condition-build-disabled-stderr.txt | 2 + Tests/RunCMake/CMakePresetsBuild/Condition.cmake | 0 Tests/RunCMake/CMakePresetsBuild/Condition.json.in | 22 ++ ...onditionFuture-build-conditionFuture-result.txt | 1 + ...onditionFuture-build-conditionFuture-stderr.txt | 2 + .../CMakePresetsBuild/ConditionFuture.json.in | 17 + .../ListPresets-build-x-stdout.txt | 3 +- .../RunCMake/CMakePresetsBuild/ListPresets.json.in | 12 +- .../RunCMake/CMakePresetsBuild/RunCMakeTest.cmake | 2 + Tests/RunCMake/CMakePresetsTest/Condition.json.in | 22 ++ .../ConditionFuture-test-x-result.txt | 1 + .../ConditionFuture-test-x-stderr.txt | 2 + .../CMakePresetsTest/ConditionFuture.json.in | 17 + .../ConditionListPresets-test-x-stdout.txt | 3 + .../ConditionRunTests-test-disabled-result.txt | 1 + .../ConditionRunTests-test-disabled-stderr.txt | 2 + .../CMakePresetsTest/ConditionRunTests.cmake | 2 + Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake | 7 + Utilities/IWYU/mapping.imp | 1 + 44 files changed, 1410 insertions(+), 19 deletions(-) create mode 100644 Help/release/dev/cmake-presets-condition.rst create mode 100644 Tests/RunCMake/CMakePresets/ConditionFuture-result.txt create mode 100644 Tests/RunCMake/CMakePresets/ConditionFuture-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/ConditionFuture.json.in create mode 100644 Tests/RunCMake/CMakePresets/Conditions.json.in create mode 100644 Tests/RunCMake/CMakePresets/ListConditions-stdout.txt create mode 100644 Tests/RunCMake/CMakePresets/SimpleFalse-result.txt create mode 100644 Tests/RunCMake/CMakePresets/SimpleFalse-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/SimpleTrue.cmake create mode 100644 Tests/RunCMake/CMakePresets/SubConditionNull-result.txt create mode 100644 Tests/RunCMake/CMakePresets/SubConditionNull-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/SubConditionNull.json.in create mode 100644 Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-result.txt create mode 100644 Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-stderr.txt create mode 100644 Tests/RunCMake/CMakePresetsBuild/Condition.cmake create mode 100644 Tests/RunCMake/CMakePresetsBuild/Condition.json.in create mode 100644 Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-result.txt create mode 100644 Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-stderr.txt create mode 100644 Tests/RunCMake/CMakePresetsBuild/ConditionFuture.json.in create mode 100644 Tests/RunCMake/CMakePresetsTest/Condition.json.in create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-result.txt create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-stderr.txt create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionFuture.json.in create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionListPresets-test-x-stdout.txt create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-result.txt create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-stderr.txt create mode 100644 Tests/RunCMake/CMakePresetsTest/ConditionRunTests.cmake diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 5273236..cc72603 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -119,6 +119,11 @@ that may contain the following fields: This field can also be a string, which is equivalent to an array containing one string. +``condition`` + + An optional `Condition`_ object. This is allowed in preset files specifying + version ``3`` or above. + ``vendor`` An optional map containing vendor-specific information. CMake does not @@ -345,6 +350,11 @@ that may contain the following fields: This field can also be a string, which is equivalent to an array containing one string. +``condition`` + + An optional `Condition`_ object. This is allowed in preset files specifying + version ``3`` or above. + ``vendor`` An optional map containing vendor-specific information. CMake does not @@ -464,6 +474,11 @@ that may contain the following fields: This field can also be a string, which is equivalent to an array containing one string. +``condition`` + + An optional `Condition`_ object. This is allowed in preset files specifying + version ``3`` or above. + ``vendor`` An optional map containing vendor-specific information. CMake does not @@ -789,6 +804,87 @@ that may contain the following fields: Equivalent to passing ``--no-tests=ignore`` on the command line. +Condition +^^^^^^^^^ + +The ``condition`` field of a preset, allowed in preset files specifying version +``3`` or above, is used to determine whether or not the preset is enabled. For +example, this can be used to disable a preset on platforms other than Windows. +``condition`` may be either a boolean, ``null``, or an object. If it is a +boolean, the boolean indicates whether the preset is enabled or disabled. If it +is ``null``, the preset is enabled, but the ``null`` condition is not inherited +by any presets that may inherit from the preset. Sub-conditions (for example in +a ``not``, ``anyOf``, or ``allOf`` condition) may not be ``null``. If it is an +object, it has the following fields: + +``type`` + + A required string with one of the following values: + + ``"const"`` + + Indicates that the condition is constant. This is equivalent to using a + boolean in place of the object. The condition object will have the + following additional fields: + + ``value`` + + A required boolean which provides a constant value for the condition's + evaluation. + + ``"equals"`` + + ``"notEquals"`` + + Indicates that the condition compares two strings to see if they are equal + (or not equal). The condition object will have the following additional + fields: + + ``lhs`` + + First string to compare. This field supports macro expansion. + + ``rhs`` + + Second string to compare. This field supports macro expansion. + + ``"inList"`` + + ``"notInList"`` + + Indicates that the condition searches for a string in a list of strings. + The condition object will have the following additional fields: + + ``string`` + + A required string to search for. This field supports macro expansion. + + ``list`` + + A required list of strings to search. This field supports macro + expansion, and uses short-circuit evaluation. + + ``"anyOf"`` + + ``"allOf"`` + + Indicates that the condition is an aggregation of zero or more nested + conditions. The condition object will have the following additional fields: + + ``conditions`` + + A required array of condition objects. These conditions use short-circuit + evaluation. + + ``"not"`` + + Indicates that the condition is an inversion of another condition. The + condition object will have the following additional fields: + + ``condition`` + + A required condition object. + Macro Expansion ^^^^^^^^^^^^^^^ diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json index dfc2910..346f342 100644 --- a/Help/manual/presets/example.json +++ b/Help/manual/presets/example.json @@ -1,5 +1,5 @@ { - "version": 2, + "version": 3, "cmakeMinimumRequired": { "major": 3, "minor": 20, @@ -35,6 +35,17 @@ "displayName": "Ninja Multi-Config", "description": "Default build using Ninja Multi-Config generator", "generator": "Ninja Multi-Config" + }, + { + "name": "windows-only", + "inherits": "default", + "displayName": "Windows-only configuration", + "description": "This build is only available on Windows", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + } } ], "buildPresets": [ diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index a5025bb..dbcead5 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -24,8 +24,8 @@ "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"}, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV1"}, - "buildPresets": { "$ref": "#/definitions/buildPresets"}, - "testPresets": { "$ref": "#/definitions/testPresets"} + "buildPresets": { "$ref": "#/definitions/buildPresetsV2"}, + "testPresets": { "$ref": "#/definitions/testPresetsV2"} }, "additionalProperties": false }, @@ -38,8 +38,8 @@ "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"}, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV3"}, - "buildPresets": { "$ref": "#/definitions/buildPresets"}, - "testPresets": { "$ref": "#/definitions/testPresets"} + "buildPresets": { "$ref": "#/definitions/buildPresetsV3"}, + "testPresets": { "$ref": "#/definitions/testPresetsV3"} }, "additionalProperties": false } @@ -82,7 +82,8 @@ "installDir": { "type": "string", "description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, it must be inherited from the inherits preset (unless this preset is hidden)." - } + }, + "condition": { "$ref": "#/definitions/topCondition" } } } }, @@ -358,7 +359,8 @@ "environment": {}, "warnings": {}, "errors": {}, - "debug": {} + "debug": {}, + "condition": {} }, "required": [ "name" @@ -397,7 +399,17 @@ "additionalProperties": false } }, - "buildPresets": { + "buildPresetsItemsV3": { + "type": "array", + "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.", + "items": { + "type": "object", + "properties": { + "condition": { "$ref": "#/definitions/topCondition" } + } + } + }, + "buildPresetsItemsV2": { "type": "array", "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.", "items": { @@ -515,11 +527,84 @@ }, "required": [ "name" + ] + } + }, + "buildPresetsV3": { + "type": "array", + "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.", + "allOf": [ + { "$ref": "#/definitions/buildPresetsItemsV3" }, + { "$ref": "#/definitions/buildPresetsItemsV2" } + ], + "items": { + "type": "object", + "properties": { + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "jobs": {}, + "targets": {}, + "configuration": {}, + "cleanFirst": {}, + "verbose": {}, + "nativeToolOptions": {}, + "condition": {} + }, + "required": [ + "name" ], "additionalProperties": false } }, - "testPresets": { + "buildPresetsV2": { + "type": "array", + "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 2 and higher.", + "allOf": [ + { "$ref": "#/definitions/buildPresetsItemsV2" } + ], + "items": { + "type": "object", + "properties": { + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "jobs": {}, + "targets": {}, + "configuration": {}, + "cleanFirst": {}, + "verbose": {}, + "nativeToolOptions": {} + }, + "required": [ + "name" + ], + "additionalProperties": false + } + }, + "testPresetsItemsV3": { + "type": "array", + "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.", + "items": { + "type": "object", + "properties": { + "condition": { "$ref": "#/definitions/topCondition" } + } + } + }, + "testPresetsItemsV2": { "type": "array", "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.", "items": { @@ -831,9 +916,264 @@ }, "required": [ "name" + ] + } + }, + "testPresetsV3": { + "type": "array", + "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.", + "allOf": [ + { "$ref": "#/definitions/testPresetsItemsV2" }, + { "$ref": "#/definitions/testPresetsItemsV3" } + ], + "items": { + "type": "object", + "properties": { + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "configuration": {}, + "overwriteConfigurationFile": {}, + "output": {}, + "filter": {}, + "execution": {}, + "condition": {} + }, + "required": [ + "name" ], "additionalProperties": false } + }, + "testPresetsV2": { + "type": "array", + "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 2 and higher.", + "allOf": [ + { "$ref": "#/definitions/testPresetsItemsV2" } + ], + "items": { + "type": "object", + "properties": { + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "configuration": {}, + "overwriteConfigurationFile": {}, + "output": {}, + "filter": {}, + "execution": {} + }, + "required": [ + "name" + ], + "additionalProperties": false + } + }, + "condition": { + "anyOf": [ + { + "type": "boolean", + "description": "A boolean which provides a constant value for the condition's evaluation." + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "const" + }, + "value": { + "type": "boolean", + "description": "A required boolean which provides a constant value for the condition's evaluation." + } + }, + "required": [ + "type", + "value" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "equals" + }, + "lhs": { + "type": "string", + "description": "First string to compare. This field supports macro expansion." + }, + "rhs": { + "type": "string", + "description": "Second string to compare. This field supports macro expansion." + } + }, + "required": [ + "type", + "lhs", + "rhs" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "notEquals" + }, + "lhs": { + "type": "string", + "description": "First string to compare. This field supports macro expansion." + }, + "rhs": { + "type": "string", + "description": "Second string to compare. This field supports macro expansion." + } + }, + "required": [ + "type", + "lhs", + "rhs" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "inList" + }, + "string": { + "type": "string", + "description": "A required string to search for. This field supports macro expansion." + }, + "list": { + "type": "array", + "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.", + "items": { + "type": "string" + } + } + }, + "required": [ + "type", + "string", + "list" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "notInList" + }, + "string": { + "type": "string", + "description": "A required string to search for. This field supports macro expansion." + }, + "list": { + "type": "array", + "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.", + "items": { + "type": "string" + } + } + }, + "required": [ + "type", + "string", + "list" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "anyOf" + }, + "conditions": { + "type": "array", + "description": "A required array of condition objects. These conditions use short-circuit evaluation.", + "items": { "$ref": "#/definitions/condition" } + } + }, + "required": [ + "type", + "conditions" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "allOf" + }, + "conditions": { + "type": "array", + "description": "A required array of condition objects. These conditions use short-circuit evaluation.", + "items": { "$ref": "#/definitions/condition" } + } + }, + "required": [ + "type", + "conditions" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "not" + }, + "condition": { "$ref": "#/definitions/condition" } + }, + "required": [ + "type", + "condition" + ], + "additionalProperties": false + } + ] + }, + "topCondition": { + "anyOf": [ + { "$ref": "#/definitions/condition" }, + { + "type": "null", + "description": "Null indicates that the condition always evaluates to true and is not inherited." + } + ] } } } diff --git a/Help/release/dev/cmake-presets-condition.rst b/Help/release/dev/cmake-presets-condition.rst new file mode 100644 index 0000000..aa01bc1 --- /dev/null +++ b/Help/release/dev/cmake-presets-condition.rst @@ -0,0 +1,4 @@ +cmake-presets-condition +----------------------- + +* :manual:`cmake-presets(7)` now support conditional enabling of presets. diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index f593f83..7d037e3 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -557,7 +557,7 @@ void QCMake::loadPresets() preset.toolset = std::move(QString::fromLocal8Bit(p.Toolset.data())); preset.setToolset = !p.ToolsetStrategy || p.ToolsetStrategy == cmCMakePresetsFile::ArchToolsetStrategy::Set; - preset.enabled = it.Expanded && + preset.enabled = it.Expanded && it.Expanded->ConditionResult && std::find_if(this->AvailableGenerators.begin(), this->AvailableGenerators.end(), [&p](const cmake::GeneratorInfo& g) { diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index c0b0981..fbe9fe5 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -9,6 +9,8 @@ #include #include +#include + #include "cmCMakePresetsFileInternal.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -114,6 +116,14 @@ ReadFileResult VisitPreset( for (auto const& v : parentPreset.Environment) { preset.Environment.insert(v); } + + if (!preset.ConditionEvaluator) { + preset.ConditionEvaluator = parentPreset.ConditionEvaluator; + } + } + + if (preset.ConditionEvaluator && preset.ConditionEvaluator->IsNull()) { + preset.ConditionEvaluator.reset(); } CHECK_OK(preset.VisitPresetAfterInherit()) @@ -382,6 +392,19 @@ bool ExpandMacros(const cmCMakePresetsFile& file, const T& preset, } } + if (preset.ConditionEvaluator) { + cm::optional result; + if (!preset.ConditionEvaluator->Evaluate( + macroExpanders, file.GetVersion(preset), result)) { + return false; + } + if (!result) { + out.reset(); + return true; + } + out->ConditionResult = *result; + } + return ExpandMacros(file, preset, out, macroExpanders); } @@ -505,6 +528,80 @@ ExpandMacroResult ExpandMacro(std::string& out, } } +bool cmCMakePresetsFileInternal::EqualsCondition::Evaluate( + const std::vector& expanders, int version, + cm::optional& out) const +{ + std::string lhs = this->Lhs; + CHECK_EXPAND(out, lhs, expanders, version); + + std::string rhs = this->Rhs; + CHECK_EXPAND(out, rhs, expanders, version); + + out = (lhs == rhs); + return true; +} + +bool cmCMakePresetsFileInternal::InListCondition::Evaluate( + const std::vector& expanders, int version, + cm::optional& out) const +{ + std::string str = this->String; + CHECK_EXPAND(out, str, expanders, version); + + for (auto item : this->List) { + CHECK_EXPAND(out, item, expanders, version); + if (str == item) { + out = true; + return true; + } + } + + out = false; + return true; +} + +bool cmCMakePresetsFileInternal::AnyAllOfCondition::Evaluate( + const std::vector& expanders, int version, + cm::optional& out) const +{ + for (auto const& condition : this->Conditions) { + cm::optional result; + if (!condition->Evaluate(expanders, version, result)) { + out.reset(); + return false; + } + + if (!result) { + out.reset(); + return true; + } + + if (result == this->StopValue) { + out = result; + return true; + } + } + + out = !this->StopValue; + return true; +} + +bool cmCMakePresetsFileInternal::NotCondition::Evaluate( + const std::vector& expanders, int version, + cm::optional& out) const +{ + out.reset(); + if (!this->SubCondition->Evaluate(expanders, version, out)) { + out.reset(); + return false; + } + if (out) { + *out = !*out; + } + return true; +} + cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ConfigurePreset::VisitPresetInherit( const cmCMakePresetsFile::Preset& parentPreset) @@ -862,6 +959,10 @@ const char* cmCMakePresetsFile::ResultToString(ReadFileResult result) case ReadFileResult::INSTALL_PREFIX_UNSUPPORTED: return "File version must be 3 or higher for installDir preset " "support."; + case ReadFileResult::INVALID_CONDITION: + return "Invalid preset condition"; + case ReadFileResult::CONDITION_UNSUPPORTED: + return "File version must be 3 or higher for condition support"; } return "Unknown error"; @@ -918,7 +1019,7 @@ void cmCMakePresetsFile::PrintConfigurePresetList( for (auto const& p : this->ConfigurePresetOrder) { auto const& preset = this->ConfigurePresets.at(p); if (!preset.Unexpanded.Hidden && preset.Expanded && - filter(preset.Unexpanded)) { + preset.Expanded->ConditionResult && filter(preset.Unexpanded)) { presets.push_back( static_cast(&preset.Unexpanded)); } @@ -935,7 +1036,8 @@ void cmCMakePresetsFile::PrintBuildPresetList() const std::vector presets; for (auto const& p : this->BuildPresetOrder) { auto const& preset = this->BuildPresets.at(p); - if (!preset.Unexpanded.Hidden && preset.Expanded) { + if (!preset.Unexpanded.Hidden && preset.Expanded && + preset.Expanded->ConditionResult) { presets.push_back( static_cast(&preset.Unexpanded)); } @@ -952,7 +1054,8 @@ void cmCMakePresetsFile::PrintTestPresetList() const std::vector presets; for (auto const& p : this->TestPresetOrder) { auto const& preset = this->TestPresets.at(p); - if (!preset.Unexpanded.Hidden && preset.Expanded) { + if (!preset.Unexpanded.Hidden && preset.Expanded && + preset.Expanded->ConditionResult) { presets.push_back( static_cast(&preset.Unexpanded)); } diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h index 02e6a32..0999d5a 100644 --- a/Source/cmCMakePresetsFile.h +++ b/Source/cmCMakePresetsFile.h @@ -2,8 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #pragma once +#include "cmConfigure.h" // IWYU pragma: keep + #include #include +#include #include #include #include @@ -34,6 +37,8 @@ public: BUILD_TEST_PRESETS_UNSUPPORTED, INVALID_CONFIGURE_PRESET, INSTALL_PREFIX_UNSUPPORTED, + INVALID_CONDITION, + CONDITION_UNSUPPORTED, }; enum class ArchToolsetStrategy @@ -49,6 +54,8 @@ public: std::string Value; }; + class Condition; + class Preset { public: @@ -71,6 +78,9 @@ public: std::string DisplayName; std::string Description; + std::shared_ptr ConditionEvaluator; + bool ConditionResult = true; + std::map> Environment; virtual ReadFileResult VisitPresetInherit(const Preset& parent) = 0; diff --git a/Source/cmCMakePresetsFileInternal.h b/Source/cmCMakePresetsFileInternal.h index f05b8ce..ffb6ce9 100644 --- a/Source/cmCMakePresetsFileInternal.h +++ b/Source/cmCMakePresetsFileInternal.h @@ -1,5 +1,7 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ +#include + #include "cmCMakePresetsFile.h" #define CHECK_OK(expr) \ @@ -20,3 +22,81 @@ enum class ExpandMacroResult using MacroExpander = std::function; } + +class cmCMakePresetsFile::Condition +{ +public: + virtual ~Condition() = default; + + virtual bool Evaluate( + const std::vector& expanders, + int version, cm::optional& out) const = 0; + virtual bool IsNull() const { return false; } +}; + +namespace cmCMakePresetsFileInternal { + +class NullCondition : public cmCMakePresetsFile::Condition +{ + bool Evaluate(const std::vector& /*expanders*/, + int /*version*/, cm::optional& out) const override + { + out = true; + return true; + } + + bool IsNull() const override { return true; } +}; + +class ConstCondition : public cmCMakePresetsFile::Condition +{ +public: + bool Evaluate(const std::vector& /*expanders*/, + int /*version*/, cm::optional& out) const override + { + out = this->Value; + return true; + } + + bool Value; +}; + +class EqualsCondition : public cmCMakePresetsFile::Condition +{ +public: + bool Evaluate(const std::vector& expanders, int version, + cm::optional& out) const override; + + std::string Lhs; + std::string Rhs; +}; + +class InListCondition : public cmCMakePresetsFile::Condition +{ +public: + bool Evaluate(const std::vector& expanders, int version, + cm::optional& out) const override; + + std::string String; + std::vector List; +}; + +class AnyAllOfCondition : public cmCMakePresetsFile::Condition +{ +public: + bool Evaluate(const std::vector& expanders, int version, + cm::optional& out) const override; + + std::vector> Conditions; + bool StopValue; +}; + +class NotCondition : public cmCMakePresetsFile::Condition +{ +public: + bool Evaluate(const std::vector& expanders, int version, + cm::optional& out) const override; + + std::unique_ptr SubCondition; +}; +} diff --git a/Source/cmCMakePresetsFileReadJSON.cxx b/Source/cmCMakePresetsFileReadJSON.cxx index b71b176..e26e7b4 100644 --- a/Source/cmCMakePresetsFileReadJSON.cxx +++ b/Source/cmCMakePresetsFileReadJSON.cxx @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -15,6 +16,7 @@ #include "cmsys/FStream.hxx" #include "cmCMakePresetsFile.h" +#include "cmCMakePresetsFileInternal.h" #include "cmJSONHelpers.h" #include "cmVersion.h" @@ -44,6 +46,180 @@ struct RootPresets std::vector TestPresets; }; +std::unique_ptr InvertCondition( + std::unique_ptr condition) +{ + auto retval = cm::make_unique(); + retval->SubCondition = std::move(condition); + return retval; +} + +auto const ConditionStringHelper = cmJSONStringHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION); + +auto const ConditionBoolHelper = cmJSONBoolHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION); + +auto const ConditionStringListHelper = + cmJSONVectorHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, + ConditionStringHelper); + +auto const ConstConditionHelper = + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, false) + .Bind("type"_s, nullptr, ConditionStringHelper, true) + .Bind("value"_s, &cmCMakePresetsFileInternal::ConstCondition::Value, + ConditionBoolHelper, true); + +auto const EqualsConditionHelper = + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, false) + .Bind("type"_s, nullptr, ConditionStringHelper, true) + .Bind("lhs"_s, &cmCMakePresetsFileInternal::EqualsCondition::Lhs, + ConditionStringHelper, true) + .Bind("rhs"_s, &cmCMakePresetsFileInternal::EqualsCondition::Rhs, + ConditionStringHelper, true); + +auto const InListConditionHelper = + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, false) + .Bind("type"_s, nullptr, ConditionStringHelper, true) + .Bind("string"_s, &cmCMakePresetsFileInternal::InListCondition::String, + ConditionStringHelper, true) + .Bind("list"_s, &cmCMakePresetsFileInternal::InListCondition::List, + ConditionStringListHelper, true); + +ReadFileResult SubConditionHelper( + std::unique_ptr& out, + const Json::Value* value); + +auto const ListConditionVectorHelper = + cmJSONVectorHelper, + ReadFileResult>(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, + SubConditionHelper); +auto const AnyAllOfConditionHelper = + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, false) + .Bind("type"_s, nullptr, ConditionStringHelper, true) + .Bind("conditions"_s, + &cmCMakePresetsFileInternal::AnyAllOfCondition::Conditions, + ListConditionVectorHelper); + +auto const NotConditionHelper = + cmJSONObjectHelper( + ReadFileResult::READ_OK, ReadFileResult::INVALID_CONDITION, false) + .Bind("type"_s, nullptr, ConditionStringHelper, true) + .Bind("condition"_s, + &cmCMakePresetsFileInternal::NotCondition::SubCondition, + SubConditionHelper); + +ReadFileResult ConditionHelper( + std::unique_ptr& out, + const Json::Value* value) +{ + if (!value) { + out.reset(); + return ReadFileResult::READ_OK; + } + + if (value->isBool()) { + auto c = cm::make_unique(); + c->Value = value->asBool(); + out = std::move(c); + return ReadFileResult::READ_OK; + } + + if (value->isNull()) { + out = cm::make_unique(); + return ReadFileResult::READ_OK; + } + + if (value->isObject()) { + if (!value->isMember("type")) { + return ReadFileResult::INVALID_CONDITION; + } + + if (!(*value)["type"].isString()) { + return ReadFileResult::INVALID_CONDITION; + } + auto type = (*value)["type"].asString(); + + if (type == "const") { + auto c = cm::make_unique(); + CHECK_OK(ConstConditionHelper(*c, value)); + out = std::move(c); + return ReadFileResult::READ_OK; + } + + if (type == "equals" || type == "notEquals") { + auto c = cm::make_unique(); + CHECK_OK(EqualsConditionHelper(*c, value)); + out = std::move(c); + if (type == "notEquals") { + out = InvertCondition(std::move(out)); + } + return ReadFileResult::READ_OK; + } + + if (type == "inList" || type == "notInList") { + auto c = cm::make_unique(); + CHECK_OK(InListConditionHelper(*c, value)); + out = std::move(c); + if (type == "notInList") { + out = InvertCondition(std::move(out)); + } + return ReadFileResult::READ_OK; + } + + if (type == "anyOf" || type == "allOf") { + auto c = + cm::make_unique(); + c->StopValue = (type == "anyOf"); + CHECK_OK(AnyAllOfConditionHelper(*c, value)); + out = std::move(c); + return ReadFileResult::READ_OK; + } + + if (type == "not") { + auto c = cm::make_unique(); + CHECK_OK(NotConditionHelper(*c, value)); + out = std::move(c); + return ReadFileResult::READ_OK; + } + } + + return ReadFileResult::INVALID_CONDITION; +} + +ReadFileResult PresetConditionHelper( + std::shared_ptr& out, + const Json::Value* value) +{ + std::unique_ptr ptr; + auto result = ConditionHelper(ptr, value); + out = std::move(ptr); + return result; +} + +ReadFileResult SubConditionHelper( + std::unique_ptr& out, + const Json::Value* value) +{ + std::unique_ptr ptr; + auto result = ConditionHelper(ptr, value); + if (ptr && ptr->IsNull()) { + return ReadFileResult::INVALID_CONDITION; + } + out = std::move(ptr); + return result; +} + cmJSONHelper VendorHelper(ReadFileResult error) { return [error](std::nullptr_t& /*out*/, @@ -306,7 +482,9 @@ auto const ConfigurePresetHelper = false) .Bind("warnings"_s, PresetWarningsHelper, false) .Bind("errors"_s, PresetErrorsHelper, false) - .Bind("debug"_s, PresetDebugHelper, false); + .Bind("debug"_s, PresetDebugHelper, false) + .Bind("condition"_s, &ConfigurePreset::ConditionEvaluator, + PresetConditionHelper, false); auto const BuildPresetHelper = cmJSONObjectHelper( @@ -335,7 +513,9 @@ auto const BuildPresetHelper = false) .Bind("verbose"_s, &BuildPreset::Verbose, PresetOptionalBoolHelper, false) .Bind("nativeToolOptions"_s, &BuildPreset::NativeToolOptions, - PresetVectorStringHelper, false); + PresetVectorStringHelper, false) + .Bind("condition"_s, &BuildPreset::ConditionEvaluator, + PresetConditionHelper, false); ReadFileResult TestPresetOutputVerbosityHelper( TestPreset::OutputOptions::VerbosityEnum& out, const Json::Value* value) @@ -651,7 +831,9 @@ auto const TestPresetHelper = false) .Bind("filter"_s, &TestPreset::Filter, TestPresetFilterHelper, false) .Bind("execution"_s, &TestPreset::Execution, TestPresetExecutionHelper, - false); + false) + .Bind("condition"_s, &TestPreset::ConditionEvaluator, + PresetConditionHelper, false); auto const ConfigurePresetsHelper = cmJSONVectorHelper( @@ -766,6 +948,11 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( return ReadFileResult::INSTALL_PREFIX_UNSUPPORTED; } + // Support for conditions added in version 3. + if (v < 3 && preset.ConditionEvaluator) { + return ReadFileResult::CONDITION_UNSUPPORTED; + } + this->ConfigurePresetOrder.push_back(preset.Name); } @@ -781,6 +968,12 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( if (!this->BuildPresets.emplace(preset.Name, presetPair).second) { return ReadFileResult::DUPLICATE_PRESETS; } + + // Support for conditions added in version 3. + if (v < 3 && preset.ConditionEvaluator) { + return ReadFileResult::CONDITION_UNSUPPORTED; + } + this->BuildPresetOrder.push_back(preset.Name); } @@ -796,6 +989,12 @@ cmCMakePresetsFile::ReadFileResult cmCMakePresetsFile::ReadJSONFile( if (!this->TestPresets.emplace(preset.Name, presetPair).second) { return ReadFileResult::DUPLICATE_PRESETS; } + + // Support for conditions added in version 3. + if (v < 3 && preset.ConditionEvaluator) { + return ReadFileResult::CONDITION_UNSUPPORTED; + } + this->TestPresetOrder.push_back(preset.Name); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 77b4441..4228d30 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2310,6 +2310,13 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, return false; } + if (!expandedPreset->ConditionResult) { + cmSystemTools::Error(cmStrCat("Cannot use disabled test preset in ", + workingDirectory, ": \"", presetName, '"')); + settingsFile.PrintTestPresetList(); + return false; + } + auto configurePresetPair = settingsFile.ConfigurePresets.find(expandedPreset->ConfigurePreset); if (configurePresetPair == settingsFile.ConfigurePresets.end()) { diff --git a/Source/cmJSONHelpers.h b/Source/cmJSONHelpers.h index a63347d..6690aef 100644 --- a/Source/cmJSONHelpers.h +++ b/Source/cmJSONHelpers.h @@ -239,7 +239,7 @@ cmJSONHelper, E> cmJSONVectorFilterHelper(E success, E fail, if (!filter(t)) { continue; } - out.push_back(t); + out.push_back(std::move(t)); } return success; }; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b12eeee..61ce154 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1217,6 +1217,11 @@ void cmake::SetArgs(const std::vector& args) "\": Invalid macro expansion")); return; } + if (!expandedPreset->ConditionResult) { + cmSystemTools::Error(cmStrCat("Could not use disabled preset \"", + preset->second.Unexpanded.Name, "\"")); + return; + } if (!this->State->IsCacheLoaded() && !haveBArg) { this->SetHomeOutputDirectory(expandedPreset->BinaryDir); @@ -3164,6 +3169,14 @@ int cmake::Build(int jobs, std::string dir, std::vector targets, return 1; } + if (!expandedPreset->ConditionResult) { + cmSystemTools::Error(cmStrCat("Cannot use disabled build preset in ", + this->GetHomeDirectory(), ": \"", + presetName, '"')); + settingsFile.PrintBuildPresetList(); + return 1; + } + auto configurePresetPair = settingsFile.ConfigurePresets.find(expandedPreset->ConfigurePreset); if (configurePresetPair == settingsFile.ConfigurePresets.end()) { diff --git a/Tests/RunCMake/CMakePresets/ConditionFuture-result.txt b/Tests/RunCMake/CMakePresets/ConditionFuture-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ConditionFuture-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/ConditionFuture-stderr.txt b/Tests/RunCMake/CMakePresets/ConditionFuture-stderr.txt new file mode 100644 index 0000000..ea5f47f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ConditionFuture-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/ConditionFuture: File version must be 3 or higher for condition support$ diff --git a/Tests/RunCMake/CMakePresets/ConditionFuture.json.in b/Tests/RunCMake/CMakePresets/ConditionFuture.json.in new file mode 100644 index 0000000..9d4798b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ConditionFuture.json.in @@ -0,0 +1,11 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "ConditionFuture", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "condition": true + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/Conditions.json.in b/Tests/RunCMake/CMakePresets/Conditions.json.in new file mode 100644 index 0000000..9a01e2f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/Conditions.json.in @@ -0,0 +1,349 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "Base", + "hidden": true, + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + }, + { + "name": "SimpleTrue", + "inherits": "Base", + "condition": true + }, + { + "name": "SimpleFalse", + "inherits": "Base", + "condition": false + }, + { + "name": "Null", + "inherits": "Base", + "condition": null + }, + { + "name": "ConstTrue", + "inherits": "Base", + "condition": { + "type": "const", + "value": true + } + }, + { + "name": "ConstFalse", + "inherits": "Base", + "condition": { + "type": "const", + "value": false + } + }, + { + "name": "EqualsTrue", + "inherits": "Base", + "condition": { + "type": "equals", + "lhs": "abc", + "rhs": "abc" + } + }, + { + "name": "EqualsFalse", + "inherits": "Base", + "condition": { + "type": "equals", + "lhs": "abc", + "rhs": "abcd" + } + }, + { + "name": "EqualsMacroLeft", + "inherits": "Base", + "condition": { + "type": "equals", + "lhs": "${presetName}", + "rhs": "EqualsMacroLeft" + } + }, + { + "name": "EqualsMacroRight", + "inherits": "Base", + "condition": { + "type": "equals", + "lhs": "EqualsMacroRight", + "rhs": "${presetName}" + } + }, + { + "name": "NotEqualsTrue", + "inherits": "Base", + "condition": { + "type": "notEquals", + "lhs": "abc", + "rhs": "abcd" + } + }, + { + "name": "NotEqualsFalse", + "inherits": "Base", + "condition": { + "type": "notEquals", + "lhs": "abc", + "rhs": "abc" + } + }, + { + "name": "InListTrue", + "inherits": "Base", + "condition": { + "type": "inList", + "string": "b", + "list": [ + "a", + "b", + "c" + ] + } + }, + { + "name": "InListFalse", + "inherits": "Base", + "condition": { + "type": "inList", + "string": "d", + "list": [ + "a", + "b", + "c" + ] + } + }, + { + "name": "InListMacroString", + "inherits": "Base", + "condition": { + "type": "inList", + "string": "${presetName}", + "list": [ + "InListMacroString", + "AnotherString" + ] + } + }, + { + "name": "InListMacroList", + "inherits": "Base", + "condition": { + "type": "inList", + "string": "InListMacroList", + "list": [ + "${presetName}", + "AnotherString" + ] + } + }, + { + "name": "InListShortCircuit", + "inherits": "Base", + "condition": { + "type": "inList", + "string": "a", + "list": [ + "a", + "${invalidMacro}" + ] + } + }, + { + "name": "NotInListTrue", + "inherits": "Base", + "condition": { + "type": "notInList", + "string": "d", + "list": [ + "a", + "b", + "c" + ] + } + }, + { + "name": "NotInListFalse", + "inherits": "Base", + "condition": { + "type": "notInList", + "string": "a", + "list": [ + "a", + "b", + "c" + ] + } + }, + { + "name": "AnyOfTrue1", + "inherits": "Base", + "condition": { + "type": "anyOf", + "conditions": [ + true, + false + ] + } + }, + { + "name": "AnyOfTrue2", + "inherits": "Base", + "condition": { + "type": "anyOf", + "conditions": [ + false, + true + ] + } + }, + { + "name": "AnyOfFalse", + "inherits": "Base", + "condition": { + "type": "anyOf", + "conditions": [ + false, + { + "type": "equals", + "lhs": "abc", + "rhs": "abcd" + } + ] + } + }, + { + "name": "AnyOfShortCircuit", + "inherits": "Base", + "condition": { + "type": "anyOf", + "conditions": [ + true, + { + "type": "equals", + "lhs": "${invalidMacro}", + "rhs": "" + } + ] + } + }, + { + "name": "AnyOfEmpty", + "inherits": "Base", + "condition": { + "type": "anyOf", + "conditions": [] + } + }, + { + "name": "AllOfTrue", + "inherits": "Base", + "condition": { + "type": "allOf", + "conditions": [ + true, + { + "type": "equals", + "lhs": "abc", + "rhs": "abc" + } + ] + } + }, + { + "name": "AllOfFalse1", + "inherits": "Base", + "condition": { + "type": "allOf", + "conditions": [ + false, + true + ] + } + }, + { + "name": "AllOfFalse2", + "inherits": "Base", + "condition": { + "type": "allOf", + "conditions": [ + true, + false + ] + } + }, + { + "name": "AllOfShortCircuit", + "inherits": "Base", + "condition": { + "type": "allOf", + "conditions": [ + false, + { + "type": "equals", + "lhs": "${invalidMacro}", + "rhs": "" + } + ] + } + }, + { + "name": "AllOfEmpty", + "inherits": "Base", + "condition": { + "type": "allOf", + "conditions": [] + } + }, + { + "name": "NotTrue", + "inherits": "Base", + "condition": { + "type": "not", + "condition": true + } + }, + { + "name": "NotFalse", + "inherits": "Base", + "condition": { + "type": "not", + "condition": false + } + }, + { + "name": "InheritanceBase", + "inherits": "Base", + "hidden": true, + "condition": { + "type": "equals", + "lhs": "${presetName}", + "rhs": "InheritanceChildTrue" + } + }, + { + "name": "InheritanceChildTrue", + "inherits": "InheritanceBase" + }, + { + "name": "InheritanceChildFalse", + "inherits": "InheritanceBase" + }, + { + "name": "InheritanceNull", + "inherits": "Null" + }, + { + "name": "InheritanceNullFalse", + "inherits": [ + "Null", + "SimpleFalse" + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt b/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt new file mode 100644 index 0000000..19f91d4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt @@ -0,0 +1,22 @@ +Available configure presets: + + "SimpleTrue" + "Null" + "ConstTrue" + "EqualsTrue" + "EqualsMacroLeft" + "EqualsMacroRight" + "NotEqualsTrue" + "InListTrue" + "InListMacroString" + "InListMacroList" + "InListShortCircuit" + "NotInListTrue" + "AnyOfTrue1" + "AnyOfTrue2" + "AnyOfShortCircuit" + "AllOfTrue" + "AllOfEmpty" + "NotFalse" + "InheritanceChildTrue" + "InheritanceNull"$ diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 24ac0e9..22425b2 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -118,6 +118,8 @@ run_cmake_presets(EnvCycle) run_cmake_presets(EmptyEnv) run_cmake_presets(EmptyPenv) set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(ConditionFuture) +run_cmake_presets(SubConditionNull) # Test cmakeMinimumRequired field run_cmake_presets(MinimumRequiredInvalid) @@ -267,6 +269,12 @@ run_cmake_presets(HostSystemName) set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/HostSystemNameFuture.json.in") run_cmake_presets(HostSystemNameFuture) +# Test conditions +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Conditions.json.in") +run_cmake_presets(ListConditions --list-presets) +run_cmake_presets(SimpleTrue) +run_cmake_presets(SimpleFalse) + # Test the example from the documentation file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example) string(REPLACE "\"generator\": \"Ninja\"" "\"generator\": \"@RunCMake_GENERATOR@\"" _example "${_example}") diff --git a/Tests/RunCMake/CMakePresets/SimpleFalse-result.txt b/Tests/RunCMake/CMakePresets/SimpleFalse-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SimpleFalse-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/SimpleFalse-stderr.txt b/Tests/RunCMake/CMakePresets/SimpleFalse-stderr.txt new file mode 100644 index 0000000..6a9a7de --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SimpleFalse-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Could not use disabled preset "SimpleFalse"$ diff --git a/Tests/RunCMake/CMakePresets/SimpleTrue.cmake b/Tests/RunCMake/CMakePresets/SimpleTrue.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresets/SubConditionNull-result.txt b/Tests/RunCMake/CMakePresets/SubConditionNull-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SubConditionNull-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/SubConditionNull-stderr.txt b/Tests/RunCMake/CMakePresets/SubConditionNull-stderr.txt new file mode 100644 index 0000000..42b74d6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SubConditionNull-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/SubConditionNull: Invalid preset condition$ diff --git a/Tests/RunCMake/CMakePresets/SubConditionNull.json.in b/Tests/RunCMake/CMakePresets/SubConditionNull.json.in new file mode 100644 index 0000000..eed3da6 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/SubConditionNull.json.in @@ -0,0 +1,14 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "SubConditionNull", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "condition": { + "type": "not", + "condition": null + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-result.txt b/Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-stderr.txt new file mode 100644 index 0000000..c35f5d7 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsBuild/Condition-build-disabled-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Cannot use disabled build preset in [^ +]*/Tests/RunCMake/CMakePresetsBuild/Condition: "disabled"$ diff --git a/Tests/RunCMake/CMakePresetsBuild/Condition.cmake b/Tests/RunCMake/CMakePresetsBuild/Condition.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CMakePresetsBuild/Condition.json.in b/Tests/RunCMake/CMakePresetsBuild/Condition.json.in new file mode 100644 index 0000000..aaee96a --- /dev/null +++ b/Tests/RunCMake/CMakePresetsBuild/Condition.json.in @@ -0,0 +1,22 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ], + "buildPresets": [ + { + "name": "enabled", + "configurePreset": "default", + "condition": true + }, + { + "name": "disabled", + "configurePreset": "default", + "condition": false + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-result.txt b/Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-stderr.txt b/Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-stderr.txt new file mode 100644 index 0000000..f08f4c1 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsBuild/ConditionFuture-build-conditionFuture-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsBuild/ConditionFuture: File version must be 3 or higher for condition support$ diff --git a/Tests/RunCMake/CMakePresetsBuild/ConditionFuture.json.in b/Tests/RunCMake/CMakePresetsBuild/ConditionFuture.json.in new file mode 100644 index 0000000..2f3f7d8 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsBuild/ConditionFuture.json.in @@ -0,0 +1,17 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ], + "buildPresets": [ + { + "name": "conditionFuture", + "configurePreset": "default", + "condition": true + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt b/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt index 4d30707..2d362d4 100644 --- a/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt +++ b/Tests/RunCMake/CMakePresetsBuild/ListPresets-build-x-stdout.txt @@ -1,5 +1,6 @@ -Available build presets: +^Available build presets: "build-default" - build-default displayName "empty" "display" - display displayName + "true"$ diff --git a/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in b/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in index 3f5e02c..26504d3 100644 --- a/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in +++ b/Tests/RunCMake/CMakePresetsBuild/ListPresets.json.in @@ -1,5 +1,5 @@ { - "version": 2, + "version": 3, "configurePresets": [ { "name": "default", @@ -26,6 +26,16 @@ { "name": "hidden", "hidden": true + }, + { + "name": "true", + "inherits": "build-default", + "condition": true + }, + { + "name": "false", + "inherits": "build-default", + "condition": false } ] } diff --git a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake index 2559b12..afa22eb 100644 --- a/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresetsBuild/RunCMakeTest.cmake @@ -64,6 +64,7 @@ set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) run_cmake_build_presets(Good "default;other" "build-other;withEnvironment;noEnvironment;macros;vendorObject") run_cmake_build_presets(InvalidConfigurePreset "default" "badConfigurePreset") +run_cmake_build_presets(Condition "default" "enabled;disabled") set(CMakePresetsBuild_BUILD_ONLY 1) run_cmake_build_presets(ListPresets "x" "x" "--list-presets") @@ -72,5 +73,6 @@ run_cmake_build_presets(Invalid "x" "hidden;vendorMacro") set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) run_cmake_build_presets(PresetsUnsupported "x" "x") +run_cmake_build_presets(ConditionFuture "x" "conditionFuture") set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) set(CMakePresetsBuild_BUILD_ONLY 0) diff --git a/Tests/RunCMake/CMakePresetsTest/Condition.json.in b/Tests/RunCMake/CMakePresetsTest/Condition.json.in new file mode 100644 index 0000000..0baf176 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/Condition.json.in @@ -0,0 +1,22 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ], + "testPresets": [ + { + "name": "enabled", + "configurePreset": "default", + "condition": true + }, + { + "name": "disabled", + "configurePreset": "default", + "condition": false + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-result.txt b/Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-stderr.txt b/Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-stderr.txt new file mode 100644 index 0000000..b814bbb --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionFuture-test-x-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsTest/ConditionFuture: File version must be 3 or higher for condition support$ diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionFuture.json.in b/Tests/RunCMake/CMakePresetsTest/ConditionFuture.json.in new file mode 100644 index 0000000..4b9f33f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionFuture.json.in @@ -0,0 +1,17 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "default", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ], + "testPresets": [ + { + "name": "conditionFuture", + "configurePreset": "default", + "condition": true + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionListPresets-test-x-stdout.txt b/Tests/RunCMake/CMakePresetsTest/ConditionListPresets-test-x-stdout.txt new file mode 100644 index 0000000..11918e5 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionListPresets-test-x-stdout.txt @@ -0,0 +1,3 @@ +^Available test presets: + + "enabled"$ diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-result.txt b/Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-stderr.txt b/Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-stderr.txt new file mode 100644 index 0000000..5db3b77 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionRunTests-test-disabled-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Cannot use disabled test preset in [^ +]*/Tests/RunCMake/CMakePresetsTest/ConditionRunTests: "disabled"$ diff --git a/Tests/RunCMake/CMakePresetsTest/ConditionRunTests.cmake b/Tests/RunCMake/CMakePresetsTest/ConditionRunTests.cmake new file mode 100644 index 0000000..b29161e --- /dev/null +++ b/Tests/RunCMake/CMakePresetsTest/ConditionRunTests.cmake @@ -0,0 +1,2 @@ +enable_testing() +add_test(true ${CMAKE_COMMAND} -E true) diff --git a/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake index c93dff3..70d25d4 100644 --- a/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresetsTest/RunCMakeTest.cmake @@ -90,6 +90,12 @@ run_cmake_test_presets(InvalidConfigurePreset "default" "" "badConfigurePreset") set(CMakePresetsTest_NO_CONFIGURE 1) set(CMakePresetsTest_FILE "${RunCMake_SOURCE_DIR}/Good.json.in") run_cmake_test_presets(ListPresets "" "" "x" "--list-presets") + +set(CMakePresetsTest_FILE "${RunCMake_SOURCE_DIR}/Condition.json.in") +run_cmake_test_presets(ConditionListPresets "" "" "x" "--list-presets") +unset(CMakePresetsTest_NO_CONFIGURE) +run_cmake_test_presets(ConditionRunTests "default" "" "enabled;disabled") +set(CMakePresetsTest_NO_CONFIGURE 1) unset(CMakePresetsTest_FILE) run_cmake_test_presets(NoConfigurePreset "" "" "noConfigurePreset") @@ -98,6 +104,7 @@ run_cmake_test_presets(Invalid "" "" "hidden;vendorMacro") set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) run_cmake_test_presets(PresetsUnsupported "" "" "x") +run_cmake_test_presets(ConditionFuture "" "" "x") set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) set(CMakePresetsTest_NO_CONFIGURE 0) diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp index c2aced5..f2aef3e 100644 --- a/Utilities/IWYU/mapping.imp +++ b/Utilities/IWYU/mapping.imp @@ -96,6 +96,7 @@ { symbol: [ "std::enable_if > >::type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::enable_if > >::type", private, "\"cmConfigure.h\"", public ] }, { symbol: [ "std::enable_if > >::type", private, "\"cmConfigure.h\"", public ] }, + { symbol: [ "__gnu_cxx::__enable_if::__type", private, "\"cmConfigure.h\"", public ] }, # Wrappers for 3rd-party libraries { include: [ "@<.*curl/curlver.h>", private, "", public ] }, -- cgit v0.12 From 6e7ff52af74cfbff15ded5c3aba7097499dffd32 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 23 Mar 2021 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 17f26a8..d106195 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210322) +set(CMake_VERSION_PATCH 20210323) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 88060f471766222c54a080900f73abf29586a6f4 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 24 Mar 2021 00:01:16 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d106195..d86d725 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210323) +set(CMake_VERSION_PATCH 20210324) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From f536e6f3fb588e2cb8ab86a1f4eab75db011cefa Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Wed, 24 Mar 2021 18:22:38 +1100 Subject: CPackIFW: Remove redundant variable assignment This was showing up in cppcheck results. --- Source/CPack/IFW/cmCPackIFWPackage.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index c4bd7f1..5191c96 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -31,7 +31,7 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct( const std::string& dependence) { // Search compare section - size_t pos = std::string::npos; + size_t pos; if ((pos = dependence.find("<=")) != std::string::npos) { this->Compare.Type = cmCPackIFWPackage::CompareLessOrEqual; this->Compare.Value = dependence.substr(pos + 2); -- cgit v0.12 From d1b23dd4680fb39cd315980bbfd720e8cc39cafc Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 24 Mar 2021 12:35:35 -0400 Subject: gitlab-ci: update Intel Compiler base image tag naming convention --- .gitlab-ci.yml | 58 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f996e8..465dc2c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -179,203 +179,203 @@ test:intel2016-makefiles: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2016_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016-el7 test:intel2016u1-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2016u1_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016u1-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016u1-el7 test:intel2016u2-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2016u2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016u2-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2016u2-el7 test:intel2017-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017-el7 test:intel2017u1-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u1_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u1-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u1-el7 test:intel2017u2-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u2-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u2-el7 test:intel2017u3-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u3_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u3-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u3-el7 test:intel2017u4-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u4_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u4-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u4-el7 test:intel2017u5-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u5_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u5-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u5-el7 test:intel2017u6-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u6_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u6-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u6-el7 test:intel2017u7-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u7_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u7-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u7-el7 test:intel2017u8-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2017u8_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u8-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2017u8-el7 test:intel2018-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2018_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018-el7 test:intel2018u1-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2018u1_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u1-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u1-el7 test:intel2018u2-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2018u2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u2-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u2-el7 test:intel2018u3-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2018u3_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u3-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u3-el7 test:intel2018u4-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2018u4_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u4-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2018u4-el7 test:intel2019-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2019_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019-el7 test:intel2019u1-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2019u1_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u1-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u1-el7 test:intel2019u2-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2019u2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u2-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u2-el7 test:intel2019u3-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2019u3_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u3-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u3-el7 test:intel2019u4-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2019u4_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u4-centos7 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2019u4-el7 test:intel2020-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2020_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020-el8 test:intel2020u2-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2020u2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020u2-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020u2-el8 test:intel2020u4-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2020u4_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020u4-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2020u4-el8 test:intel2021.1.1-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2021.1.1_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.1-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.1-el8 test:intel2021.1.2-makefiles: extends: - .cmake_test_linux_intelclassic_makefiles variables: CMAKE_CI_BUILD_NAME: intel2021.1.2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-el8 test:oneapi2021.1.1-makefiles: extends: - .cmake_test_linux_inteloneapi_makefiles variables: CMAKE_CI_BUILD_NAME: oneapi2021.1.1_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.1-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.1-el8 test:oneapi2021.1.2-makefiles: extends: - .cmake_test_linux_inteloneapi_makefiles variables: CMAKE_CI_BUILD_NAME: oneapi2021.1.2_makefiles - CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-rhel8 + CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.1.2-el8 build:linux-x86_64-package: extends: -- cgit v0.12 From c0aa4244f5b1900c280b54a5453cc881dc7d3d95 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 25 Mar 2021 00:01:17 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d86d725..dd9f4cb 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210324) +set(CMake_VERSION_PATCH 20210325) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 238c2b6cb7e96a6024108b3657f7d8bec6fa07f2 Mon Sep 17 00:00:00 2001 From: Pedro Luis Castedo Cepeda Date: Thu, 25 Mar 2021 20:17:28 +0100 Subject: FindRuby: Consider ruby names with full nodot version suffixes --- Modules/FindRuby.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index ee07f83..759f57c 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -435,7 +435,7 @@ endif() # Determine the list of possible names for the ruby library -set(_Ruby_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_Ruby_VERSION_SHORT} ruby${_Ruby_VERSION_SHORT_NODOT} ruby-${_Ruby_VERSION_SHORT} ruby-${Ruby_VERSION}) +set(_Ruby_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_Ruby_VERSION_SHORT} ruby${_Ruby_VERSION_SHORT_NODOT} ruby${_Ruby_NODOT_VERSION} ruby-${_Ruby_VERSION_SHORT} ruby-${Ruby_VERSION}) if(WIN32) set(_Ruby_POSSIBLE_MSVC_RUNTIMES "msvcrt;vcruntime140;vcruntime140_1") -- cgit v0.12 From 2fe39dc30614f8fd7d0c37a68e8e7e3eb20f445a Mon Sep 17 00:00:00 2001 From: Matt Jaeger Date: Thu, 25 Mar 2021 11:56:36 -0700 Subject: cmake: Fix loading CMake sources from long paths on Windows Pass a Windows extended path to the lexer so it can open long paths. --- Source/cmListFileCache.cxx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 1464a14..5c3a034 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -7,6 +7,10 @@ #include #include +#ifdef _WIN32 +# include +#endif + #include "cmListFileLexer.h" #include "cmMessageType.h" #include "cmMessenger.h" @@ -83,9 +87,15 @@ bool cmListFileParser::ParseFile(const char* filename) { this->FileName = filename; +#ifdef _WIN32 + std::string expandedFileName = cmsys::Encoding::ToNarrow( + cmSystemTools::ConvertToWindowsExtendedPath(filename)); + filename = expandedFileName.c_str(); +#endif + // Open the file. cmListFileLexer_BOM bom; - if (!cmListFileLexer_SetFileName(this->Lexer, this->FileName, &bom)) { + if (!cmListFileLexer_SetFileName(this->Lexer, filename, &bom)) { this->IssueFileOpenError("cmListFileCache: error can not open file."); return false; } -- cgit v0.12 From 739446a9a1975367b2c9a6b105b3fde1656c725b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 25 Mar 2021 16:54:08 -0400 Subject: FindDoxygen: clarify the CMake variable naming scheme --- Modules/FindDoxygen.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 7fe5da1..4a16e31 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -223,7 +223,8 @@ them to be separated by whitespace. CMake variables hold lists as a string with items separated by semi-colons, so a conversion needs to be performed. The ``doxygen_add_docs()`` command specifically checks the following Doxygen config options and will convert their associated CMake variable's contents into the -required form if set. +required form if set. CMake variables are named ``DOXYGEN_`` for the +Doxygen settings specified here. :: -- cgit v0.12 From 61fd90b90c9dfec154aee7fb4d97574921e651d1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 26 Mar 2021 00:01:21 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dd9f4cb..fa9d567 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210325) +set(CMake_VERSION_PATCH 20210326) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 3706e9c97cef2ad8097adfd4ed2f04ff08398787 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 26 Mar 2021 09:34:18 -0400 Subject: Help: Convert project() directory variables to a definition list --- Help/command/project.rst | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Help/command/project.rst b/Help/command/project.rst index 6c931b6..a726cbb 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -20,12 +20,13 @@ Sets the name of the project, and stores it in the variable ``CMakeLists.txt`` also stores the project name in the variable :variable:`CMAKE_PROJECT_NAME`. -Also sets the variables +Also sets the variables: -* :variable:`PROJECT_SOURCE_DIR`, - :variable:`_SOURCE_DIR` -* :variable:`PROJECT_BINARY_DIR`, - :variable:`_BINARY_DIR` +:variable:`PROJECT_SOURCE_DIR`, :variable:`_SOURCE_DIR` + Absolute path to the source directory for the project. + +:variable:`PROJECT_BINARY_DIR`, :variable:`_BINARY_DIR` + Absolute path to the binary directory for the project. Further variables are set by the optional arguments described in the following. If any of these arguments is not used, then the corresponding variables are -- cgit v0.12 From 96a704010713833e9ec17fa78495df3e0852bbf5 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Wed, 24 Mar 2021 19:59:14 +0000 Subject: project: Define variables indicating whether project is top level Define `PROJECT_IS_TOP_LEVEL` and `_IS_TOP_LEVEL`. The latter is a STATIC cache entry just like other `_*` variables so that it is globally scoped. Issue: #20310 Fixes: #21961 --- Help/command/project.rst | 5 +++++ Help/manual/cmake-variables.7.rst | 2 ++ Help/release/dev/project-is-top-level.rst | 6 ++++++ Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst | 11 +++++++++++ Help/variable/PROJECT_IS_TOP_LEVEL.rst | 21 +++++++++++++++++++++ Source/cmProjectCommand.cxx | 5 +++++ Tests/RunCMake/project/ProjectIsTopLevel-stdout.txt | 2 ++ Tests/RunCMake/project/ProjectIsTopLevel.cmake | 9 +++++++++ .../project/ProjectIsTopLevelMultiple-stdout.txt | 3 +++ .../project/ProjectIsTopLevelMultiple.cmake | 14 ++++++++++++++ .../ProjectIsTopLevelSubdirectory-stdout.txt | 6 ++++++ .../project/ProjectIsTopLevelSubdirectory.cmake | 8 ++++++++ .../ProjectIsTopLevelSubdirectory/CMakeLists.txt | 5 +++++ Tests/RunCMake/project/RunCMakeTest.cmake | 3 +++ 14 files changed, 100 insertions(+) create mode 100644 Help/release/dev/project-is-top-level.rst create mode 100644 Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst create mode 100644 Help/variable/PROJECT_IS_TOP_LEVEL.rst create mode 100644 Tests/RunCMake/project/ProjectIsTopLevel-stdout.txt create mode 100644 Tests/RunCMake/project/ProjectIsTopLevel.cmake create mode 100644 Tests/RunCMake/project/ProjectIsTopLevelMultiple-stdout.txt create mode 100644 Tests/RunCMake/project/ProjectIsTopLevelMultiple.cmake create mode 100644 Tests/RunCMake/project/ProjectIsTopLevelSubdirectory-stdout.txt create mode 100644 Tests/RunCMake/project/ProjectIsTopLevelSubdirectory.cmake create mode 100644 Tests/RunCMake/project/ProjectIsTopLevelSubdirectory/CMakeLists.txt diff --git a/Help/command/project.rst b/Help/command/project.rst index a726cbb..8a6bc1e 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -28,6 +28,11 @@ Also sets the variables: :variable:`PROJECT_BINARY_DIR`, :variable:`_BINARY_DIR` Absolute path to the binary directory for the project. +:variable:`PROJECT_IS_TOP_LEVEL`, :variable:`_IS_TOP_LEVEL` + .. versionadded:: 3.21 + + Boolean value indicating whether the project is top-level. + Further variables are set by the optional arguments described in the following. If any of these arguments is not used, then the corresponding variables are set to the empty string. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 4317dd4..37ef053 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -130,6 +130,7 @@ Variables that Provide Information /variable/PROJECT-NAME_BINARY_DIR /variable/PROJECT-NAME_DESCRIPTION /variable/PROJECT-NAME_HOMEPAGE_URL + /variable/PROJECT-NAME_IS_TOP_LEVEL /variable/PROJECT-NAME_SOURCE_DIR /variable/PROJECT-NAME_VERSION /variable/PROJECT-NAME_VERSION_MAJOR @@ -139,6 +140,7 @@ Variables that Provide Information /variable/PROJECT_BINARY_DIR /variable/PROJECT_DESCRIPTION /variable/PROJECT_HOMEPAGE_URL + /variable/PROJECT_IS_TOP_LEVEL /variable/PROJECT_NAME /variable/PROJECT_SOURCE_DIR /variable/PROJECT_VERSION diff --git a/Help/release/dev/project-is-top-level.rst b/Help/release/dev/project-is-top-level.rst new file mode 100644 index 0000000..568afe0 --- /dev/null +++ b/Help/release/dev/project-is-top-level.rst @@ -0,0 +1,6 @@ +project-is-top-level +-------------------- + +* :command:`project` now sets variables :variable:`PROJECT_IS_TOP_LEVEL` and + :variable:`_IS_TOP_LEVEL` to indicate whether it was called + in a top level ``CMakeLists.txt`` file. diff --git a/Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst b/Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst new file mode 100644 index 0000000..953e978 --- /dev/null +++ b/Help/variable/PROJECT-NAME_IS_TOP_LEVEL.rst @@ -0,0 +1,11 @@ +_IS_TOP_LEVEL +--------------------------- + +.. versionadded:: 3.21 + +A boolean variable indicating whether the named project was called in a top +level ``CMakeLists.txt`` file. + +To obtain the value from the most recent call to :command:`project` in +the current directory scope or above, see the +:variable:`PROJECT_IS_TOP_LEVEL` variable. diff --git a/Help/variable/PROJECT_IS_TOP_LEVEL.rst b/Help/variable/PROJECT_IS_TOP_LEVEL.rst new file mode 100644 index 0000000..e5eb6c1 --- /dev/null +++ b/Help/variable/PROJECT_IS_TOP_LEVEL.rst @@ -0,0 +1,21 @@ +PROJECT_IS_TOP_LEVEL +-------------------- + +.. versionadded:: 3.21 + +A boolean variable indicating whether :command:`project` was called in a top +level ``CMakeLists.txt`` file. + +Some modules should only be included as part of the top level +``CMakeLists.txt`` file to not cause unintended side effects in the build +tree, and this variable can be used to conditionally execute such code. For +example, consider the :module:`CTest` module, which creates targets and +options: + +.. code-block:: cmake + + project(MyProject) + ... + if(PROJECT_IS_TOP_LEVEL) + include(CTest) + endif() diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index ed32de9..acdb09f 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -59,6 +59,11 @@ bool cmProjectCommand(std::vector const& args, mf.AddDefinition("PROJECT_NAME", projectName); + mf.AddDefinitionBool("PROJECT_IS_TOP_LEVEL", mf.IsRootMakefile()); + mf.AddCacheDefinition(projectName + "_IS_TOP_LEVEL", + mf.IsRootMakefile() ? "ON" : "OFF", + "Value Computed by CMake", cmStateEnums::STATIC); + // Set the CMAKE_PROJECT_NAME variable to be the highest-level // project name in the tree. If there are two project commands // in the same CMakeLists.txt file, and it is the top level diff --git a/Tests/RunCMake/project/ProjectIsTopLevel-stdout.txt b/Tests/RunCMake/project/ProjectIsTopLevel-stdout.txt new file mode 100644 index 0000000..af8abfd --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevel-stdout.txt @@ -0,0 +1,2 @@ +-- PROJECT_IS_TOP_LEVEL=ON +-- ProjectIsTopLevel_IS_TOP_LEVEL=ON diff --git a/Tests/RunCMake/project/ProjectIsTopLevel.cmake b/Tests/RunCMake/project/ProjectIsTopLevel.cmake new file mode 100644 index 0000000..5a0af0a --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevel.cmake @@ -0,0 +1,9 @@ +# no project() call, includer already calls project(${RunCMake_TEST} NONE) +if(NOT DEFINED PROJECT_IS_TOP_LEVEL) + message(FATAL_ERROR "PROJECT_IS_TOP_LEVEL is not defined") +endif() +if(NOT DEFINED "CACHE{${RunCMake_TEST}_IS_TOP_LEVEL}") + message(FATAL_ERROR "IsTopLevel_IS_TOP_LEVEL is not defined") +endif() +message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}") +message(STATUS "${RunCMake_TEST}_IS_TOP_LEVEL=${${RunCMake_TEST}_IS_TOP_LEVEL}") diff --git a/Tests/RunCMake/project/ProjectIsTopLevelMultiple-stdout.txt b/Tests/RunCMake/project/ProjectIsTopLevelMultiple-stdout.txt new file mode 100644 index 0000000..75d787f --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevelMultiple-stdout.txt @@ -0,0 +1,3 @@ +-- PROJECT_IS_TOP_LEVEL=ON +-- ProjectIsTopLevelMultiple_IS_TOP_LEVEL=ON +-- IsTopLevel_IS_TOP_LEVEL=ON diff --git a/Tests/RunCMake/project/ProjectIsTopLevelMultiple.cmake b/Tests/RunCMake/project/ProjectIsTopLevelMultiple.cmake new file mode 100644 index 0000000..98ba55b --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevelMultiple.cmake @@ -0,0 +1,14 @@ +# only one project() call, includer already calls project(${RunCMake_TEST} NONE) +project(IsTopLevel NONE) +if(NOT DEFINED PROJECT_IS_TOP_LEVEL) + message(FATAL_ERROR "PROJECT_IS_TOP_LEVEL is not defined") +endif() +if(NOT DEFINED "CACHE{${RunCMake_TEST}_IS_TOP_LEVEL}") + message(FATAL_ERROR "${RunCMake_TEST}_IS_TOP_LEVEL is not defined") +endif() +if(NOT DEFINED CACHE{IsTopLevel_IS_TOP_LEVEL}) + message(FATAL_ERROR "IsTopLevel_IS_TOP_LEVEL is not defined") +endif() +message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}") +message(STATUS "${RunCMake_TEST}_IS_TOP_LEVEL=${${RunCMake_TEST}_IS_TOP_LEVEL}") +message(STATUS "IsTopLevel_IS_TOP_LEVEL=${IsTopLevel_IS_TOP_LEVEL}") diff --git a/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory-stdout.txt b/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory-stdout.txt new file mode 100644 index 0000000..d9e15ff --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory-stdout.txt @@ -0,0 +1,6 @@ +-- PROJECT_IS_TOP_LEVEL=ON +-- PROJECT_IS_TOP_LEVEL=ON +-- PROJECT_IS_TOP_LEVEL=OFF +-- PROJECT_IS_TOP_LEVEL=ON +-- ProjectIsTopLevelSubdirectory_IS_TOP_LEVEL=ON +-- NotTopLevel_IS_TOP_LEVEL=OFF diff --git a/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory.cmake b/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory.cmake new file mode 100644 index 0000000..b5df84b --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory.cmake @@ -0,0 +1,8 @@ +# no project() call, includer already calls project(${RunCMake_TEST} NONE) +message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}") + +add_subdirectory(ProjectIsTopLevelSubdirectory) + +message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}") +message(STATUS "${RunCMake_TEST}_IS_TOP_LEVEL=${${RunCMake_TEST}_IS_TOP_LEVEL}") +message(STATUS "NotTopLevel_IS_TOP_LEVEL=${NotTopLevel_IS_TOP_LEVEL}") diff --git a/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory/CMakeLists.txt b/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory/CMakeLists.txt new file mode 100644 index 0000000..d2f16ea --- /dev/null +++ b/Tests/RunCMake/project/ProjectIsTopLevelSubdirectory/CMakeLists.txt @@ -0,0 +1,5 @@ +message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}") + +project(NotTopLevel NONE) + +message(STATUS "PROJECT_IS_TOP_LEVEL=${PROJECT_IS_TOP_LEVEL}") diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 6914699..349e8ac 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -15,6 +15,9 @@ run_cmake(ProjectDescriptionNoArg2) run_cmake(ProjectHomepage) run_cmake(ProjectHomepage2) run_cmake(ProjectHomepageNoArg) +run_cmake(ProjectIsTopLevel) +run_cmake(ProjectIsTopLevelMultiple) +run_cmake(ProjectIsTopLevelSubdirectory) run_cmake(ProjectTwice) run_cmake(VersionAndLanguagesEmpty) run_cmake(VersionEmpty) -- cgit v0.12 From 8e342a6637d7d3d63549bfa6ae98efe6deee8390 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 26 Mar 2021 10:52:30 -0400 Subject: FindIntl: Fix detection of intl built in to C library Since commit c30d06b7e6 (FindIntl: Add imported target, 2020-10-06, v3.20.0-rc1~687^2) we use `check_symbol_exists` to check whether the `intl` library is built in to the C library. On some platforms the tested symbols are provided as macros so the check passes without linking any symbol. Instead, check whether a sample source file both compiles and links. Fixes: #21979 --- Modules/FindIntl.cmake | 101 ++++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 44 deletions(-) diff --git a/Modules/FindIntl.cmake b/Modules/FindIntl.cmake index eaeefef..038f4da 100644 --- a/Modules/FindIntl.cmake +++ b/Modules/FindIntl.cmake @@ -61,24 +61,11 @@ The following cache variables may also be set: The libintl library (if any) -.. variable:: Intl_HAVE_GETTEXT_BUILTIN +.. variable:: Intl_IS_BUILT_IN .. versionadded:: 3.20 - True if gettext is in the C library - -.. variable:: Intl_HAVE_DCGETTEXT_BUILTIN - - .. versionadded:: 3.20 - - True if dcgettext is in the C library - -.. variable:: Intl_IS_BUILTIN - - .. versionadded:: 3.20 - - whether intl is a part of the C library determined from the result of - Intl_HAVE_GETTEXT_BUILTIN and Intl_HAVE_DCGETTEXT_BUILTIN + whether ``intl`` is a part of the C library. .. note:: On some platforms, such as Linux with GNU libc, the gettext @@ -96,40 +83,59 @@ The following cache variables may also be set: #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) -include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake) - -# Check if we have libintl is a part of libc -cmake_push_check_state(RESET) -set(CMAKE_REQUIRED_QUIET TRUE) -check_symbol_exists(gettext libintl.h Intl_HAVE_GETTEXT_BUILTIN) -check_symbol_exists(dcgettext libintl.h Intl_HAVE_DCGETTEXT_BUILTIN) # redundant check -cmake_pop_check_state() - -if(Intl_HAVE_GETTEXT_BUILTIN AND Intl_HAVE_DCGETTEXT_BUILTIN) - set(Intl_IS_BUILTIN TRUE) +if(CMAKE_C_COMPILER_LOADED) + include(${CMAKE_CURRENT_LIST_DIR}/CheckCSourceCompiles.cmake) +elseif(CMAKE_CXX_COMPILER_LOADED) + include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSourceCompiles.cmake) else() - set(Intl_IS_BUILTIN FALSE) + # If neither C nor CXX are loaded, implicit intl makes no sense. + set(Intl_IS_BUILT_IN FALSE) endif() -# Find include directory -find_path(Intl_INCLUDE_DIR - NAMES "libintl.h" - DOC "libintl include directory") -mark_as_advanced(Intl_INCLUDE_DIR) +# Check if Intl is built in to the C library. +if(NOT DEFINED Intl_IS_BUILT_IN) + if(NOT DEFINED Intl_INCLUDE_DIR AND NOT DEFINED Intl_LIBRARY) + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_QUIET TRUE) + set(Intl_IMPLICIT_TEST_CODE [[ +#include +int main(void) { + gettext(""); + dgettext("", ""); + dcgettext("", "", 0); + return 0; +} +]]) + if(CMAKE_C_COMPILER_LOADED) + check_c_source_compiles("${Intl_IMPLICIT_TEST_CODE}" Intl_IS_BUILT_IN) + else() + check_cxx_source_compiles("${Intl_IMPLICIT_TEST_CODE}" Intl_IS_BUILT_IN) + endif() + cmake_pop_check_state() + else() + set(Intl_IS_BUILT_IN FALSE) + endif() +endif() -# Find all Intl libraries -if(NOT Intl_IS_BUILTIN) - set(Intl_LIBRARY_NAMES "intl" "libintl") +set(_Intl_REQUIRED_VARS) +if(Intl_IS_BUILT_IN) + set(_Intl_REQUIRED_VARS _Intl_IS_BUILT_IN_MSG) + set(_Intl_IS_BUILT_IN_MSG "built in to C library") else() - set(Intl_LIBRARY_NAMES "c") -endif() + set(_Intl_REQUIRED_VARS Intl_LIBRARY Intl_INCLUDE_DIR) + + find_path(Intl_INCLUDE_DIR + NAMES "libintl.h" + DOC "libintl include directory") + mark_as_advanced(Intl_INCLUDE_DIR) -find_library(Intl_LIBRARY ${Intl_LIBRARY_NAMES} NAMES_PER_DIR - DOC "intl library (potentially the C library)") -mark_as_advanced(Intl_LIBRARY) + find_library(Intl_LIBRARY "intl" "libintl" NAMES_PER_DIR + DOC "libintl libraries (if not in the C library)") + mark_as_advanced(Intl_LIBRARY) +endif() # NOTE: glibc's libintl.h does not define LIBINTL_VERSION -if(Intl_INCLUDE_DIR AND NOT Intl_IS_BUILTIN) +if(Intl_INCLUDE_DIR AND EXISTS "${Intl_INCLUDE_DIR}/libintl.h") file(STRINGS ${Intl_INCLUDE_DIR}/libintl.h Intl_VERSION_DEFINE REGEX "LIBINTL_VERSION (.*)") if(Intl_VERSION_DEFINE MATCHES "(0x[A-Fa-f0-9]+)") @@ -152,13 +158,20 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Intl FOUND_VAR Intl_FOUND - REQUIRED_VARS Intl_LIBRARY Intl_INCLUDE_DIR + REQUIRED_VARS ${_Intl_REQUIRED_VARS} VERSION_VAR Intl_VERSION FAIL_MESSAGE "Failed to find Gettext libintl") +unset(_Intl_REQUIRED_VARS) +unset(_Intl_IS_BUILT_IN_MSG) if(Intl_FOUND) - set(Intl_INCLUDE_DIRS "${Intl_INCLUDE_DIR}") - set(Intl_LIBRARIES "${Intl_LIBRARY}") + if(Intl_IS_BUILT_IN) + set(Intl_INCLUDE_DIRS "") + set(Intl_LIBRARIES "") + else() + set(Intl_INCLUDE_DIRS "${Intl_INCLUDE_DIR}") + set(Intl_LIBRARIES "${Intl_LIBRARY}") + endif() if(NOT TARGET Intl::Intl) add_library(Intl::Intl INTERFACE IMPORTED) set_target_properties(Intl::Intl PROPERTIES -- cgit v0.12 From 1d8e3a1e770ae4aed921eefffaceb70b1fd73701 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 26 Mar 2021 16:27:18 +0100 Subject: UseSWIG: Use standard library name conventions for csharp language Fixes: #21542 --- Help/manual/cmake-policies.7.rst | 3 ++- Help/policy/CMP0122.rst | 17 +++++++++++++++++ Help/release/dev/UseSWIG-csharp.rst | 5 +++++ Modules/UseSWIG.cmake | 19 ++++++++++++++++++- Source/cmPolicies.h | 6 +++++- Tests/RunCMake/UseSWIG/CMP0122-NEW-check.cmake | 10 ++++++++++ Tests/RunCMake/UseSWIG/CMP0122-NEW.cmake | 2 ++ Tests/RunCMake/UseSWIG/CMP0122-OLD-check.cmake | 10 ++++++++++ Tests/RunCMake/UseSWIG/CMP0122-OLD.cmake | 2 ++ Tests/RunCMake/UseSWIG/CMP0122-WARN-stderr.txt | 10 ++++++++++ Tests/RunCMake/UseSWIG/CMP0122-WARN.cmake | 1 + Tests/RunCMake/UseSWIG/CMP0122-common.cmake | 12 ++++++++++++ Tests/RunCMake/UseSWIG/RunCMakeTest.cmake | 4 ++++ 13 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 Help/policy/CMP0122.rst create mode 100644 Help/release/dev/UseSWIG-csharp.rst create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-NEW-check.cmake create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-NEW.cmake create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-OLD-check.cmake create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-OLD.cmake create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-WARN-stderr.txt create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-WARN.cmake create mode 100644 Tests/RunCMake/UseSWIG/CMP0122-common.cmake diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index f103c50..5dfa894 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,7 +57,8 @@ Policies Introduced by CMake 3.21 .. toctree:: :maxdepth: 1 - CMP0121: The list command detects invalid indicies + CMP0122: UseSWIG use standard library name conventions for csharp language. + CMP0121: The list command detects invalid indicies. Policies Introduced by CMake 3.20 ================================= diff --git a/Help/policy/CMP0122.rst b/Help/policy/CMP0122.rst new file mode 100644 index 0000000..1ff8c48 --- /dev/null +++ b/Help/policy/CMP0122.rst @@ -0,0 +1,17 @@ +CMP0122 +------- + +.. versionadded:: 3.21 + +:module:`UseSWIG` use library name conventions for ``CSharp`` language. + +Starting with CMake 3.21, :module:`UseSWIG` generates now a library using +default naming conventions. This policy provides compatibility with projects +that expect the legacy behavior. + +This policy was introduced in CMake version 3.21. CMake version +|release| warns when the policy is not set and uses ``OLD`` behavior. +Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` +explicitly. + +.. include:: DEPRECATED.txt diff --git a/Help/release/dev/UseSWIG-csharp.rst b/Help/release/dev/UseSWIG-csharp.rst new file mode 100644 index 0000000..dbbeaf1 --- /dev/null +++ b/Help/release/dev/UseSWIG-csharp.rst @@ -0,0 +1,5 @@ +UseSWIG-csharp +-------------- + +* The :module:`UseSWIG` module use now standard library name conventions for + ``CSharp`` language. See policy :policy:`CMP0122`. diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b1e0576..c7d8346 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -38,7 +38,13 @@ Defines the following command for use with ``SWIG``: .. versionchanged:: 3.15 Alternate library name (set with the :prop_tgt:`OUTPUT_NAME` property, - for example) will be passed on to Python and CSharp wrapper libraries. + for example) will be passed on to ``Python`` and ``CSharp`` wrapper + libraries. + + .. versionchanged:: 3.21 + Generated library use standard naming conventions for ``CSharp`` language + when policy :policy:`CMP0122` is set to ``NEW``. Otherwise, the legacy + behavior is applied. .. note:: @@ -950,6 +956,17 @@ function(SWIG_ADD_LIBRARY name) endif () elseif (swig_lowercase_language STREQUAL "fortran") # Do *not* override the target's library prefix + elseif (swig_lowercase_language STREQUAL "csharp") + cmake_policy(GET CMP0122 csharp_naming_policy) + if (csharp_naming_policy STREQUAL "NEW") + # Do *not* override the target's library prefix + else() + if (NOT csharp_naming_policy) + cmake_policy(GET_WARNING CMP0122 _cmp0122_warning) + message(AUTHOR_WARNING "${_cmp0122_warning}\n") + endif() + set_target_properties (${target_name} PROPERTIES PREFIX "") + endif() else() # assume empty prefix because we expect the module to be dynamically loaded set_target_properties (${target_name} PROPERTIES PREFIX "") diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 9295a3f..d546b6e 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -362,7 +362,11 @@ class cmMakefile; cmPolicies::WARN) \ SELECT(POLICY, CMP0121, \ "The list() command now validates parsing of index arguments.", 3, \ - 21, 0, cmPolicies::WARN) + 21, 0, cmPolicies::WARN) \ + SELECT( \ + POLICY, CMP0122, \ + "UseSWIG use standard library name conventions for csharp language.", 3, \ + 21, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Tests/RunCMake/UseSWIG/CMP0122-NEW-check.cmake b/Tests/RunCMake/UseSWIG/CMP0122-NEW-check.cmake new file mode 100644 index 0000000..a26c278 --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-NEW-check.cmake @@ -0,0 +1,10 @@ + +cmake_policy(VERSION 3.1) + +file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CMP0122-library-name.txt" prefixes) + +list(GET prefixes 0 std_prefix) +list(GET prefixes 1 lib_prefix) +if (NOT std_prefix STREQUAL lib_prefix) + string (APPEND RunCMake_TEST_FAILED "\nFound prefix: '${lib_prefix}', expected: '${std_prefix}'.") +endif() diff --git a/Tests/RunCMake/UseSWIG/CMP0122-NEW.cmake b/Tests/RunCMake/UseSWIG/CMP0122-NEW.cmake new file mode 100644 index 0000000..fecb7db --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0122 NEW) +include(CMP0122-common.cmake) diff --git a/Tests/RunCMake/UseSWIG/CMP0122-OLD-check.cmake b/Tests/RunCMake/UseSWIG/CMP0122-OLD-check.cmake new file mode 100644 index 0000000..01657d0 --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-OLD-check.cmake @@ -0,0 +1,10 @@ + +cmake_policy(VERSION 3.1) + +file(STRINGS "${RunCMake_TEST_BINARY_DIR}/CMP0122-library-name.txt" prefixes) + +list(GET prefixes 1 lib_prefix) +if (lib_prefix) + # prefix must be empty + string (APPEND RunCMake_TEST_FAILED "\nFound unexpected prefix: '${lib_prefix}'.") +endif() diff --git a/Tests/RunCMake/UseSWIG/CMP0122-OLD.cmake b/Tests/RunCMake/UseSWIG/CMP0122-OLD.cmake new file mode 100644 index 0000000..a787b68 --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0122 OLD) +include(CMP0122-common.cmake) diff --git a/Tests/RunCMake/UseSWIG/CMP0122-WARN-stderr.txt b/Tests/RunCMake/UseSWIG/CMP0122-WARN-stderr.txt new file mode 100644 index 0000000..37c4fbd --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-WARN-stderr.txt @@ -0,0 +1,10 @@ +CMake Warning \(dev\) at .*/Modules/UseSWIG.cmake:[0-9]+ \(message\): + Policy CMP0122 is not set: UseSWIG use standard library name conventions + for csharp language\. Run "cmake --help-policy CMP0122" for policy details\. + Use the cmake_policy command to set the policy and suppress this warning\. + +Call Stack \(most recent call first\): + CMP0122-common.cmake:9 \(swig_add_library\) + CMP0122-WARN.cmake:1 \(include\) + CMakeLists.txt:3 \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/UseSWIG/CMP0122-WARN.cmake b/Tests/RunCMake/UseSWIG/CMP0122-WARN.cmake new file mode 100644 index 0000000..5d571aa --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-WARN.cmake @@ -0,0 +1 @@ +include(CMP0122-common.cmake) diff --git a/Tests/RunCMake/UseSWIG/CMP0122-common.cmake b/Tests/RunCMake/UseSWIG/CMP0122-common.cmake new file mode 100644 index 0000000..be880ec --- /dev/null +++ b/Tests/RunCMake/UseSWIG/CMP0122-common.cmake @@ -0,0 +1,12 @@ + +cmake_policy(SET CMP0078 NEW) +cmake_policy(SET CMP0086 NEW) + +set(SWIG_EXECUTABLE "swig") +set(SWIG_DIR "/swig") +include(UseSWIG) + +swig_add_library(example LANGUAGE csharp TYPE SHARED SOURCES example.i) + +file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/CMP0122-library-name.txt" + CONTENT "${CMAKE_SHARED_LIBRARY_PREFIX}\n$\n") diff --git a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake index 6acf719..c7a118f 100644 --- a/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake +++ b/Tests/RunCMake/UseSWIG/RunCMakeTest.cmake @@ -23,3 +23,7 @@ if (CMake_TEST_FindPython) run_cmake_target(CMP0086-NEW build example) endif() + +run_cmake(CMP0122-WARN) +run_cmake(CMP0122-OLD) +run_cmake(CMP0122-NEW) -- cgit v0.12 From a43783a08d621153daec4511474f939484b2b952 Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Wed, 24 Mar 2021 18:21:38 +1100 Subject: CPackIFW: Fix parsing of name and version in component DEPENDS The DEPENDS or DEPENDENCIES arguments in a call to cpack_ifw_configure_component() or cpack_ifw_configure_component_group() specify a name and optionally a version constraint as a single string. QtIFW also allows a colon (requires QtIFW 3.1 or later) or a hyphen to separate the name and version. The version may optionally contain a leading operator, with = being assumed when no operator is present. The previous code was not handling : as a separator at all and was erroneously dropping the version part when no operator was given. Fix both of those non-conforming behaviors and also warn if trying to use a hyphen in a name with a QtIFW version that isn't recent enough to support it. Fixes: #21697 --- Help/release/dev/ifw-default-version-operator.rst | 7 ++ Modules/CPackIFW.cmake | 10 ++ Source/CPack/IFW/cmCPackIFWPackage.cxx | 109 +++++++++++++++------- 3 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 Help/release/dev/ifw-default-version-operator.rst diff --git a/Help/release/dev/ifw-default-version-operator.rst b/Help/release/dev/ifw-default-version-operator.rst new file mode 100644 index 0000000..4aeace2 --- /dev/null +++ b/Help/release/dev/ifw-default-version-operator.rst @@ -0,0 +1,7 @@ +ifw-default-version-operator +---------------------------- + +* Names given as ``DEPENDS`` or ``DEPENDENCIES`` arguments to + :command:`cpack_ifw_configure_component` or + :command:`cpack_ifw_configure_component_group` may now contain hyphens. + This requires QtIFW 3.1 or later. diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake index d57cf18..2087a51 100644 --- a/Modules/CPackIFW.cmake +++ b/Modules/CPackIFW.cmake @@ -125,6 +125,11 @@ The module defines the following commands: list of dependency component or component group identifiers in QtIFW style. + .. versionadded:: 3.21 + + Component or group names listed as dependencies may contain hyphens. + This requires QtIFW 3.1 or later. + ``AUTO_DEPEND_ON`` .. versionadded:: 3.8 @@ -260,6 +265,11 @@ The module defines the following commands: list of dependency component or component group identifiers in QtIFW style. + .. versionadded:: 3.21 + + Component or group names listed as dependencies may contain hyphens. + This requires QtIFW 3.1 or later. + ``AUTO_DEPEND_ON`` .. versionadded:: 3.8 diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index 5191c96..1429c46 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -7,6 +7,8 @@ #include #include +#include + #include "cmCPackComponentGroup.h" #include "cmCPackIFWCommon.h" #include "cmCPackIFWGenerator.h" @@ -30,44 +32,67 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct() = default; cmCPackIFWPackage::DependenceStruct::DependenceStruct( const std::string& dependence) { - // Search compare section + // Preferred format is name and version are separated by a colon (:), but + // note that this is only supported with QtIFW 3.1 or later. Backward + // compatibility allows a hyphen (-) as a separator instead, but names then + // cannot contain a hyphen. size_t pos; - if ((pos = dependence.find("<=")) != std::string::npos) { - this->Compare.Type = cmCPackIFWPackage::CompareLessOrEqual; - this->Compare.Value = dependence.substr(pos + 2); - } else if ((pos = dependence.find(">=")) != std::string::npos) { - this->Compare.Type = cmCPackIFWPackage::CompareGreaterOrEqual; - this->Compare.Value = dependence.substr(pos + 2); - } else if ((pos = dependence.find('<')) != std::string::npos) { - this->Compare.Type = cmCPackIFWPackage::CompareLess; - this->Compare.Value = dependence.substr(pos + 1); - } else if ((pos = dependence.find('=')) != std::string::npos) { - this->Compare.Type = cmCPackIFWPackage::CompareEqual; - this->Compare.Value = dependence.substr(pos + 1); - } else if ((pos = dependence.find('>')) != std::string::npos) { - this->Compare.Type = cmCPackIFWPackage::CompareGreater; - this->Compare.Value = dependence.substr(pos + 1); - } else if ((pos = dependence.find('-')) != std::string::npos) { - this->Compare.Type = cmCPackIFWPackage::CompareNone; - this->Compare.Value = dependence.substr(pos + 1); - } - size_t dashPos = dependence.find('-'); - if (dashPos != std::string::npos) { - pos = dashPos; - } - this->Name = dependence.substr(0, pos); + if ((pos = dependence.find(':')) == std::string::npos) { + pos = dependence.find('-'); + } + + if (pos != std::string::npos) { + this->Name = dependence.substr(0, pos); + ++pos; + if (pos == dependence.size()) { + // Nothing after the separator. Treat this as no version constraint. + return; + } + + const auto versionPart = + cm::string_view(dependence.data() + pos, dependence.size() - pos); + + if (cmHasLiteralPrefix(versionPart, "<=")) { + this->Compare.Type = cmCPackIFWPackage::CompareLessOrEqual; + this->Compare.Value = std::string(versionPart.substr(2)); + } else if (cmHasLiteralPrefix(versionPart, ">=")) { + this->Compare.Type = cmCPackIFWPackage::CompareGreaterOrEqual; + this->Compare.Value = std::string(versionPart.substr(2)); + } else if (cmHasPrefix(versionPart, '<')) { + this->Compare.Type = cmCPackIFWPackage::CompareLess; + this->Compare.Value = std::string(versionPart.substr(1)); + } else if (cmHasPrefix(versionPart, '=')) { + this->Compare.Type = cmCPackIFWPackage::CompareEqual; + this->Compare.Value = std::string(versionPart.substr(1)); + } else if (cmHasPrefix(versionPart, '>')) { + this->Compare.Type = cmCPackIFWPackage::CompareGreater; + this->Compare.Value = std::string(versionPart.substr(1)); + } else { + // We found no operator but a version specification is still expected to + // follow. The default behavior is to treat this the same as =. We + // explicitly record that as our type (it simplifies our logic a little + // and is also clearer). + this->Compare.Type = cmCPackIFWPackage::CompareEqual; + this->Compare.Value = std::string(versionPart); + } + } else { + this->Name = dependence; + } } std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const { - if (this->Compare.Type == cmCPackIFWPackage::CompareNone) { - return this->Name; - } - std::string result = this->Name; - - if (this->Compare.Type != cmCPackIFWPackage::CompareNone || - !this->Compare.Value.empty()) { + if (this->Name.find('-') != std::string::npos) { + // When a name contains a hyphen, we must use a colon after the name to + // prevent the hyphen from being parsed by QtIFW as the separator between + // the name and the version. Note that a colon is only supported with + // QtIFW 3.1 or later. + result += ":"; + } else if (this->Compare.Type != cmCPackIFWPackage::CompareNone || + !this->Compare.Value.empty()) { + // No hyphen in the name and we know a version part will follow. Use a + // hyphen as a separator since this works for all QtIFW versions. result += "-"; } @@ -609,6 +634,9 @@ void cmCPackIFWPackage::GeneratePackageFile() } // Dependencies + const bool hyphensInNamesUnsupported = this->Generator && + !this->Generator->FrameworkVersion.empty() && this->IsVersionLess("3.1"); + bool warnUnsupportedNames = false; std::set compDepSet; for (DependenceStruct* ad : this->AlienDependencies) { compDepSet.insert(*ad); @@ -620,9 +648,13 @@ void cmCPackIFWPackage::GeneratePackageFile() if (!compDepSet.empty()) { std::ostringstream dependencies; auto it = compDepSet.begin(); + warnUnsupportedNames |= + hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos; dependencies << it->NameWithCompare(); ++it; while (it != compDepSet.end()) { + warnUnsupportedNames |= + hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos; dependencies << "," << it->NameWithCompare(); ++it; } @@ -638,15 +670,28 @@ void cmCPackIFWPackage::GeneratePackageFile() if (!compAutoDepSet.empty()) { std::ostringstream dependencies; auto it = compAutoDepSet.begin(); + warnUnsupportedNames |= + hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos; dependencies << it->NameWithCompare(); ++it; while (it != compAutoDepSet.end()) { + warnUnsupportedNames |= + hyphensInNamesUnsupported && it->Name.find('-') != std::string::npos; dependencies << "," << it->NameWithCompare(); ++it; } xout.Element("AutoDependOn", dependencies.str()); } + if (warnUnsupportedNames) { + cmCPackIFWLogger( + WARNING, + "The dependencies for component \"" + << this->Name << "\" specify names that contain hyphens. " + << "This requires QtIFW 3.1 or later, but you are using version " + << this->Generator->FrameworkVersion << std::endl); + } + // Licenses (copy to meta dir) std::vector licenses = this->Licenses; for (size_t i = 1; i < licenses.size(); i += 2) { -- cgit v0.12 From b22c800604e22a0ffdb13aa5fd4cfb7ee26896a4 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 27 Mar 2021 00:01:17 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fa9d567..dc4fcae 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210326) +set(CMake_VERSION_PATCH 20210327) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 44ad3f0b7f7e0aaf96e5cfd672d07a70e1b76410 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 20 Mar 2021 16:53:14 +1100 Subject: ctest: Support multiple -L and -LE options to mean "AND" Fixes: #21087 --- Help/manual/ctest.1.rst | 50 ++++++++++++++- Source/CTest/cmCTestGenericHandler.cxx | 52 ++++++++++++---- Source/CTest/cmCTestGenericHandler.h | 32 ++++++++++ Source/CTest/cmCTestTestCommand.cxx | 6 +- Source/CTest/cmCTestTestHandler.cxx | 103 ++++++++++++++++++------------- Source/CTest/cmCTestTestHandler.h | 8 +-- Source/cmCTest.cxx | 29 ++++++--- Source/cmCTest.h | 2 + Source/ctest.cxx | 10 +-- Tests/CMakeTests/CMakeLists.txt | 1 + Tests/CTestTestLabelRegExp/test.cmake.in | 4 ++ Tests/QtAutogen/TestMacros.cmake | 1 + Tests/QtAutogen/Tests.cmake | 2 + Tests/RunCMake/CMakeLists.txt | 4 ++ 14 files changed, 222 insertions(+), 82 deletions(-) diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst index 175359d..68409e1 100644 --- a/Help/manual/ctest.1.rst +++ b/Help/manual/ctest.1.rst @@ -155,7 +155,10 @@ Options Run tests with labels matching regular expression. This option tells CTest to run only the tests whose labels match the - given regular expression. + given regular expression. When more than one ``-L`` option is given, + a test will only be run if each regular expression matches at least one + of the test's labels (i.e. the multiple ``-L`` labels form an ``AND`` + relationship). See `Label Matching`_. ``-R , --tests-regex `` Run tests matching regular expression. @@ -173,7 +176,10 @@ Options Exclude tests with labels matching regular expression. This option tells CTest to NOT run the tests whose labels match the - given regular expression. + given regular expression. When more than one ``-LE`` option is given, + a test will only be excluded if each regular expression matches at least one + of the test's labels (i.e. the multiple ``-LE`` labels form an ``AND`` + relationship). See `Label Matching`_. ``-FA , --fixture-exclude-any `` Exclude fixtures matching ```` from automatically adding any tests to @@ -398,6 +404,46 @@ Specify the directory in which to look for tests. .. include:: OPTIONS_HELP.txt +.. _`Label Matching`: + +Label Matching +============== + +Tests may have labels attached to them. Tests may be included +or excluded from a test run by filtering on the labels. +Each individual filter is a regular expression applied to +the labels attached to a test. + +When ``-L`` is used, in order for a test to be included in a +test run, each regular expression must match at least one +label. Using more than one ``-L`` option means "match **all** +of these". + +The ``-LE`` option works just like ``-L``, but excludes tests +rather than including them. A test is excluded if each regular +expression matches at least one label. + +If a test has no labels attached to it, then ``-L`` will never +include that test, and ``-LE`` will never exclude that test. +As an example of tests with labels, consider five tests, +with the following labels: + +* *test1* has labels *tuesday* and *production* +* *test2* has labels *tuesday* and *test* +* *test3* has labels *wednesday* and *production* +* *test4* has label *wednesday* +* *test5* has labels *friday* and *test* + +Running ``ctest`` with ``-L tuesday -L test`` will select *test2*, which has +both labels. Running CTest with ``-L test`` will select *test2* and +*test5*, because both of them have a label that matches that regular +expression. + +Because the matching works with regular expressions, take note that +running CTest with ``-L es`` will match all five tests. +To select the *tuesday* and *wednesday* tests together, use a single +regular expression that matches either of them, like ``-L "tue|wed"``. + .. _`Label and Subproject Summary`: Label and Subproject Summary diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 91818bb..cc756d7 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -21,32 +21,47 @@ cmCTestGenericHandler::cmCTestGenericHandler() cmCTestGenericHandler::~cmCTestGenericHandler() = default; -void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) +/* Modify the given `map`, setting key `op` to `value` if `value` + * is non-null, otherwise removing key `op` (if it exists). + */ +static void SetMapValue(cmCTestGenericHandler::t_StringToString& map, + const std::string& op, const char* value) { if (!value) { - auto remit = this->Options.find(op); - if (remit != this->Options.end()) { - this->Options.erase(remit); - } + map.erase(op); return; } - this->Options[op] = value; + map[op] = value; +} + +void cmCTestGenericHandler::SetOption(const std::string& op, const char* value) +{ + SetMapValue(this->Options, op, value); } void cmCTestGenericHandler::SetPersistentOption(const std::string& op, const char* value) { this->SetOption(op, value); - if (!value) { - auto remit = this->PersistentOptions.find(op); - if (remit != this->PersistentOptions.end()) { - this->PersistentOptions.erase(remit); - } - return; + SetMapValue(this->PersistentOptions, op, value); +} + +void cmCTestGenericHandler::AddMultiOption(const std::string& op, + const std::string& value) +{ + if (!value.empty()) { + this->MultiOptions[op].emplace_back(value); } +} - this->PersistentOptions[op] = value; +void cmCTestGenericHandler::AddPersistentMultiOption(const std::string& op, + const std::string& value) +{ + if (!value.empty()) { + this->MultiOptions[op].emplace_back(value); + this->PersistentMultiOptions[op].emplace_back(value); + } } void cmCTestGenericHandler::Initialize() @@ -68,6 +83,17 @@ const char* cmCTestGenericHandler::GetOption(const std::string& op) return remit->second.c_str(); } +std::vector cmCTestGenericHandler::GetMultiOption( + const std::string& optionName) const +{ + // Avoid inserting a key, which MultiOptions[op] would do. + auto remit = this->MultiOptions.find(optionName); + if (remit == this->MultiOptions.end()) { + return {}; + } + return remit->second; +} + bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part, const char* name, cmGeneratedFileStream& xofs) diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 89d7596..6f44545 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -72,11 +72,41 @@ public: virtual ~cmCTestGenericHandler(); using t_StringToString = std::map; + using t_StringToMultiString = + std::map>; + /** + * Options collect a single value from flags; passing the + * flag multiple times on the command-line *overwrites* values, + * and only the last one specified counts. Set an option to + * nullptr to "unset" it. + * + * The value is stored as a string. The values set for single + * and multi-options (see below) live in different spaces, + * so calling a single-getter for a key that has only been set + * as a multi-value will return nullptr. + */ void SetPersistentOption(const std::string& op, const char* value); void SetOption(const std::string& op, const char* value); const char* GetOption(const std::string& op); + /** + * Multi-Options collect one or more values from flags; passing + * the flag multiple times on the command-line *adds* values, + * rather than overwriting the previous values. + * + * Adding an empty value does nothing. + * + * The value is stored as a vector of strings. The values set for single + * (see above) and multi-options live in different spaces, + * so calling a multi-getter for a key that has only been set + * as a single-value will return an empty vector. + */ + void AddPersistentMultiOption(const std::string& optionName, + const std::string& value); + void AddMultiOption(const std::string& optionName, const std::string& value); + std::vector GetMultiOption(const std::string& op) const; + void SetCommand(cmCTestCommand* command) { this->Command = command; } void SetSubmitIndex(int idx) { this->SubmitIndex = idx; } @@ -100,6 +130,8 @@ protected: cmCTest* CTest; t_StringToString Options; t_StringToString PersistentOptions; + t_StringToMultiString MultiOptions; + t_StringToMultiString PersistentMultiOptions; t_StringToString LogFileNames; cmCTestCommand* Command; diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 4403733..886c263 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -73,11 +73,11 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() handler->SetOption("IncludeRegularExpression", this->Include.c_str()); } if (!this->ExcludeLabel.empty()) { - handler->SetOption("ExcludeLabelRegularExpression", - this->ExcludeLabel.c_str()); + handler->AddMultiOption("ExcludeLabelRegularExpression", + this->ExcludeLabel); } if (!this->IncludeLabel.empty()) { - handler->SetOption("LabelRegularExpression", this->IncludeLabel.c_str()); + handler->AddMultiOption("LabelRegularExpression", this->IncludeLabel); } if (!this->ExcludeFixture.empty()) { handler->SetOption("ExcludeFixtureRegularExpression", diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 42c4d5e..742e78a 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -287,8 +287,6 @@ cmCTestTestHandler::cmCTestTestHandler() { this->UseUnion = false; - this->UseIncludeLabelRegExpFlag = false; - this->UseExcludeLabelRegExpFlag = false; this->UseIncludeRegExpFlag = false; this->UseExcludeRegExpFlag = false; this->UseExcludeRegExpFirst = false; @@ -327,13 +325,11 @@ void cmCTestTestHandler::Initialize() this->TestsToRun.clear(); - this->UseIncludeLabelRegExpFlag = false; - this->UseExcludeLabelRegExpFlag = false; this->UseIncludeRegExpFlag = false; this->UseExcludeRegExpFlag = false; this->UseExcludeRegExpFirst = false; - this->IncludeLabelRegularExpression = ""; - this->ExcludeLabelRegularExpression = ""; + this->IncludeLabelRegularExpressions.clear(); + this->ExcludeLabelRegularExpressions.clear(); this->IncludeRegExp.clear(); this->ExcludeRegExp.clear(); this->ExcludeFixtureRegExp.clear(); @@ -479,6 +475,22 @@ int cmCTestTestHandler::ProcessHandler() return 0; } +/* Given a multi-option value `parts`, compile those parts into + * regular expressions in `expressions`. Skip empty values. + * Returns true if there were any expressions. + */ +static bool BuildLabelRE(const std::vector& parts, + std::vector& expressions) +{ + expressions.clear(); + for (const auto& p : parts) { + if (!p.empty()) { + expressions.emplace_back(p); + } + } + return !expressions.empty(); +} + bool cmCTestTestHandler::ProcessOptions() { // Update internal data structure from generic one @@ -519,18 +531,11 @@ bool cmCTestTestHandler::ProcessOptions() this->CTest->SetStopOnFailure(true); } - const char* val; - val = this->GetOption("LabelRegularExpression"); - if (val) { - this->UseIncludeLabelRegExpFlag = true; - this->IncludeLabelRegExp = val; - } - val = this->GetOption("ExcludeLabelRegularExpression"); - if (val) { - this->UseExcludeLabelRegExpFlag = true; - this->ExcludeLabelRegExp = val; - } - val = this->GetOption("IncludeRegularExpression"); + BuildLabelRE(this->GetMultiOption("LabelRegularExpression"), + this->IncludeLabelRegularExpressions); + BuildLabelRE(this->GetMultiOption("ExcludeLabelRegularExpression"), + this->ExcludeLabelRegularExpressions); + const char* val = this->GetOption("IncludeRegularExpression"); if (val) { this->UseIncludeRegExp(); this->SetIncludeRegExp(val); @@ -763,10 +768,40 @@ void cmCTestTestHandler::PrintLabelOrSubprojectSummary(bool doSubProject) cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet); } +/** + * Check if the labels (from a test) match all the expressions. + * + * Each of the RE's must match at least one label + * (e.g. all of the REs must match **some** label, + * in order for the filter to apply to the test). + */ +static bool MatchLabelsAgainstFilterRE( + const std::vector& labels, + const std::vector& expressions) +{ + for (const auto& re : expressions) { + // check to see if the label regular expression matches + bool found = false; // assume it does not match + cmsys::RegularExpressionMatch match; + // loop over all labels and look for match + for (std::string const& l : labels) { + if (re.find(l.c_str(), match)) { + found = true; + break; + } + } + // if no match was found, exclude the test + if (!found) { + return false; + } + } + return true; +} + void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it) { // if not using Labels to filter then return - if (!this->UseIncludeLabelRegExpFlag) { + if (this->IncludeLabelRegularExpressions.empty()) { return; } // if there are no labels and we are filtering by labels @@ -775,16 +810,9 @@ void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it) it.IsInBasedOnREOptions = false; return; } - // check to see if the label regular expression matches - bool found = false; // assume it does not match - // loop over all labels and look for match - for (std::string const& l : it.Labels) { - if (this->IncludeLabelRegularExpression.find(l)) { - found = true; - } - } // if no match was found, exclude the test - if (!found) { + if (!MatchLabelsAgainstFilterRE(it.Labels, + this->IncludeLabelRegularExpressions)) { it.IsInBasedOnREOptions = false; } } @@ -792,7 +820,7 @@ void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it) void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it) { // if not using Labels to filter then return - if (!this->UseExcludeLabelRegExpFlag) { + if (this->ExcludeLabelRegularExpressions.empty()) { return; } // if there are no labels and we are excluding by labels @@ -800,16 +828,9 @@ void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it) if (it.Labels.empty()) { return; } - // check to see if the label regular expression matches - bool found = false; // assume it does not match - // loop over all labels and look for match - for (std::string const& l : it.Labels) { - if (this->ExcludeLabelRegularExpression.find(l)) { - found = true; - } - } // if match was found, exclude the test - if (found) { + if (MatchLabelsAgainstFilterRE(it.Labels, + this->ExcludeLabelRegularExpressions)) { it.IsInBasedOnREOptions = false; } } @@ -1704,12 +1725,6 @@ bool cmCTestTestHandler::ParseResourceGroupsProperty( bool cmCTestTestHandler::GetListOfTests() { - if (!this->IncludeLabelRegExp.empty()) { - this->IncludeLabelRegularExpression.compile(this->IncludeLabelRegExp); - } - if (!this->ExcludeLabelRegExp.empty()) { - this->ExcludeLabelRegularExpression.compile(this->ExcludeLabelRegExp); - } if (!this->IncludeRegExp.empty()) { this->IncludeTestsRegularExpression.compile(this->IncludeRegExp); } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index aa29eeb..6fa18a9 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -320,20 +320,16 @@ private: std::vector TestsToRun; - bool UseIncludeLabelRegExpFlag; - bool UseExcludeLabelRegExpFlag; bool UseIncludeRegExpFlag; bool UseExcludeRegExpFlag; bool UseExcludeRegExpFirst; - std::string IncludeLabelRegExp; - std::string ExcludeLabelRegExp; std::string IncludeRegExp; std::string ExcludeRegExp; std::string ExcludeFixtureRegExp; std::string ExcludeFixtureSetupRegExp; std::string ExcludeFixtureCleanupRegExp; - cmsys::RegularExpression IncludeLabelRegularExpression; - cmsys::RegularExpression ExcludeLabelRegularExpression; + std::vector IncludeLabelRegularExpressions; + std::vector ExcludeLabelRegularExpressions; cmsys::RegularExpression IncludeTestsRegularExpression; cmsys::RegularExpression ExcludeTestsRegularExpression; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 4228d30..0dfd1bd 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2108,17 +2108,17 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, } else if (this->CheckArgument(arg, "-L"_s, "--label-regex") && i < args.size() - 1) { i++; - this->GetTestHandler()->SetPersistentOption("LabelRegularExpression", - args[i].c_str()); - this->GetMemCheckHandler()->SetPersistentOption("LabelRegularExpression", - args[i].c_str()); + this->GetTestHandler()->AddPersistentMultiOption("LabelRegularExpression", + args[i]); + this->GetMemCheckHandler()->AddPersistentMultiOption( + "LabelRegularExpression", args[i]); } else if (this->CheckArgument(arg, "-LE"_s, "--label-exclude") && i < args.size() - 1) { i++; - this->GetTestHandler()->SetPersistentOption( - "ExcludeLabelRegularExpression", args[i].c_str()); - this->GetMemCheckHandler()->SetPersistentOption( - "ExcludeLabelRegularExpression", args[i].c_str()); + this->GetTestHandler()->AddPersistentMultiOption( + "ExcludeLabelRegularExpression", args[i]); + this->GetMemCheckHandler()->AddPersistentMultiOption( + "ExcludeLabelRegularExpression", args[i]); } else if (this->CheckArgument(arg, "-E"_s, "--exclude-regex") && @@ -2268,6 +2268,15 @@ void cmCTest::SetPersistentOptionIfNotEmpty(const std::string& value, } } +void cmCTest::AddPersistentMultiOptionIfNotEmpty(const std::string& value, + const std::string& optionName) +{ + if (!value.empty()) { + this->GetTestHandler()->AddPersistentMultiOption(optionName, value); + this->GetMemCheckHandler()->AddPersistentMultiOption(optionName, value); + } +} + bool cmCTest::SetArgsFromPreset(const std::string& presetName, bool listPresets) { @@ -2419,7 +2428,7 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, if (expandedPreset->Filter->Include) { this->SetPersistentOptionIfNotEmpty( expandedPreset->Filter->Include->Name, "IncludeRegularExpression"); - this->SetPersistentOptionIfNotEmpty( + this->AddPersistentMultiOptionIfNotEmpty( expandedPreset->Filter->Include->Label, "LabelRegularExpression"); if (expandedPreset->Filter->Include->Index) { @@ -2452,7 +2461,7 @@ bool cmCTest::SetArgsFromPreset(const std::string& presetName, if (expandedPreset->Filter->Exclude) { this->SetPersistentOptionIfNotEmpty( expandedPreset->Filter->Exclude->Name, "ExcludeRegularExpression"); - this->SetPersistentOptionIfNotEmpty( + this->AddPersistentMultiOptionIfNotEmpty( expandedPreset->Filter->Exclude->Label, "ExcludeLabelRegularExpression"); diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 4669a1c..392eb1c 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -463,6 +463,8 @@ public: private: void SetPersistentOptionIfNotEmpty(const std::string& value, const std::string& optionName); + void AddPersistentMultiOptionIfNotEmpty(const std::string& value, + const std::string& optionName); int GenerateNotesFile(const std::string& files); diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 3c331d3..a4b85ae 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -55,8 +55,9 @@ static const char* cmDocumentationOptions[][2] = { "format of the test information and can be 'human' for the current text " "format or 'json-v1' for json format. Defaults to 'human'." }, { "-L , --label-regex ", - "Run tests with labels matching " - "regular expression." }, + "Run tests with labels matching regular expression. " + "With multiple -L, run tests where each " + "regular expression matches at least one label." }, { "-R , --tests-regex ", "Run tests matching regular " "expression." }, @@ -64,8 +65,9 @@ static const char* cmDocumentationOptions[][2] = { "Exclude tests matching regular " "expression." }, { "-LE , --label-exclude ", - "Exclude tests with labels " - "matching regular expression." }, + "Exclude tests with labels matching regular expression. " + "With multiple -LE, exclude tests where each " + "regular expression matches at least one label." }, { "-FA , --fixture-exclude-any ", "Do not automatically " "add any tests for " diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 6bbbe7d..52959e6 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -7,6 +7,7 @@ macro(AddCMakeTest TestName PreArgs) add_test(NAME CMake.${TestName} COMMAND ${CMAKE_EXECUTABLE} ${PreArgs} -P "${CMAKE_CURRENT_BINARY_DIR}/${TestName}Test.cmake" ${ARGN}) + set_tests_properties("CMake.${TestName}" PROPERTIES LABELS "CMake;command") endmacro() diff --git a/Tests/CTestTestLabelRegExp/test.cmake.in b/Tests/CTestTestLabelRegExp/test.cmake.in index 5c0c9d7..dd40c3b 100644 --- a/Tests/CTestTestLabelRegExp/test.cmake.in +++ b/Tests/CTestTestLabelRegExp/test.cmake.in @@ -27,11 +27,15 @@ expect_test_list("test1.*test3.*Total Tests: 2" --label-regex foo) expect_test_list("test2.*test3.*Total Tests: 2" --label-regex bar) expect_test_list("test1.*test2.*test3.*Total Tests: 3" --label-regex foo|bar) expect_test_list("Total Tests: 0" --label-regex baz) +expect_test_list("Total Tests: 0" --label-regex foo --label-regex baz) +expect_test_list("test3.*Total Tests: 1" --label-regex foo --label-regex bar) expect_test_list("test2.*Total Tests: 1" --label-exclude foo) expect_test_list("test1.*Total Tests: 1" --label-exclude bar) expect_test_list("Total Tests: 0" --label-exclude foo|bar) expect_test_list("test1.*test2.*test3.*Total Tests: 3" --label-exclude baz) +expect_test_list("test1.*test2.*Total Tests: 2" --label-exclude foo --label-exclude bar) +expect_test_list("test1.*test2.*test3.*Total Tests: 3" --label-exclude foo --label-exclude baz) expect_test_list("test1.*Total Tests: 1" --label-regex foo --label-exclude bar) expect_test_list("test2.*Total Tests: 1" --label-regex bar --label-exclude foo) diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index 1024996..9dcf31f 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -43,6 +43,7 @@ macro(ADD_AUTOGEN_TEST NAME) --build-options ${build_options} ${Autogen_BUILD_OPTIONS} ${_TestCommand} ) + set_tests_properties("${_QtXAutogen}.${NAME}" PROPERTIES LABELS "Qt${QT_TEST_VERSION}") list(APPEND TEST_BUILD_DIRS "${_BuildDir}") unset(_TestCommand) unset(_QtXAutogen) diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index d1edd72..ab5686a 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -36,7 +36,9 @@ ADD_AUTOGEN_TEST(UnityMocSource) if(QT_TEST_ALLOW_QT_MACROS) ADD_AUTOGEN_TEST(MocCMP0071) + set_property(TEST "Qt${QT_TEST_VERSION}Autogen.MocCMP0071" APPEND PROPERTY LABELS "policy") ADD_AUTOGEN_TEST(MocCMP0100) + set_property(TEST "Qt${QT_TEST_VERSION}Autogen.MocCMP0100" APPEND PROPERTY LABELS "policy") ADD_AUTOGEN_TEST(MocInclude) ADD_AUTOGEN_TEST(MocIncludeSymlink) ADD_AUTOGEN_TEST(MocSkipSource) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 354a04e..c05b1a7 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -29,6 +29,10 @@ macro(add_RunCMake_test test) ${TEST_ARGS} -P "${CMAKE_CURRENT_SOURCE_DIR}/${Test_Dir}/RunCMakeTest.cmake" ) + set_tests_properties("RunCMake.${test}" PROPERTIES LABELS "CMake;run") + if(${test} MATCHES ^CMP) + set_property(TEST "RunCMake.${test}" APPEND PROPERTY LABELS "policy") + endif() endmacro() function(add_RunCMake_test_group test types) -- cgit v0.12 From 699577e7b2ca4e3f987b4a74bb4f88e4cfeff786 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 28 Mar 2021 00:01:11 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index dc4fcae..d2ba664 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210327) +set(CMake_VERSION_PATCH 20210328) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From d0adb2386a87046e9236b1b2b4d1c2706c78a711 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Sat, 27 Mar 2021 23:52:56 +0100 Subject: CPackRPM: correctly handle empty dir in single package mode Enabling CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE while having an empty directory in non main component resulted in packaging error that the directory does not exist. Fixes: #21951 --- Modules/Internal/CPack/CPackRPM.cmake | 10 ++++++++-- .../RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake | 2 +- Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake | 3 +++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 08bbc68..d853189 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1349,15 +1349,21 @@ function(cpack_rpm_generate_package) continue() endif() - file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES false RELATIVE + file(GLOB_RECURSE files_for_move_ LIST_DIRECTORIES true RELATIVE "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}" "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/*") foreach(f_ IN LISTS files_for_move_) - get_filename_component(dir_path_ "${f_}" DIRECTORY) set(src_file_ "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${component_}/${f_}") + if(IS_DIRECTORY "${src_file_}") + file(MAKE_DIRECTORY "${WDIR}/${f_}") + continue() + endif() + + get_filename_component(dir_path_ "${f_}" DIRECTORY) + # check that we are not overriding an existing file that doesn't # match the file that we want to copy if(EXISTS "${src_file_}" AND EXISTS "${WDIR}/${f_}") diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake index 936e4ed..1dc7084 100644 --- a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/ExpectedFiles.cmake @@ -9,7 +9,7 @@ if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL set(EXPECTED_FILE_2 "single_debuginfo*-headers.rpm") set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") set(EXPECTED_FILE_3 "single_debuginfo*-libs.rpm") - set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so") + set(EXPECTED_FILE_CONTENT_3_LIST "/bas;/bas/libtest_lib.so;/empty_dir") set(EXPECTED_FILE_4_COMPONENT "debuginfo") set(EXPECTED_FILE_CONTENT_4 ".*/src${whitespaces_}/src/src_1${whitespaces_}/src/src_1/main.cpp${whitespaces_}/src/src_1/test_lib.cpp.*\.debug.*") diff --git a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake index 60e9038..064539e 100644 --- a/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake +++ b/Tests/RunCMake/CPack/tests/SINGLE_DEBUGINFO/test.cmake @@ -30,6 +30,9 @@ if(RunCMake_SUBTEST_SUFFIX STREQUAL "valid" OR RunCMake_SUBTEST_SUFFIX STREQUAL "no_debuginfo") install(FILES CMakeLists.txt DESTINATION bar COMPONENT headers) install(TARGETS test_lib DESTINATION bas COMPONENT libs) + + # test that we correctly handle empty dir in non main component + install(DIRECTORY DESTINATION empty_dir COMPONENT libs) elseif(RunCMake_SUBTEST_SUFFIX STREQUAL "one_component" OR RunCMake_SUBTEST_SUFFIX STREQUAL "one_component_no_debuginfo") set(CPACK_COMPONENTS_ALL applications) -- cgit v0.12 From d5ab6a53edef5f259f9b9446943dcc5113898b51 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 29 Mar 2021 00:01:18 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d2ba664..64077c4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210328) +set(CMake_VERSION_PATCH 20210329) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 2e7719903032f4a7a9e223e1cd65e2c5132636ce Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 30 Mar 2021 00:01:18 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 64077c4..3798d8c 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210329) +set(CMake_VERSION_PATCH 20210330) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 3c867cff4a98bb198211e3d9f8494fbb478a29e4 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Tue, 22 Dec 2020 13:07:20 -0700 Subject: Fujitsu: Add support for the Fujitsu compiler in Trad mode Co-Author: Yuichiro Utsumi --- Help/manual/cmake-compile-features.7.rst | 1 + Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 + Modules/CMakeCheckCompilerFlagCommonPatterns.cmake | 2 +- Modules/CMakeDetermineCompilerId.cmake | 25 +++++++++++- Modules/CMakeFortranCompilerId.F.in | 9 +++++ Modules/CMakeParseImplicitIncludeInfo.cmake | 15 +++++++ Modules/CMakePlatformId.h.in | 6 ++- Modules/Compiler/Fujitsu-C.cmake | 20 +++++++++ Modules/Compiler/Fujitsu-CXX.cmake | 47 ++++++++++++++++++++++ Modules/Compiler/Fujitsu-DetermineCompiler.cmake | 17 +++++++- Modules/Compiler/Fujitsu-Fortran.cmake | 16 ++++++++ Modules/Compiler/Fujitsu.cmake | 33 +++++++++++++++ Modules/Platform/Linux-Fujitsu-CXX.cmake | 8 ++++ Modules/Platform/Linux-Fujitsu.cmake | 17 ++++++++ 14 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 Modules/Compiler/Fujitsu-C.cmake create mode 100644 Modules/Compiler/Fujitsu-CXX.cmake create mode 100644 Modules/Compiler/Fujitsu-Fortran.cmake create mode 100644 Modules/Compiler/Fujitsu.cmake create mode 100644 Modules/Platform/Linux-Fujitsu-CXX.cmake create mode 100644 Modules/Platform/Linux-Fujitsu.cmake diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 0d15ddf..56d16c0 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -359,6 +359,7 @@ following :variable:`compiler ids _COMPILER_ID>` as of the versions specified for each: * ``Cray``: Cray Compiler Environment version 8.1+. +* ``Fujitsu``: Fujitsu HPC compiler 4.0+. * ``PGI``: PGI version 12.10+. * ``NVHPC``: NVIDIA HPC compilers version 11.0+. * ``TI``: Texas Instruments compiler. diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index 89d9e27..c4f61a9 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -19,6 +19,7 @@ include: Cray = Cray Compiler (cray.com) Embarcadero, Borland = Embarcadero (embarcadero.com) Flang = Flang LLVM Fortran Compiler + Fujitsu = Fujitsu HPC compiler (Trad mode) G95 = G95 Fortran (g95.org) GNU = GNU Compiler Collection (gcc.gnu.org) GHS = Green Hills Software (www.ghs.com) diff --git a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake index 2dc75d6..05174de 100644 --- a/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake +++ b/Modules/CMakeCheckCompilerFlagCommonPatterns.cmake @@ -8,7 +8,7 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR) set(${_VAR} - FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG + FAIL_REGEX "[Uu]nrecogni[sz]ed .*option" # GNU, NAG, Fujitsu FAIL_REGEX "switch .* is no longer supported" # GNU FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "optimization flag .* not supported" # Clang diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index f406e5a..017c51a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -165,6 +165,25 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) endif() endif() + # The Fujitsu compiler does not always convey version information through + # preprocessor symbols so we extract through command line info + if (CMAKE_${lang}_COMPILER_ID STREQUAL "Fujitsu") + if(NOT CMAKE_${lang}_COMPILER_VERSION) + execute_process( + COMMAND "${CMAKE_${lang}_COMPILER}" -V + OUTPUT_VARIABLE output + ERROR_VARIABLE output + RESULT_VARIABLE result + TIMEOUT 10 + ) + if (result EQUAL 0) + if (output MATCHES [[Fujitsu [^ ]* Compiler ([0-9]+\.[0-9]+\.[0-9]+)]]) + set(CMAKE_${lang}_COMPILER_VERSION "${CMAKE_MATCH_1}") + endif() + endif() + endif() + endif() + # if the format is unknown after all files have been checked, put "Unknown" in the cache if(NOT CMAKE_EXECUTABLE_FORMAT) set(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format") @@ -830,8 +849,10 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}") endif() if("${info}" MATCHES "INFO:compiler_version_internal\\[([^]\"]*)\\]") - string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION_INTERNAL "${CMAKE_MATCH_1}") - string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION_INTERNAL "${COMPILER_VERSION_INTERNAL}") + set(COMPILER_VERSION_INTERNAL "${CMAKE_MATCH_1}") + string(REGEX REPLACE "^0+([0-9]+)" "\\1" COMPILER_VERSION_INTERNAL "${COMPILER_VERSION_INTERNAL}") + string(REGEX REPLACE "\\.0+([0-9]+)" ".\\1" COMPILER_VERSION_INTERNAL "${COMPILER_VERSION_INTERNAL}") + string(STRIP "${COMPILER_VERSION_INTERNAL}" COMPILER_VERSION_INTERNAL) endif() foreach(comp MAJOR MINOR PATCH TWEAK) foreach(digit 1 2 3 4 5 6 7 8 9) diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 0a3db4c..0b92b6a 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -136,6 +136,15 @@ #define COMPILER_VERSION_MAJOR DEC(__NAG_COMPILER_RELEASE/10) #define COMPILER_VERSION_MINOR DEC(__NAG_COMPILER_RELEASE % 10) #define COMPILER_VERSION_PATCH DEC(__NAG_COMPILER_BUILD) +#elif defined(__FUJITSU) + PRINT *, 'INFO:compiler[Fujitsu]' +# if defined(__FRT_major__) +# define COMPILER_VERSION_MAJOR DEC(__FRT_major__) +# define COMPILER_VERSION_MINOR DEC(__FRT_minor__) +# define COMPILER_VERSION_PATCH DEC(__FRT_patchlevel__) +# elif defined(__FRT_version__) + PRINT *, 'INFO:compiler_version['//__FRT_version__//']' +# endif #else PRINT *, 'INFO:compiler[]' #endif diff --git a/Modules/CMakeParseImplicitIncludeInfo.cmake b/Modules/CMakeParseImplicitIncludeInfo.cmake index 7cd7548..a8e6ac0 100644 --- a/Modules/CMakeParseImplicitIncludeInfo.cmake +++ b/Modules/CMakeParseImplicitIncludeInfo.cmake @@ -146,6 +146,21 @@ function(cmake_parse_implicit_include_line line lang id_var log_var state_var) endif() endif() + # Fujitsu compiler + if(CMAKE_${lang}_COMPILER_ID STREQUAL "Fujitsu" AND + line MATCHES "/ccpcom") + string(REGEX MATCHALL " (-I *|--sys_include=|--preinclude +)(\"[^\"]+\"|[^ \"]+)" incs "${line}") + foreach(inc IN LISTS incs) + string(REGEX REPLACE " (-I *|--sys_include=|--preinclude +)(\"[^\"]+\"|[^ \"]+)" "\\2" idir "${inc}") + list(APPEND rv "${idir}") + endforeach() + if(rv) + string(APPEND log " got implicit includes via fujitsu ccpcom parser!\n") + else() + string(APPEND log " warning: fujitsu ccpcom parse failed!\n") + endif() + endif() + if(log) set(${log_var} "${log}" PARENT_SCOPE) else() diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 1dc12c0..3ae9f49 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -256,8 +256,12 @@ ('0' + ((n)>>4 & 0xF)), \ ('0' + ((n) & 0xF)) +/* Construct a string literal encoding the version number. */ +#ifdef COMPILER_VERSION +char const* info_version = "INFO" ":" "compiler_version[" COMPILER_VERSION "]"; + /* Construct a string literal encoding the version number components. */ -#ifdef COMPILER_VERSION_MAJOR +#elif defined(COMPILER_VERSION_MAJOR) char const info_version[] = { 'I', 'N', 'F', 'O', ':', 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', diff --git a/Modules/Compiler/Fujitsu-C.cmake b/Modules/Compiler/Fujitsu-C.cmake new file mode 100644 index 0000000..0e0f1dc --- /dev/null +++ b/Modules/Compiler/Fujitsu-C.cmake @@ -0,0 +1,20 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +include(Compiler/Fujitsu) +__compiler_fujitsu(C) + +if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4) + set(CMAKE_C89_STANDARD_COMPILE_OPTION -std=c89) + set(CMAKE_C89_EXTENSION_COMPILE_OPTION -std=gnu89) + set(CMAKE_C89_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C99_STANDARD_COMPILE_OPTION -std=c99) + set(CMAKE_C99_EXTENSION_COMPILE_OPTION -std=gnu99) + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_C11_STANDARD_COMPILE_OPTION -std=c11) + set(CMAKE_C11_EXTENSION_COMPILE_OPTION -std=gnu11) + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) +endif() + +__compiler_check_default_language_standard(C 4 11) diff --git a/Modules/Compiler/Fujitsu-CXX.cmake b/Modules/Compiler/Fujitsu-CXX.cmake new file mode 100644 index 0000000..0f42196 --- /dev/null +++ b/Modules/Compiler/Fujitsu-CXX.cmake @@ -0,0 +1,47 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +include(Compiler/Fujitsu) +__compiler_fujitsu(CXX) + +#set(CMAKE_PCH_EXTENSION .pch) +#set(CMAKE_PCH_EPILOGUE "#pragma hdrstop") +#set(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH --no_pch_messages -include --use_pch ) +#set(CMAKE_CXX_COMPILE_OPTIONS_CREATE_PCH --no_pch_messages -include --create_pch ) + +# The Fujitsu compiler offers both a 98 and 03 mode. These two are +# essentially interchangeable as 03 simply provides clarity to some 98 +# ambiguyity. +# +# Re: Stroustrup's C++ FAQ: +# What is the difference between C++98 and C++03? +# From a programmer's view there is none. The C++03 revision of the +# standard was a bug fix release for implementers to ensure greater +# consistency and portability. In particular, tutorial and reference +# material describing C++98 and C++03 can be used interchangeably by all +# except compiler writers and standards gurus. +# +# Since CMake doesn't actually have an 03 mode and they're effectively +# interchangeable then we're just going to explicitly use 03 mode in the +# compiler when 98 is requested. + +# The version matching is messy here. The std support seems to be related to +# the compiler tweak version derived from the patch id in the version string. + +if(CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 4) + set(CMAKE_CXX98_STANDARD_COMPILE_OPTION -std=c++03) + set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION -std=gnu++03) + set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_CXX11_STANDARD_COMPILE_OPTION -std=c++11) + set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION -std=gnu++11) + set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_CXX14_STANDARD_COMPILE_OPTION -std=c++14) + set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION -std=gnu++14) + set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON) + + set(CMAKE_CXX17_STANDARD_COMPILE_OPTION -std=c++17) + set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION -std=gnu++17) +endif() + +__compiler_check_default_language_standard(CXX 4 14) diff --git a/Modules/Compiler/Fujitsu-DetermineCompiler.cmake b/Modules/Compiler/Fujitsu-DetermineCompiler.cmake index 73ee38c..a8c655d 100644 --- a/Modules/Compiler/Fujitsu-DetermineCompiler.cmake +++ b/Modules/Compiler/Fujitsu-DetermineCompiler.cmake @@ -1,2 +1,17 @@ -set(_compiler_id_pp_test "defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version)") +set(_compiler_id_pp_test "defined(__FUJITSU) && !defined(__CLANG_FUJITSU)") + +set(_compiler_id_version_compute " +# if defined(__FCC_version__) +# define @PREFIX@COMPILER_VERSION __FCC_version__ +# elif defined(__FCC_major__) +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__FCC_major__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__FCC_minor__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__FCC_patchlevel__) +# endif +# if defined(__fcc_version) +# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__fcc_version) +# elif defined(__FCC_VERSION) +# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__FCC_VERSION) +# endif +") diff --git a/Modules/Compiler/Fujitsu-Fortran.cmake b/Modules/Compiler/Fujitsu-Fortran.cmake new file mode 100644 index 0000000..0f687bc --- /dev/null +++ b/Modules/Compiler/Fujitsu-Fortran.cmake @@ -0,0 +1,16 @@ +include(Compiler/Fujitsu) +__compiler_fujitsu(Fortran) + +set(CMAKE_Fortran_SUBMODULE_SEP ".") +set(CMAKE_Fortran_SUBMODULE_EXT ".smod") + +set(CMAKE_Fortran_PREPROCESS_SOURCE + " -Cpp -E > ") +set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-Cpp") + +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Free") + +string(APPEND CMAKE_Fortran_FLAGS_DEBUG_INIT "") + +set(CMAKE_Fortran_MODDIR_FLAG "-M ") diff --git a/Modules/Compiler/Fujitsu.cmake b/Modules/Compiler/Fujitsu.cmake new file mode 100644 index 0000000..13bc57c --- /dev/null +++ b/Modules/Compiler/Fujitsu.cmake @@ -0,0 +1,33 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_FUJITSU) + return() +endif() +set(__COMPILER_FUJITSU 1) + +include(Compiler/CMakeCommonCompilerMacros) + +macro(__compiler_fujitsu lang) + set(CMAKE_${lang}_VERBOSE_FLAG "-###") + + # Initial configuration flags + string(APPEND CMAKE_${lang}_FLAGS_INIT " ") + string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g -O0") + string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3 -DNDEBUG") + string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG") + + # PIC flags + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + + # Passing link options to the compiler + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG "-Wl,") + set(CMAKE_${lang}_LINKER_WRAPPER_FLAG_SEP ",") + + # How to actually call the compiler + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE + " -E $<$:-Cpp> > ") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") +endmacro() diff --git a/Modules/Platform/Linux-Fujitsu-CXX.cmake b/Modules/Platform/Linux-Fujitsu-CXX.cmake new file mode 100644 index 0000000..d72dd49 --- /dev/null +++ b/Modules/Platform/Linux-Fujitsu-CXX.cmake @@ -0,0 +1,8 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details + +include(Platform/Linux-Fujitsu) +__linux_compiler_fujitsu(CXX) + +# Special sauce to propagate the -std=xxx flag when linking +set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION ON) diff --git a/Modules/Platform/Linux-Fujitsu.cmake b/Modules/Platform/Linux-Fujitsu.cmake new file mode 100644 index 0000000..be11b0a --- /dev/null +++ b/Modules/Platform/Linux-Fujitsu.cmake @@ -0,0 +1,17 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__LINUX_COMPILER_FUJITSU) + return() +endif() +set(__LINUX_COMPILER_FUJITSU 1) + +macro(__linux_compiler_fujitsu lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") +endmacro() -- cgit v0.12 From d0b9ffb6304834915ae983ce44af1c92ec9cdd39 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Tue, 30 Mar 2021 09:46:09 -0400 Subject: KWSys 2021-03-30 (db93a594) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit db93a5948e331c8920ac701e35b2f7e283646cae (master). Upstream Shortlog ----------------- Lemures Lemniscati (2): 9a6d6c54 Terminal: Avoid using Windows functions on Cygwin 4c61b968 SystemTools::FileIsFullPath: Do not accept Windows paths on Cygwin --- SystemTools.cxx | 2 +- Terminal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SystemTools.cxx b/SystemTools.cxx index cf04799..4d974a8 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -3926,7 +3926,7 @@ bool SystemTools::FileIsFullPath(const char* in_name) bool SystemToolsStatic::FileIsFullPath(const char* in_name, size_t len) { -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) && !defined(__CYGWIN__) // On Windows, the name must be at least two characters long. if (len < 2) { return false; diff --git a/Terminal.c b/Terminal.c index 4d1b46c..9409d1b 100644 --- a/Terminal.c +++ b/Terminal.c @@ -10,7 +10,7 @@ #endif /* Configure support for this platform. */ -#if defined(_WIN32) || defined(__CYGWIN__) +#if defined(_WIN32) # define KWSYS_TERMINAL_SUPPORT_CONSOLE #endif #if !defined(_WIN32) -- cgit v0.12 From 31c184ad690be45494cf997df71ad09293a0d4b0 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Mon, 29 Mar 2021 00:06:05 +0200 Subject: CPackRPM: handle scripts in debuginfo single package mode Enabling CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE while using rpm install or erase scripts resulted in resulted missing scripts for non default components. Fixes: #21974 --- Modules/Internal/CPack/CPackRPM.cmake | 19 +++++++++++++++++++ Tests/RunCMake/CPack/RPM/Prerequirements.cmake | 7 +++++++ Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 +- .../CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake | 7 ++++++- .../RPM-COMPONENT-single_debug_info-stderr.txt | 1 + .../tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake | 11 +++++++++++ Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake | 6 ++++++ 7 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-single_debug_info-stderr.txt create mode 100644 Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 08bbc68..2ee0622 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1637,6 +1637,25 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ %description -n \@CPACK_RPM_PACKAGE_NAME\@ \@CPACK_RPM_PACKAGE_DESCRIPTION\@ +%post -n \@CPACK_RPM_PACKAGE_NAME\@ +\@RPM_SYMLINK_POSTINSTALL\@ +\@CPACK_RPM_SPEC_POSTINSTALL\@ + +%posttrans -n \@CPACK_RPM_PACKAGE_NAME\@ +\@CPACK_RPM_SPEC_POSTTRANS\@ + +%postun -n \@CPACK_RPM_PACKAGE_NAME\@ +\@CPACK_RPM_SPEC_POSTUNINSTALL\@ + +%pre -n \@CPACK_RPM_PACKAGE_NAME\@ +\@CPACK_RPM_SPEC_PREINSTALL\@ + +%pretrans -n \@CPACK_RPM_PACKAGE_NAME\@ +\@CPACK_RPM_SPEC_PRETRANS\@ + +%preun -n \@CPACK_RPM_PACKAGE_NAME\@ +\@CPACK_RPM_SPEC_PREUNINSTALL\@ + %files -n \@CPACK_RPM_PACKAGE_NAME\@ %defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@) \@CPACK_RPM_INSTALL_FILES\@ diff --git a/Tests/RunCMake/CPack/RPM/Prerequirements.cmake b/Tests/RunCMake/CPack/RPM/Prerequirements.cmake index 3416205..e95cd15 100644 --- a/Tests/RunCMake/CPack/RPM/Prerequirements.cmake +++ b/Tests/RunCMake/CPack/RPM/Prerequirements.cmake @@ -13,4 +13,11 @@ function(get_test_prerequirements found_var config_file) "\nset(RPMBUILD_EXECUTABLE \"${RPMBUILD_EXECUTABLE}\")") set(${found_var} true PARENT_SCOPE) endif() + + # optional tool for some tests + find_program(OBJDUMP_EXECUTABLE objdump) + if(OBJDUMP_EXECUTABLE) + file(APPEND "${config_file}" + "\nset(OBJDUMP_EXECUTABLE \"${OBJDUMP_EXECUTABLE}\")") + endif() endfunction() diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 15bfb60..48b9c1d 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -16,7 +16,7 @@ run_cpack_test(VERSION "RPM.VERSION;DEB.VERSION" false "MONOLITHIC;COMPONENT") run_cpack_test(EXTRA "DEB.EXTRA" false "COMPONENT") run_cpack_test_subtests(GENERATE_SHLIBS "soversion_not_zero;soversion_zero" "DEB.GENERATE_SHLIBS" true "COMPONENT") run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB.GENERATE_SHLIBS_LDCONFIG" true "COMPONENT") -run_cpack_test(INSTALL_SCRIPTS "RPM.INSTALL_SCRIPTS" false "COMPONENT") +run_cpack_test_subtests(INSTALL_SCRIPTS "default;single_debug_info" "RPM.INSTALL_SCRIPTS" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB.LONG_FILENAMES" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM.MAIN_COMPONENT" false "COMPONENT") run_cpack_test(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake index de38df9..29e36a3 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake @@ -1,5 +1,10 @@ +if(RunCMake_SUBTEST_SUFFIX STREQUAL "single_debug_info") + set(EXPECTED_FILE_1 "install_scripts-0.1.1-1.*.rpm") +else() + set(EXPECTED_FILE_1_COMPONENT "foo") +endif() + set(EXPECTED_FILES_COUNT "2") -set(EXPECTED_FILE_1_COMPONENT "foo") set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") set(EXPECTED_FILE_2_COMPONENT "bar") set(EXPECTED_FILE_CONTENT_2_LIST "/bar;/bar/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-single_debug_info-stderr.txt b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-single_debug_info-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-single_debug_info-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake new file mode 100644 index 0000000..c5d20cc --- /dev/null +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake @@ -0,0 +1,11 @@ +function(get_test_prerequirements found_var config_file) + if(SUBTEST_SUFFIX STREQUAL "single_debug_info") + include(${config_file}) + + if(OBJDUMP_EXECUTABLE) + set(${found_var} true PARENT_SCOPE) + endif() + else() + set(${found_var} true PARENT_SCOPE) + endif() +endfunction() diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake index c200fa5..6877c57 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake @@ -24,6 +24,12 @@ if(GENERATOR_TYPE STREQUAL "RPM") "${CMAKE_CURRENT_BINARY_DIR}/pre_trans_foo.sh") set(CPACK_RPM_foo_POST_TRANS_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/post_trans_foo.sh") + + if(RunCMake_SUBTEST_SUFFIX STREQUAL "single_debug_info") + set(CPACK_RPM_MAIN_COMPONENT "foo") + set(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE ON) + set(CPACK_RPM_FOO_FILE_NAME "RPM-DEFAULT") + endif() endif() set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) -- cgit v0.12 From d796948f44c09d7714163948e79f20e9b1f8dbe6 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 31 Mar 2021 00:01:19 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3798d8c..6604148 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210330) +set(CMake_VERSION_PATCH 20210331) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From a55feff69c7967d56e0935d841cf1ea2c980a43a Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Tue, 22 Dec 2020 13:07:48 -0700 Subject: Tests: Update for the Fujitsu compiler --- Tests/CheckFortran.cmake | 2 +- Tests/CompileFeatures/CMakeLists.txt | 4 ++-- Tests/ConfigSources/CMakeLists.txt | 1 + .../Import/Interface/pch_iface_test.cpp | 3 ++- Tests/Fortran/CMakeLists.txt | 2 +- Tests/FortranOnly/CMakeLists.txt | 21 ++++++++++----------- .../WriteCompilerDetectionHeader/CMakeLists.txt | 4 ++-- Tests/RunCMake/CMakeLists.txt | 2 +- Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt | 5 +++++ 9 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake index 33e1bfb..36293f5 100644 --- a/Tests/CheckFortran.cmake +++ b/Tests/CheckFortran.cmake @@ -7,7 +7,7 @@ if(NOT DEFINED CMAKE_Fortran_COMPILER) message(STATUS ${_desc}) file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/CheckFortran/CMakeLists.txt" - "cmake_minimum_required(VERSION 2.4) + "cmake_minimum_required(VERSION 2.8.12) project(CheckFortran Fortran) file(WRITE \"\${CMAKE_CURRENT_BINARY_DIR}/result.cmake\" \"set(CMAKE_Fortran_COMPILER \\\"\${CMAKE_Fortran_COMPILER}\\\")\\n\" diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 7771967..f4fab51 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -18,7 +18,7 @@ macro(run_test feature lang) endif() endmacro() -if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") foreach(feature ${c_features}) @@ -26,7 +26,7 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") endforeach() endif() -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") foreach(feature ${cxx_features}) diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index a3d98f6..219a972 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.0) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE) endif() diff --git a/Tests/ExportImport/Import/Interface/pch_iface_test.cpp b/Tests/ExportImport/Import/Interface/pch_iface_test.cpp index a18bbde..d676a5b 100644 --- a/Tests/ExportImport/Import/Interface/pch_iface_test.cpp +++ b/Tests/ExportImport/Import/Interface/pch_iface_test.cpp @@ -3,7 +3,8 @@ # ifndef PCH_PCH_H_INCLUDED # error "Expected PCH_PCH_H_INCLUDED." # endif -#elif defined(__PGIC__) || defined(__ibmxl__) || defined(_CRAYC) +#elif defined(__PGIC__) || defined(__ibmxl__) || defined(_CRAYC) || \ + defined(__FUJITSU) // No PCH expected but these compilers define macros below. #elif defined(__GNUC__) || defined(__clang__) || defined(_INTEL_COMPILER) || \ defined(_MSC_VER) diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index c1476be..2fc47a5 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -46,7 +46,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|PathScale|Absoft|Fujitsu") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt index b5b5e56..cdf8ed6 100644 --- a/Tests/FortranOnly/CMakeLists.txt +++ b/Tests/FortranOnly/CMakeLists.txt @@ -117,15 +117,9 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") target_compile_definitions(IntelIfDef PRIVATE SOME_DEF) endif() -# Skip these tests if compiler/version doesn't have preprocessing flags -if((CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.4) - OR (CMAKE_Fortran_COMPILER_ID STREQUAL "XL" AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 15.1.6)) - set(test_pp_flags 0) -else() - set(test_pp_flags 1) -endif() - -if(test_pp_flags) +# Skip these tests if compiler/version does enable and disable preprocessing +if(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON AND + CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF) # Test that we can always preprocess a target add_executable(preprocess_target preprocess2.f) set_property(TARGET preprocess_target PROPERTY Fortran_PREPROCESS ON) @@ -145,17 +139,22 @@ set_property(SOURCE no_preprocess_source_lower.f PROPERTY Fortran_PREPROCESS OFF # Test that we can explicitly not preprocess a target or source. # This will not work on certain compilers due to either missing a -# "don't preprocess" flag, or due to choice of file extension. -if(test_pp_flags AND NOT CMAKE_Fortran_COMPILER_ID MATCHES "(Flang|NAG|PGI|NVHPC|SunPro|XL)") +# "don't preprocess" flag, or due to the flags being ignored for +# extensions like '.F' and '.fpp'. +if(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF AND + NOT CMAKE_Fortran_COMPILER_ID MATCHES "(Flang|NAG|PGI|NVHPC|SunPro|XL)") add_library(no_preprocess_target STATIC no_preprocess_target_upper.F) target_compile_options(no_preprocess_target PRIVATE -DINTEGER=nonsense) + add_library(no_preprocess_source STATIC no_preprocess_source_upper.F) target_compile_options(no_preprocess_source PRIVATE -DINTEGER=nonsense) + if(NOT CMAKE_Fortran_COMPILER_ID STREQUAL "Cray" AND NOT "${CMAKE_Fortran_COMPILER_ID};${CMAKE_Fortran_SIMULATE_ID}" MATCHES "Intel(LLVM)?;MSVC") target_sources(no_preprocess_target PRIVATE no_preprocess_target_fpp.fpp) target_sources(no_preprocess_source PRIVATE no_preprocess_source_fpp.fpp) endif() + set_property(TARGET no_preprocess_target PROPERTY Fortran_PREPROCESS OFF) set_property(SOURCE no_preprocess_source_upper.F no_preprocess_source_fpp.fpp PROPERTY Fortran_PREPROCESS OFF) endif() diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index 0cf74bf..d438e54 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -52,7 +52,7 @@ endmacro() # detailed features tables, not just meta-features if (CMAKE_C_COMPILE_FEATURES) - if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") + if (NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") endif() @@ -95,7 +95,7 @@ if (C_expected_features) endif() if (CMAKE_CXX_COMPILE_FEATURES) - if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM)$") + if (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 354a04e..3f3c3a0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -273,7 +273,7 @@ add_RunCMake_test(Graphviz) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) -if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang)$") +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|Fujitsu)$") add_RunCMake_test(MetaCompileFeatures) endif() if(MSVC) diff --git a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt index abd0628..950ec25 100644 --- a/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt +++ b/Tests/VSGNUFortran/subdir/fortran/CMakeLists.txt @@ -43,4 +43,9 @@ if(CMAKE_Fortran_COMPILER_ID MATCHES SunPro) target_link_libraries(hello PRIVATE sunquad) endif() endif() +elseif(CMAKE_Fortran_COMPILER_ID MATCHES Fujitsu) + # Fujitsu Fortran doesn't automatically link its runtime libraries into + # SOs + target_link_libraries(world PRIVATE fj90i fj90f fjsrcinfo) + target_link_libraries(hello PRIVATE fj90i fj90f fjsrcinfo) endif() -- cgit v0.12 From 27579e9cf12a9994fc15ff9e5487f73cc0406428 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Tue, 22 Dec 2020 14:11:34 -0700 Subject: FujitsuClang: Add support for the Fujitsu compiler in Clang mode This should be front end compatible with vanilla clang but giving it a unique identifier allows a project to pass additional options unique to Fujitsu and outside the scope of a CMake builtin. --- Help/variable/CMAKE_LANG_COMPILER_ID.rst | 1 + Modules/CMakeCompilerIdDetection.cmake | 1 + Modules/CMakePlatformId.h.in | 2 ++ Modules/Compiler/Fujitsu-DetermineCompiler.cmake | 2 +- Modules/Compiler/FujitsuClang-C.cmake | 6 ++++++ Modules/Compiler/FujitsuClang-CXX.cmake | 6 ++++++ Modules/Compiler/FujitsuClang-DetermineCompiler.cmake | 9 +++++++++ Modules/Compiler/FujitsuClang.cmake | 11 +++++++++++ Modules/Platform/Linux-Fujitsu-C.cmake | 1 + Modules/Platform/Linux-Fujitsu-CXX.cmake | 9 +-------- 10 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 Modules/Compiler/FujitsuClang-C.cmake create mode 100644 Modules/Compiler/FujitsuClang-CXX.cmake create mode 100644 Modules/Compiler/FujitsuClang-DetermineCompiler.cmake create mode 100644 Modules/Compiler/FujitsuClang.cmake create mode 100644 Modules/Platform/Linux-Fujitsu-C.cmake diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst index c4f61a9..0abedde 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst @@ -20,6 +20,7 @@ include: Embarcadero, Borland = Embarcadero (embarcadero.com) Flang = Flang LLVM Fortran Compiler Fujitsu = Fujitsu HPC compiler (Trad mode) + FujitsuClang = Fujitsu HPC compiler (Clang mode) G95 = G95 Fortran (g95.org) GNU = GNU Compiler Collection (gcc.gnu.org) GHS = Green Hills Software (www.ghs.com) diff --git a/Modules/CMakeCompilerIdDetection.cmake b/Modules/CMakeCompilerIdDetection.cmake index 214d58a..c79d423 100644 --- a/Modules/CMakeCompilerIdDetection.cmake +++ b/Modules/CMakeCompilerIdDetection.cmake @@ -66,6 +66,7 @@ function(compiler_id_detection outvar lang) PGI Cray TI + FujitsuClang Fujitsu GHS ) diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in index 3ae9f49..2643874 100644 --- a/Modules/CMakePlatformId.h.in +++ b/Modules/CMakePlatformId.h.in @@ -285,6 +285,8 @@ char const info_version_internal[] = { 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','_', 'i','n','t','e','r','n','a','l','[', COMPILER_VERSION_INTERNAL,']','\0'}; +#elif defined(COMPILER_VERSION_INTERNAL_STR) +char const* info_version_internal = "INFO" ":" "compiler_version_internal[" COMPILER_VERSION_INTERNAL_STR "]"; #endif /* Construct a string literal encoding the version number components. */ diff --git a/Modules/Compiler/Fujitsu-DetermineCompiler.cmake b/Modules/Compiler/Fujitsu-DetermineCompiler.cmake index a8c655d..8534916 100644 --- a/Modules/Compiler/Fujitsu-DetermineCompiler.cmake +++ b/Modules/Compiler/Fujitsu-DetermineCompiler.cmake @@ -1,5 +1,5 @@ -set(_compiler_id_pp_test "defined(__FUJITSU) && !defined(__CLANG_FUJITSU)") +set(_compiler_id_pp_test "defined(__FUJITSU)") set(_compiler_id_version_compute " # if defined(__FCC_version__) diff --git a/Modules/Compiler/FujitsuClang-C.cmake b/Modules/Compiler/FujitsuClang-C.cmake new file mode 100644 index 0000000..f700d2d --- /dev/null +++ b/Modules/Compiler/FujitsuClang-C.cmake @@ -0,0 +1,6 @@ +include(Compiler/FujitsuClang) + +set(_fjclang_ver "${CMAKE_C_COMPILER_VERSION_INTERNAL}") +set(CMAKE_C_COMPILER_VERSION "${CMAKE_C_COMPILER_VERSION_INTERNAL}") +include(Compiler/Clang-C) +set(CMAKE_C_COMPILER_VERSION "${_fjclang_ver}") diff --git a/Modules/Compiler/FujitsuClang-CXX.cmake b/Modules/Compiler/FujitsuClang-CXX.cmake new file mode 100644 index 0000000..c8790cd --- /dev/null +++ b/Modules/Compiler/FujitsuClang-CXX.cmake @@ -0,0 +1,6 @@ +include(Compiler/FujitsuClang) + +set(_fjclang_ver "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}") +set(CMAKE_CXX_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION_INTERNAL}") +include(Compiler/Clang-CXX) +set(CMAKE_CXX_COMPILER_VERSION "${_fjclang_ver}") diff --git a/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake b/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake new file mode 100644 index 0000000..f6719b1 --- /dev/null +++ b/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake @@ -0,0 +1,9 @@ + +set(_compiler_id_pp_test "defined(__CLANG_FUJITSU)") + +set(_compiler_id_version_compute " +# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@(__FCC_major__) +# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(__FCC_minor__) +# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__FCC_patchlevel__) +# define @PREFIX@COMPILER_VERSION_INTERNAL_STR __clang_version__ +") diff --git a/Modules/Compiler/FujitsuClang.cmake b/Modules/Compiler/FujitsuClang.cmake new file mode 100644 index 0000000..a848248 --- /dev/null +++ b/Modules/Compiler/FujitsuClang.cmake @@ -0,0 +1,11 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_FUJITSUCLANG) + return() +endif() +set(__COMPILER_FUJITSUCLANG 1) + +include(Compiler/Clang) diff --git a/Modules/Platform/Linux-Fujitsu-C.cmake b/Modules/Platform/Linux-Fujitsu-C.cmake new file mode 100644 index 0000000..e37573d --- /dev/null +++ b/Modules/Platform/Linux-Fujitsu-C.cmake @@ -0,0 +1 @@ +include(Platform/Linux-Clang-C) diff --git a/Modules/Platform/Linux-Fujitsu-CXX.cmake b/Modules/Platform/Linux-Fujitsu-CXX.cmake index d72dd49..5257f13 100644 --- a/Modules/Platform/Linux-Fujitsu-CXX.cmake +++ b/Modules/Platform/Linux-Fujitsu-CXX.cmake @@ -1,8 +1 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details - -include(Platform/Linux-Fujitsu) -__linux_compiler_fujitsu(CXX) - -# Special sauce to propagate the -std=xxx flag when linking -set(CMAKE_CXX_LINK_WITH_STANDARD_COMPILE_OPTION ON) +include(Platform/Linux-Clang-CXX) -- cgit v0.12 From a2374509485d7507b42f03f093456aeb62ca6811 Mon Sep 17 00:00:00 2001 From: Yuichiro Utsumi Date: Fri, 5 Mar 2021 09:07:19 +0000 Subject: Tests: Update for the FujitsuClang compiler --- Tests/CompileFeatures/CMakeLists.txt | 4 ++-- Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt | 4 ++-- Tests/RunCMake/CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index f4fab51..20988ac 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -18,7 +18,7 @@ macro(run_test feature lang) endif() endmacro() -if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") +if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu|FujitsuClang)$") get_property(c_features GLOBAL PROPERTY CMAKE_C_KNOWN_FEATURES) list(FILTER c_features EXCLUDE REGEX "^c_std_[0-9][0-9]") foreach(feature ${c_features}) @@ -26,7 +26,7 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujits endforeach() endif() -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") +if(NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu|FujitsuClang)$") get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES) list(FILTER cxx_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") foreach(feature ${cxx_features}) diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt index d438e54..e406758 100644 --- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt +++ b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt @@ -52,7 +52,7 @@ endmacro() # detailed features tables, not just meta-features if (CMAKE_C_COMPILE_FEATURES) - if (NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") + if (NOT CMAKE_C_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu|FujitsuClang)$") set(C_expected_features ${CMAKE_C_COMPILE_FEATURES}) list(FILTER C_expected_features EXCLUDE REGEX "^c_std_[0-9][0-9]") endif() @@ -95,7 +95,7 @@ if (C_expected_features) endif() if (CMAKE_CXX_COMPILE_FEATURES) - if (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu)$") + if (NOT CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|IntelLLVM|Fujitsu|FujitsuClang)$") set(CXX_expected_features ${CMAKE_CXX_COMPILE_FEATURES}) list(FILTER CXX_expected_features EXCLUDE REGEX "^cxx_std_[0-9][0-9]") endif() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 3f3c3a0..9a6a103 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -273,7 +273,7 @@ add_RunCMake_test(Graphviz) add_RunCMake_test(TargetPropertyGeneratorExpressions) add_RunCMake_test(Languages) add_RunCMake_test(LinkStatic) -if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|Fujitsu)$") +if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|Fujitsu|FujitsuClang)$") add_RunCMake_test(MetaCompileFeatures) endif() if(MSVC) -- cgit v0.12 From 9e0a1cf03ed91bd52df9b5b66af5f203cf8b05c5 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Thu, 5 Sep 2019 15:08:48 -0400 Subject: FindMPI: Add support for the Fujitsu compiler wrappers Co-Author: Yuichiro Utsumi --- Modules/FindMPI.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 195ca49..bea0d8d 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -277,6 +277,11 @@ set(_MPI_Fortran_GENERIC_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r mpif77 mpif77_r mpf77 mpf77_r mpifc) +#Fujitsu cross/own compiler names +set(_MPI_Fujitsu_C_COMPILER_NAMES mpifccpx mpifcc) +set(_MPI_Fujitsu_CXX_COMPILER_NAMES mpiFCCpx mpiFCC) +set(_MPI_Fujitsu_Fortran_COMPILER_NAMES mpifrtpx mpifrt) + # GNU compiler names set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r mpigxx) @@ -337,7 +342,7 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95 # pick up the right settings for it. foreach (LANG IN ITEMS C CXX Fortran) set(_MPI_${LANG}_COMPILER_NAMES "") - foreach (id IN ITEMS GNU Intel IntelLLVM MSVC PGI XL) + foreach (id IN ITEMS Fujitsu FujitsuClang GNU Intel IntelLLVM MSVC PGI XL) if (NOT CMAKE_${LANG}_COMPILER_ID OR CMAKE_${LANG}_COMPILER_ID STREQUAL id) foreach(_COMPILER_NAME IN LISTS _MPI_${id}_${LANG}_COMPILER_NAMES) list(APPEND _MPI_${LANG}_COMPILER_NAMES ${_COMPILER_NAME}${MPI_EXECUTABLE_SUFFIX}) -- cgit v0.12 From 376c300b259fe4267085265cf8519fa749f882e1 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Thu, 5 Sep 2019 15:14:29 -0400 Subject: FindOpenMP: Add support for Fujitsu compilers Co-Author: Yuichiro Utsumi --- Modules/FindOpenMP.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 52330a4..e982e2d 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -130,6 +130,8 @@ function(_OPENMP_FLAG_CANDIDATES LANG) set(OMP_FLAG_XL "-qsmp=omp") # Cray compiler activate OpenMP with -h omp, which is enabled by default. set(OMP_FLAG_Cray " " "-h omp") + set(OMP_FLAG_Fujitsu "-Kopenmp" "-KOMP") + set(OMP_FLAG_FujitsuClang "-fopenmp" "-Kopenmp") # If we know the correct flags, use those if(DEFINED OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID}) -- cgit v0.12 From 4c74c86f4099ed63f429d39394f7c7117430a8a6 Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Wed, 27 Jan 2021 08:56:17 -0700 Subject: FindBLAS/LAPACK: Add support for the Fujitsu SSL2 library This also does some additional work to fix issues with libraries provided only via compiler options and no explicit library names. Co-Author: Yuichiro Utsumi --- Modules/FindBLAS.cmake | 75 +++++++++++++++++++++++++++++++------------ Modules/FindLAPACK.cmake | 83 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 122 insertions(+), 36 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 4cf812b..14a8665 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -55,6 +55,8 @@ The following variables may be set to influence this module's behavior: * ``Arm_ilp64_mp`` * ``EML`` * ``EML_mt`` + * ``Fujitsu_SSL2`` (Fujitsu serial blas / lapack) + * ``Fujitsu_SSL2BLAMP`` (Fujitsu parallel blas / lapack) * ``Generic`` .. versionadded:: 3.6 @@ -78,6 +80,7 @@ The following variables may be set to influence this module's behavior: .. versionadded:: 3.20 Elbrus Math Library support (``EML``, ``EML_mt``). + Fujitsu SSL2 Library support (``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP``) ``BLA_F95`` if ``ON`` tries to find the BLAS95 interfaces @@ -153,13 +156,18 @@ if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_CO endif() function(_add_blas_target) - if(NOT TARGET BLAS::BLAS) + if(BLAS_FOUND AND NOT TARGET BLAS::BLAS) add_library(BLAS::BLAS INTERFACE IMPORTED) if(BLAS_LIBRARIES) set_target_properties(BLAS::BLAS PROPERTIES INTERFACE_LINK_LIBRARIES "${BLAS_LIBRARIES}" ) endif() + if(BLAS_LINKER_FLAGS) + set_target_properties(BLAS::BLAS PROPERTIES + INTERFACE_LINK_OPTIONS "${BLAS_LINKER_FLAGS}" + ) + endif() endif() endfunction() @@ -228,34 +236,34 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add endif() list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - foreach(_library ${_list}) + foreach(_library ${_list} ${_threadlibs}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) set(${LIBRARIES} ${${LIBRARIES}} "${_library}") else() - set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_threadlibs}" STREQUAL "") - set(_combined_name ${_combined_name}_threadlibs) - endif() + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY + find_library(${_prefix}_${_lib_var}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) endif() endif() endforeach() + foreach(_flag ${_flags}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") + set(_combined_name ${_combined_name}_${_flag_var}) + endforeach() if(_libraries_work) # Test this combination of libraries. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threadlibs}) - #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -274,12 +282,12 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add else() set(${LIBRARIES} FALSE) endif() - #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endmacro() set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) set(BLAS95_LIBRARIES) +set(_blas_fphsa_req_var BLAS_LIBRARIES) if(NOT $ENV{BLA_VENDOR} STREQUAL "") set(BLA_VENDOR $ENV{BLA_VENDOR}) else() @@ -302,6 +310,9 @@ if(BLA_VENDOR STREQUAL "All") "" ) endif() + if(BLAS_WORKS) + set(_blas_fphsa_req_var BLAS_WORKS) + endif() endif() # BLAS in the Intel MKL 10+ library? @@ -1016,6 +1027,31 @@ if(BLA_VENDOR MATCHES "EML" OR BLA_VENDOR STREQUAL "All") endif() +# Fujitsu SSL2 Library? +if(NOT BLAS_LIBRARIES AND + BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP") + set(_ssl2_suffix BLAMP) + else() + set(_ssl2_suffix) + endif() + check_blas_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "-SSL2${_ssl2_suffix}" + "" + "" + "" + "" + ) + if(BLAS_LIBRARIES) + set(BLAS_LINKER_FLAGS "-SSL2${_ssl2_suffix}") + set(_blas_fphsa_req_var BLAS_LINKER_FLAGS) + endif() + unset(_ssl2_suffix) +endif() + # Generic BLAS library? if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) @@ -1032,17 +1068,16 @@ if(BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") endif() endif() -if(NOT BLA_F95) - find_package_handle_standard_args(BLAS REQUIRED_VARS BLAS_LIBRARIES) -endif() - - -# On compilers that implicitly link BLAS (such as ftn, cc, and CC on Cray HPC machines) -# we used a placeholder for empty BLAS_LIBRARIES to get through our logic above. +# On compilers that implicitly link BLAS (i.e. CrayPrgEnv) we used a +# placeholder for empty BLAS_LIBRARIES to get through our logic above. if(BLAS_LIBRARIES STREQUAL "BLAS_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") set(BLAS_LIBRARIES "") endif() +if(NOT BLA_F95) + find_package_handle_standard_args(BLAS REQUIRED_VARS ${_blas_fphsa_req_var}) +endif() + _add_blas_target() cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 45e4be7..a5b16ca 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -45,6 +45,8 @@ The following variables may be set to influence this module's behavior: * ``Arm_ilp64_mp`` * ``EML`` * ``EML_mt`` + * ``Fujitsu_SSL2`` (Fujitsu serial blas / lapack) + * ``Fujitsu_SSL2BLAMP`` (Fujitsu parallel blas / lapack) * ``Generic`` .. versionadded:: 3.6 @@ -68,6 +70,7 @@ The following variables may be set to influence this module's behavior: .. versionadded:: 3.20 Elbrus Math Library support (``EML``, ``EML_mt``). + Fujitsu SSL2 Library support (``Fujitsu_SSL2``, ``Fujitsu_SSL2BLAMP``) ``BLA_F95`` if ``ON`` tries to find the BLAS95/LAPACK95 interfaces @@ -130,20 +133,33 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) function(_add_lapack_target) if(LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK) add_library(LAPACK::LAPACK INTERFACE IMPORTED) + + # Filter out redundant BLAS info and replace with the BLAS target set(_lapack_libs "${LAPACK_LIBRARIES}") - if(_lapack_libs AND TARGET BLAS::BLAS) - # remove the ${BLAS_LIBRARIES} from the interface and replace it - # with the BLAS::BLAS target - list(REMOVE_ITEM _lapack_libs "${BLAS_LIBRARIES}") + set(_lapack_flags "${LAPACK_LINKER_FLAGS}") + if(TARGET BLAS::BLAS) + if(_lapack_libs AND BLAS_LIBRARIES) + foreach(_blas_lib IN LISTS BLAS_LIBRARIES) + list(REMOVE_ITEM _lapack_libs "${_blas_lib}") + endforeach() + endif() + if(_lapack_flags AND BLAS_LINKER_FLAGS) + foreach(_blas_flag IN LISTS BLAS_LINKER_FLAGS) + list(REMOVE_ITEM _lapack_flags "${_blas_flag}") + endforeach() + endif() list(APPEND _lapack_libs BLAS::BLAS) endif() - if(_lapack_libs) set_target_properties(LAPACK::LAPACK PROPERTIES INTERFACE_LINK_LIBRARIES "${_lapack_libs}" ) endif() - unset(_lapack_libs) + if(_lapack_flags) + set_target_properties(LAPACK::LAPACK PROPERTIES + INTERFACE_LINK_OPTIONS "${_lapack_flags}" + ) + endif() endif() endfunction() @@ -202,32 +218,35 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endif() list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - foreach(_library ${_list}) + foreach(_library ${_list} ${_threadlibs}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) set(${LIBRARIES} ${${LIBRARIES}} "${_library}") else() - set(_combined_name ${_combined_name}_${_library}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY + find_library(${_prefix}_${_lib_var}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - #message("DEBUG: find_library(${_library}) got ${${_prefix}_${_library}_LIBRARY}") - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) endif() endif() endforeach() unset(_library) + foreach(_flag ${_flags}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") + set(_combined_name ${_combined_name}_${_flag_var}) + endforeach() if(_libraries_work) # Test this combination of libraries. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) - #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -250,7 +269,6 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a unset(_extaddlibdir) unset(_libraries_work) unset(_combined_name) - #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endmacro() macro(_lapack_find_dependency dep) @@ -279,6 +297,7 @@ _lapack_find_library_setup() set(LAPACK_LINKER_FLAGS) set(LAPACK_LIBRARIES) set(LAPACK95_LIBRARIES) +set(_lapack_fphsa_req_var LAPACK_LIBRARIES) # Check the language being used if(NOT (CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED)) @@ -585,6 +604,38 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) ) endif() + # Fujitsu SSL2 Library? + if(NOT LAPACK_LIBRARIES + AND BLA_VENDOR MATCHES "Fujitsu_SSL2" OR BLA_VENDOR STREQUAL "All") + if(BLA_VENDOR STREQUAL "Fujitsu_SSL2BLAMP") + set(_ssl2_suffix BLAMP) + else() + set(_ssl2_suffix) + endif() + set(_ssl2_blas) + if(BLAS_LIBRARIES STREQUAL "") + set(_ssl2_blas "${BLAS_LINKER_FLAGS}") + else() + set(_ssl2_blas "${BLAS_LIBRARIES} ${BLAS_LINKER_FLAGS}") + endif() + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "-SSL2${_ssl2_suffix}" + "" + "" + "" + "" + "${_ssl2_blas}" + ) + if(LAPACK_LIBRARIES) + set(LAPACK_LINKER_FLAGS "-SSL2${_ssl2_suffix}") + set(_lapack_fphsa_req_var LAPACK_LINKER_FLAGS) + endif() + unset(_ssl2_suffix) + endif() + # Generic LAPACK library? if(NOT LAPACK_LIBRARIES AND (BLA_VENDOR STREQUAL "Generic" @@ -612,7 +663,7 @@ if(LAPACK_NOT_FOUND_MESSAGE) set(LAPACK_NOT_FOUND_MESSAGE REASON_FAILURE_MESSAGE ${LAPACK_NOT_FOUND_MESSAGE}) endif() -find_package_handle_standard_args(LAPACK REQUIRED_VARS LAPACK_LIBRARIES +find_package_handle_standard_args(LAPACK REQUIRED_VARS ${_lapack_fphsa_req_var} ${LAPACK_NOT_FOUND_MESSAGE}) unset(LAPACK_NOT_FOUND_MESSAGE) -- cgit v0.12 From 8ef55dec292b307e8be85d9d9a5424f0468d441f Mon Sep 17 00:00:00 2001 From: Chuck Atkins Date: Tue, 22 Dec 2020 14:31:54 -0700 Subject: Help: Add release notes for Fujitsu compiler support --- Help/release/dev/fujitsu-compiler-support.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Help/release/dev/fujitsu-compiler-support.rst diff --git a/Help/release/dev/fujitsu-compiler-support.rst b/Help/release/dev/fujitsu-compiler-support.rst new file mode 100644 index 0000000..c6f8cfb --- /dev/null +++ b/Help/release/dev/fujitsu-compiler-support.rst @@ -0,0 +1,11 @@ +fujitsu-compiler-support +------------------------ + +* Addition of the ``Fujitsu`` compiler ID operating in traditional ``Trad`` + mode and ``FujitsuClang`` operating in ``Clang`` mode. +* The :module:`FindOpenMP` module learned to support ``Fujitsu`` and + ``FujitsuClang``. +* The :module:`FindMPI` module learned to support ``Fujitsu`` and + ``FujitsuClang`` in both host and cross compiling modes. +* The :module:`FindBLAS` and :module:`FindLAPACK` modules learned to support + the serial ``Fujitsu SSL2`` and parallel ``Fujitsu SSL2BLAMP`` libraries. -- cgit v0.12 From 5ac8b923f503dcd02c47aa920afc747978bb07ab Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Wed, 31 Mar 2021 10:24:24 -0400 Subject: CMakePresets.json: Add matches condition --- Help/manual/cmake-presets.7.rst | 16 ++++++ Help/manual/presets/schema.json | 48 ++++++++++++++++++ Source/cmCMakePresetsFile.cxx | 20 ++++++++ Source/cmCMakePresetsFileInternal.h | 10 ++++ Source/cmCMakePresetsFileReadJSON.cxx | 20 ++++++++ Tests/RunCMake/CMakePresets/Conditions.json.in | 57 ++++++++++++++++++++++ .../RunCMake/CMakePresets/InvalidRegex-result.txt | 1 + .../RunCMake/CMakePresets/InvalidRegex-stderr.txt | 2 + Tests/RunCMake/CMakePresets/InvalidRegex.json.in | 15 ++++++ .../CMakePresets/ListConditions-stdout.txt | 4 ++ Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 1 + 11 files changed, 194 insertions(+) create mode 100644 Tests/RunCMake/CMakePresets/InvalidRegex-result.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidRegex-stderr.txt create mode 100644 Tests/RunCMake/CMakePresets/InvalidRegex.json.in diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index cc72603..8543be3 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -864,6 +864,22 @@ object, it has the following fields: A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation. + ``"matches"`` + + ``"notMatches"`` + + Indicates that the condition searches for a regular expression in a string. + The condition object will have the following additional fields: + + ``string`` + + A required string to search. This field supports macro expansion. + + ``regex`` + + A required regular expression to search for. This field supports macro + expansion. + ``"anyOf"`` ``"allOf"`` diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index c3c3ca1..9261519 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -1114,6 +1114,54 @@ "type": { "type": "string", "description": "A required string specifying the type of the condition.", + "const": "matches" + }, + "string": { + "type": "string", + "description": "A required string to search. This field supports macro expansion." + }, + "regex": { + "type": "string", + "description": "A required regular expression to search for. This field supports macro expansion." + } + }, + "required": [ + "type", + "string", + "regex" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "notMatches" + }, + "string": { + "type": "string", + "description": "A required string to search. This field supports macro expansion." + }, + "regex": { + "type": "string", + "description": "A required regular expression to search for. This field supports macro expansion." + } + }, + "required": [ + "type", + "string", + "regex" + ], + "additionalProperties": false + }, + { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", "const": "anyOf" }, "conditions": { diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index fbe9fe5..d44dfb3 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -11,6 +11,8 @@ #include +#include "cmsys/RegularExpression.hxx" + #include "cmCMakePresetsFileInternal.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" @@ -561,6 +563,24 @@ bool cmCMakePresetsFileInternal::InListCondition::Evaluate( return true; } +bool cmCMakePresetsFileInternal::MatchesCondition::Evaluate( + const std::vector& expanders, int version, + cm::optional& out) const +{ + std::string str = this->String; + CHECK_EXPAND(out, str, expanders, version); + std::string regexStr = this->Regex; + CHECK_EXPAND(out, regexStr, expanders, version); + + cmsys::RegularExpression regex; + if (!regex.compile(regexStr)) { + return false; + } + + out = regex.find(str); + return true; +} + bool cmCMakePresetsFileInternal::AnyAllOfCondition::Evaluate( const std::vector& expanders, int version, cm::optional& out) const diff --git a/Source/cmCMakePresetsFileInternal.h b/Source/cmCMakePresetsFileInternal.h index ffb6ce9..3269276 100644 --- a/Source/cmCMakePresetsFileInternal.h +++ b/Source/cmCMakePresetsFileInternal.h @@ -81,6 +81,16 @@ public: std::vector List; }; +class MatchesCondition : public cmCMakePresetsFile::Condition +{ +public: + bool Evaluate(const std::vector& expanders, int version, + cm::optional& out) const override; + + std::string String; + std::string Regex; +}; + class AnyAllOfCondition : public cmCMakePresetsFile::Condition { public: diff --git a/Source/cmCMakePresetsFileReadJSON.cxx b/Source/cmCMakePresetsFileReadJSON.cxx index e26e7b4..403fac6 100644 --- a/Source/cmCMakePresetsFileReadJSON.cxx +++ b/Source/cmCMakePresetsFileReadJSON.cxx @@ -93,6 +93,16 @@ auto const InListConditionHelper = .Bind("list"_s, &cmCMakePresetsFileInternal::InListCondition::List, ConditionStringListHelper, true); +auto const MatchesConditionHelper = + cmJSONObjectHelper(ReadFileResult::READ_OK, + ReadFileResult::INVALID_CONDITION, false) + .Bind("type"_s, nullptr, ConditionStringHelper, true) + .Bind("string"_s, &cmCMakePresetsFileInternal::MatchesCondition::String, + ConditionStringHelper, true) + .Bind("regex"_s, &cmCMakePresetsFileInternal::MatchesCondition::Regex, + ConditionStringHelper, true); + ReadFileResult SubConditionHelper( std::unique_ptr& out, const Json::Value* value); @@ -177,6 +187,16 @@ ReadFileResult ConditionHelper( return ReadFileResult::READ_OK; } + if (type == "matches" || type == "notMatches") { + auto c = cm::make_unique(); + CHECK_OK(MatchesConditionHelper(*c, value)); + out = std::move(c); + if (type == "notMatches") { + out = InvertCondition(std::move(out)); + } + return ReadFileResult::READ_OK; + } + if (type == "anyOf" || type == "allOf") { auto c = cm::make_unique(); diff --git a/Tests/RunCMake/CMakePresets/Conditions.json.in b/Tests/RunCMake/CMakePresets/Conditions.json.in index 9a01e2f..9c0c6bd 100644 --- a/Tests/RunCMake/CMakePresets/Conditions.json.in +++ b/Tests/RunCMake/CMakePresets/Conditions.json.in @@ -181,6 +181,63 @@ } }, { + "name": "MatchesTrue", + "inherits": "Base", + "condition": { + "type": "matches", + "string": "aaa", + "regex": "^a*$" + } + }, + { + "name": "MatchesFalse", + "inherits": "Base", + "condition": { + "type": "matches", + "string": "aab", + "regex": "^a*$" + } + }, + { + "name": "MatchesMacroString", + "inherits": "Base", + "condition": { + "type": "matches", + "string": "${presetName}", + "regex": "^Matches" + } + }, + { + "name": "MatchesMacroRegex", + "inherits": "Base", + "condition": { + "type": "matches", + "string": "stuff", + "regex": "$env{CONDITION_REGEX}" + }, + "environment": { + "CONDITION_REGEX": "^stuf*$" + } + }, + { + "name": "NotMatchesTrue", + "inherits": "Base", + "condition": { + "type": "notMatches", + "string": "aab", + "regex": "^a*$" + } + }, + { + "name": "NotMatchesFalse", + "inherits": "Base", + "condition": { + "type": "notMatches", + "string": "aaa", + "regex": "^a*$" + } + }, + { "name": "AnyOfTrue1", "inherits": "Base", "condition": { diff --git a/Tests/RunCMake/CMakePresets/InvalidRegex-result.txt b/Tests/RunCMake/CMakePresets/InvalidRegex-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRegex-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/InvalidRegex-stderr.txt b/Tests/RunCMake/CMakePresets/InvalidRegex-stderr.txt new file mode 100644 index 0000000..5b500e4 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRegex-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresets/InvalidRegex: Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresets/InvalidRegex.json.in b/Tests/RunCMake/CMakePresets/InvalidRegex.json.in new file mode 100644 index 0000000..69114d2 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/InvalidRegex.json.in @@ -0,0 +1,15 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "InvalidRegex", + "binaryDir": "${sourceDir}/build", + "generator": "@RunCMake_GENERATOR@", + "condition": { + "type": "matches", + "string": "a", + "regex": "+" + } + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt b/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt index 19f91d4..91e0017 100644 --- a/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt +++ b/Tests/RunCMake/CMakePresets/ListConditions-stdout.txt @@ -12,6 +12,10 @@ Available configure presets: "InListMacroList" "InListShortCircuit" "NotInListTrue" + "MatchesTrue" + "MatchesMacroString" + "MatchesMacroRegex" + "NotMatchesTrue" "AnyOfTrue1" "AnyOfTrue2" "AnyOfShortCircuit" diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 22425b2..9523430 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -117,6 +117,7 @@ run_cmake_presets(NoSuchMacro) run_cmake_presets(EnvCycle) run_cmake_presets(EmptyEnv) run_cmake_presets(EmptyPenv) +run_cmake_presets(InvalidRegex) set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) run_cmake_presets(ConditionFuture) run_cmake_presets(SubConditionNull) -- cgit v0.12 From a8d2f7f459b861bee52990db9c1ed9f603dc6ef9 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 1 Apr 2021 00:01:23 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6604148..9893e4b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210331) +set(CMake_VERSION_PATCH 20210401) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 34c8a23044eaf8d56f405c4c9f13b53d0b47c963 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Thu, 1 Apr 2021 22:28:24 +0200 Subject: CPackRPM: add scriplets tags only if scripts exist Scriplet tags should not be added to generated spec files if scripts weren't provided as those tags are otherwise present in generated rpm file even if the script wasn't provided thereby generating unneeded dependency on shell. Fixes: #21345 --- Modules/Internal/CPack/CPackRPM.cmake | 103 ++++++++++++------- Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 +- .../tests/INSTALL_SCRIPTS/ExpectedFiles.cmake | 2 +- ...MPONENT-no_scripts_single_debug_info-stderr.txt | 1 + .../INSTALL_SCRIPTS/RPM-Prerequirements.cmake | 2 +- .../CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake | 39 +++++--- .../CPack/tests/INSTALL_SCRIPTS/test.cmake | 110 +++++++++++---------- 7 files changed, 153 insertions(+), 106 deletions(-) create mode 100644 Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-no_scripts_single_debug_info-stderr.txt diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index faaff7b..bece2dd 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -6,6 +6,56 @@ cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # if IN_LIST +function(set_spec_script_if_enabled TYPE PACKAGE_NAME VAR) + if(NOT "${VAR}" STREQUAL "" AND NOT "${VAR}" STREQUAL "\n") + if(PACKAGE_NAME) + set(PACKAGE_NAME " -n ${PACKAGE_NAME}") + endif() + set(${TYPE}_ + "%${TYPE}${PACKAGE_NAME}\n" + "${VAR}\n" PARENT_SCOPE) + else() + set(${TYPE} "" PARENT_SCOPE) + endif() +endfunction() + +macro(set_spec_scripts PACKAGE_NAME) + # we should only set scripts that were provided + # as script announcement without content inside + # spec file will generate unneeded dependency + # on shell + + set_spec_script_if_enabled( + "post" + "${PACKAGE_NAME}" + "${RPM_SYMLINK_POSTINSTALL}\n${CPACK_RPM_SPEC_POSTINSTALL}") + + set_spec_script_if_enabled( + "posttrans" + "${PACKAGE_NAME}" + "${CPACK_RPM_SPEC_POSTTRANS}") + + set_spec_script_if_enabled( + "postun" + "${PACKAGE_NAME}" + "${CPACK_RPM_SPEC_POSTUNINSTALL}") + + set_spec_script_if_enabled( + "pre" + "${PACKAGE_NAME}" + "${CPACK_RPM_SPEC_PREINSTALL}") + + set_spec_script_if_enabled( + "pretrans" + "${PACKAGE_NAME}" + "${CPACK_RPM_SPEC_PRETRANS}") + + set_spec_script_if_enabled( + "preun" + "${PACKAGE_NAME}" + "${CPACK_RPM_SPEC_PREUNINSTALL}") +endmacro() + function(get_file_permissions FILE RETURN_VAR) execute_process(COMMAND ls -l ${FILE} OUTPUT_VARIABLE permissions_ @@ -1613,6 +1663,9 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ ) elseif(GENERATE_SPEC_PARTS) # binary rpm with single debuginfo package + + set_spec_scripts("${CPACK_RPM_PACKAGE_NAME}") + file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- %package -n \@CPACK_RPM_PACKAGE_NAME\@ @@ -1643,24 +1696,12 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ %description -n \@CPACK_RPM_PACKAGE_NAME\@ \@CPACK_RPM_PACKAGE_DESCRIPTION\@ -%post -n \@CPACK_RPM_PACKAGE_NAME\@ -\@RPM_SYMLINK_POSTINSTALL\@ -\@CPACK_RPM_SPEC_POSTINSTALL\@ - -%posttrans -n \@CPACK_RPM_PACKAGE_NAME\@ -\@CPACK_RPM_SPEC_POSTTRANS\@ - -%postun -n \@CPACK_RPM_PACKAGE_NAME\@ -\@CPACK_RPM_SPEC_POSTUNINSTALL\@ - -%pre -n \@CPACK_RPM_PACKAGE_NAME\@ -\@CPACK_RPM_SPEC_PREINSTALL\@ - -%pretrans -n \@CPACK_RPM_PACKAGE_NAME\@ -\@CPACK_RPM_SPEC_PRETRANS\@ - -%preun -n \@CPACK_RPM_PACKAGE_NAME\@ -\@CPACK_RPM_SPEC_PREUNINSTALL\@ +\@post_\@ +\@posttrans_\@ +\@postun_\@ +\@pre_\@ +\@pretrans_\@ +\@preun_\@ %files -n \@CPACK_RPM_PACKAGE_NAME\@ %defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@) @@ -1687,6 +1728,8 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ set(RPMBUILD_FLAGS "-bb") if(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) + set_spec_scripts("") + file(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# Restore old style debuginfo creation for rpm >= 4.14. %undefine _debugsource_packages @@ -1750,24 +1793,12 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT %clean -%post -\@RPM_SYMLINK_POSTINSTALL\@ -\@CPACK_RPM_SPEC_POSTINSTALL\@ - -%posttrans -\@CPACK_RPM_SPEC_POSTTRANS\@ - -%postun -\@CPACK_RPM_SPEC_POSTUNINSTALL\@ - -%pre -\@CPACK_RPM_SPEC_PREINSTALL\@ - -%pretrans -\@CPACK_RPM_SPEC_PRETRANS\@ - -%preun -\@CPACK_RPM_SPEC_PREUNINSTALL\@ +\@post_\@ +\@posttrans_\@ +\@postun_\@ +\@pre_\@ +\@pretrans_\@ +\@preun_\@ %files %defattr(\@TMP_DEFAULT_FILE_PERMISSIONS\@,\@TMP_DEFAULT_USER\@,\@TMP_DEFAULT_GROUP\@,\@TMP_DEFAULT_DIR_PERMISSIONS\@) diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 48b9c1d..a3c72a1 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -16,7 +16,7 @@ run_cpack_test(VERSION "RPM.VERSION;DEB.VERSION" false "MONOLITHIC;COMPONENT") run_cpack_test(EXTRA "DEB.EXTRA" false "COMPONENT") run_cpack_test_subtests(GENERATE_SHLIBS "soversion_not_zero;soversion_zero" "DEB.GENERATE_SHLIBS" true "COMPONENT") run_cpack_test(GENERATE_SHLIBS_LDCONFIG "DEB.GENERATE_SHLIBS_LDCONFIG" true "COMPONENT") -run_cpack_test_subtests(INSTALL_SCRIPTS "default;single_debug_info" "RPM.INSTALL_SCRIPTS" false "COMPONENT") +run_cpack_test_subtests(INSTALL_SCRIPTS "default;single_debug_info;no_scripts;no_scripts_single_debug_info" "RPM.INSTALL_SCRIPTS" false "COMPONENT") run_cpack_test(LONG_FILENAMES "DEB.LONG_FILENAMES" false "MONOLITHIC") run_cpack_test_subtests(MAIN_COMPONENT "invalid;found" "RPM.MAIN_COMPONENT" false "COMPONENT") run_cpack_test(MINIMAL "RPM.MINIMAL;DEB.MINIMAL;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ;External" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake index 29e36a3..5a87c44 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/ExpectedFiles.cmake @@ -1,4 +1,4 @@ -if(RunCMake_SUBTEST_SUFFIX STREQUAL "single_debug_info") +if(RunCMake_SUBTEST_SUFFIX MATCHES ".*single_debug_info") set(EXPECTED_FILE_1 "install_scripts-0.1.1-1.*.rpm") else() set(EXPECTED_FILE_1_COMPONENT "foo") diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-no_scripts_single_debug_info-stderr.txt b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-no_scripts_single_debug_info-stderr.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-COMPONENT-no_scripts_single_debug_info-stderr.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake index c5d20cc..90cfe44 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/RPM-Prerequirements.cmake @@ -1,5 +1,5 @@ function(get_test_prerequirements found_var config_file) - if(SUBTEST_SUFFIX STREQUAL "single_debug_info") + if(SUBTEST_SUFFIX MATCHES ".*single_debug_info") include(${config_file}) if(OBJDUMP_EXECUTABLE) diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake index 1a1e983..0c42d90 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake @@ -7,23 +7,34 @@ function(checkScripts_ FILE COMPARE_LIST) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}") + if(COMPARE_LIST STREQUAL "") + if(NOT FILE_SCRIPTS_ STREQUAL "") + message(FATAL_ERROR "No scripts were expected in '${FILE}'; file info: '${FILE_SCRIPTS_}'") + endif() + else() + string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) - foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) - unset(FOUND_) + foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() - foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_) - if(COMPARE_ MATCHES "${COMPARE_REGEX_}") - set(FOUND_ true) - break() + if(NOT FOUND_) + message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'") endif() endforeach() - - if(NOT FOUND_) - message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'") - endif() - endforeach() + endif() endfunction() -checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\";echo \"pre trans foo\";echo \"post trans foo\"") -checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\";echo \"pre trans\";echo \"post trans\"") +if(RunCMake_SUBTEST_SUFFIX MATCHES "no_scripts.*") + checkScripts_("${FOUND_FILE_1}" "") + checkScripts_("${FOUND_FILE_2}" "") +else() + checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\";echo \"pre trans foo\";echo \"post trans foo\"") + checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\";echo \"pre trans\";echo \"post trans\"") +endif() diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake index 6877c57..ce5db0c 100644 --- a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/test.cmake @@ -1,31 +1,5 @@ if(GENERATOR_TYPE STREQUAL "RPM") - set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") - set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") - set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") - set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") - set(CPACK_RPM_PRE_TRANS_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_trans.sh") - set(CPACK_RPM_POST_TRANS_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_trans.sh") - - set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") - set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") - set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") - set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") - set(CPACK_RPM_foo_PRE_TRANS_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/pre_trans_foo.sh") - set(CPACK_RPM_foo_POST_TRANS_SCRIPT_FILE - "${CMAKE_CURRENT_BINARY_DIR}/post_trans_foo.sh") - - if(RunCMake_SUBTEST_SUFFIX STREQUAL "single_debug_info") + if(RunCMake_SUBTEST_SUFFIX MATCHES ".*single_debug_info") set(CPACK_RPM_MAIN_COMPONENT "foo") set(CPACK_RPM_DEBUGINFO_SINGLE_PACKAGE ON) set(CPACK_RPM_FOO_FILE_NAME "RPM-DEFAULT") @@ -34,33 +8,63 @@ endif() set(CMAKE_BUILD_WITH_INSTALL_RPATH 1) -# default -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh" - "echo \"pre install\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh" - "echo \"post install\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh" - "echo \"pre uninstall\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh" - "echo \"post uninstall\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_trans.sh" - "echo \"pre trans\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_trans.sh" - "echo \"post trans\"\n") +if(NOT RunCMake_SUBTEST_SUFFIX MATCHES "no_scripts.*") + if(GENERATOR_TYPE STREQUAL "RPM") + set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh") + set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh") + set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh") + set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh") + set(CPACK_RPM_PRE_TRANS_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_trans.sh") + set(CPACK_RPM_POST_TRANS_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_trans.sh") + + set(CPACK_RPM_foo_PRE_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh") + set(CPACK_RPM_foo_POST_INSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh") + set(CPACK_RPM_foo_PRE_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh") + set(CPACK_RPM_foo_POST_UNINSTALL_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh") + set(CPACK_RPM_foo_PRE_TRANS_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/pre_trans_foo.sh") + set(CPACK_RPM_foo_POST_TRANS_SCRIPT_FILE + "${CMAKE_CURRENT_BINARY_DIR}/post_trans_foo.sh") + endif() + + # default + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install.sh" + "echo \"pre install\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install.sh" + "echo \"post install\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall.sh" + "echo \"pre uninstall\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall.sh" + "echo \"post uninstall\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_trans.sh" + "echo \"pre trans\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_trans.sh" + "echo \"post trans\"\n") -# specific -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh" - "echo \"pre install foo\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh" - "echo \"post install foo\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh" - "echo \"pre uninstall foo\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh" - "echo \"post uninstall foo\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_trans_foo.sh" - "echo \"pre trans foo\"\n") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_trans_foo.sh" - "echo \"post trans foo\"\n") + # specific + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_install_foo.sh" + "echo \"pre install foo\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_install_foo.sh" + "echo \"post install foo\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_uninstall_foo.sh" + "echo \"pre uninstall foo\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_uninstall_foo.sh" + "echo \"post uninstall foo\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/pre_trans_foo.sh" + "echo \"pre trans foo\"\n") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/post_trans_foo.sh" + "echo \"post trans foo\"\n") +endif() install(FILES CMakeLists.txt DESTINATION foo COMPONENT foo) install(FILES CMakeLists.txt DESTINATION bar COMPONENT bar) -- cgit v0.12 From ce1cadd35a26bd44879675581d8e70b00ff8e0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?= Date: Thu, 1 Apr 2021 20:14:06 +0700 Subject: Tests/ConfigSources: fix for non main stream CMAKE_BUILD_TYPE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - None is a valid CMAKE_BUILD_TYPE - Most of distros uses None as CMAKE_BUILD_TYPE - When CMAKE_BUILD_TYPE=None, main_other.cpp will be compiled and linked into final executable, this program requires some symbols only exist when CUSTOM_CFG_OTHER is defined. - And CMake also allows other CMAKE_BUILD_TYPE, too, CMake documentation specificaly mentions funny CMAKE_BUILD_TYPE like ReLeAsE [1] Let's define them when non main stream like None is specified as CMAKE_BUILD_TYPE. [1]: https://cmake.org/cmake/help/v3.20/variable/CMAKE_BUILD_TYPE.html --- Tests/ConfigSources/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt index a3d98f6..f83759c 100644 --- a/Tests/ConfigSources/CMakeLists.txt +++ b/Tests/ConfigSources/CMakeLists.txt @@ -74,10 +74,10 @@ add_custom_command(APPEND VERBATIM ) foreach(n RANGE 1 5) - set_property(SOURCE custom${n}_Debug.cpp PROPERTY COMPILE_DEFINITIONS CUSTOM_CFG_DEBUG) - foreach(other Release RelWithDebInfo MinSizeRel) + foreach(other ${CMAKE_BUILD_TYPE} Release RelWithDebInfo MinSizeRel) set_property(SOURCE custom${n}_${other}.cpp PROPERTY COMPILE_DEFINITIONS CUSTOM_CFG_OTHER) endforeach() + set_property(SOURCE custom${n}_Debug.cpp PROPERTY COMPILE_DEFINITIONS CUSTOM_CFG_DEBUG) endforeach() add_library(Custom STATIC custom1_$.cpp -- cgit v0.12 From 55843b899ed1ef52e3c4746ae98c3c4a396760c1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 2 Apr 2021 00:01:22 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9893e4b..e1d460f 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210401) +set(CMake_VERSION_PATCH 20210402) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From d904b74c9e6b5d1eb0053d87463eed0afc198fc1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 3 Apr 2021 00:01:54 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e1d460f..feee9c9 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210402) +set(CMake_VERSION_PATCH 20210403) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 20e90c08e3b1fa60b69442d384bcc236ff6f8a21 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 4 Apr 2021 00:01:11 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index feee9c9..84568e0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210403) +set(CMake_VERSION_PATCH 20210404) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From f6c47dd0b415f1542472ae785b52d05afa444f2a Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sun, 4 Apr 2021 10:57:14 +0100 Subject: Help: Fix a typo in the AUTOGEN_SOURCE_GROUP help --- Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst index 2e32320..f9c5f48 100644 --- a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst +++ b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst @@ -9,7 +9,7 @@ Name of the :command:`source_group` for :prop_tgt:`AUTOMOC` and Files generated by :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` are not always known at configure time and therefore can't be passed to :command:`source_group`. -:prop_gbl:`AUTOGEN_SOURCE_GROUP` an be used instead to generate or select +:prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used instead to generate or select a source group for :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` generated files. For :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` specific overrides see -- cgit v0.12 From 7f0151dc91805617cbc1d538ec9df2b34e0477d6 Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sun, 4 Apr 2021 10:59:50 +0100 Subject: Help: Document the AUTOUIC_SOURCE_GROUP property This property came into existence with the changes in b4a103bdecc437d37580d0ab540f6014006d661c because generated files are now being added for UIC. --- Auxiliary/vim/syntax/cmake.vim | 1 + Help/manual/cmake-properties.7.rst | 1 + Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst | 19 ++++++++++--------- Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst | 9 +++++++++ Help/prop_sf/GENERATED.rst | 7 ++++--- 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 955beae..067f80d 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -92,6 +92,7 @@ syn keyword cmakeProperty contained \ AUTOUIC_EXECUTABLE \ AUTOUIC_OPTIONS \ AUTOUIC_SEARCH_PATHS + \ AUTOUIC_SOURCE_GROUP \ BINARY_DIR \ BUILDSYSTEM_TARGETS \ BUILD_RPATH diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index af170da..60a4028 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -21,6 +21,7 @@ Properties of Global Scope /prop_gbl/AUTOMOC_SOURCE_GROUP /prop_gbl/AUTOMOC_TARGETS_FOLDER /prop_gbl/AUTORCC_SOURCE_GROUP + /prop_gbl/AUTOUIC_SOURCE_GROUP /prop_gbl/CMAKE_C_KNOWN_FEATURES /prop_gbl/CMAKE_CUDA_KNOWN_FEATURES /prop_gbl/CMAKE_CXX_KNOWN_FEATURES diff --git a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst index f9c5f48..07c732b 100644 --- a/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst +++ b/Help/prop_gbl/AUTOGEN_SOURCE_GROUP.rst @@ -3,15 +3,16 @@ AUTOGEN_SOURCE_GROUP .. versionadded:: 3.9 -Name of the :command:`source_group` for :prop_tgt:`AUTOMOC` and -:prop_tgt:`AUTORCC` generated files. +Name of the :command:`source_group` for :prop_tgt:`AUTOMOC`, +:prop_tgt:`AUTORCC` and :prop_tgt:`AUTOUIC` generated files. -Files generated by :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` are not always -known at configure time and therefore can't be passed to -:command:`source_group`. +Files generated by :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC` and +:prop_tgt:`AUTOUIC` are not always known at configure time and therefore can't +be passed to :command:`source_group`. :prop_gbl:`AUTOGEN_SOURCE_GROUP` can be used instead to generate or select -a source group for :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` generated files. +a source group for :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC` and +:prop_tgt:`AUTOUIC` generated files. -For :prop_tgt:`AUTOMOC` and :prop_tgt:`AUTORCC` specific overrides see -:prop_gbl:`AUTOMOC_SOURCE_GROUP` and :prop_gbl:`AUTORCC_SOURCE_GROUP` -respectively. +For :prop_tgt:`AUTOMOC`, :prop_tgt:`AUTORCC` and :prop_tgt:`AUTOUIC` specific +overrides see :prop_gbl:`AUTOMOC_SOURCE_GROUP`, :prop_gbl:`AUTORCC_SOURCE_GROUP` +and :prop_gbl:`AUTOUIC_SOURCE_GROUP` respectively. diff --git a/Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst b/Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst new file mode 100644 index 0000000..79ebfe0 --- /dev/null +++ b/Help/prop_gbl/AUTOUIC_SOURCE_GROUP.rst @@ -0,0 +1,9 @@ +AUTOUIC_SOURCE_GROUP +-------------------- + +.. versionadded:: 3.21 + +Name of the :command:`source_group` for :prop_tgt:`AUTOUIC` generated files. + +When set this is used instead of :prop_gbl:`AUTOGEN_SOURCE_GROUP` for +files generated by :prop_tgt:`AUTOUIC`. diff --git a/Help/prop_sf/GENERATED.rst b/Help/prop_sf/GENERATED.rst index 6ef4580..216dfe8 100644 --- a/Help/prop_sf/GENERATED.rst +++ b/Help/prop_sf/GENERATED.rst @@ -32,9 +32,10 @@ The :ref:`Makefile Generators` will remove ``GENERATED`` files during ``make clean``. Generated sources may be hidden in some IDE tools, while in others they might -be shown. For the special case of sources generated by CMake's :prop_tgt:`AUTOMOC` -or :prop_tgt:`AUTORCC` functionality, the :prop_gbl:`AUTOGEN_SOURCE_GROUP`, -:prop_gbl:`AUTOMOC_SOURCE_GROUP` and :prop_gbl:`AUTORCC_SOURCE_GROUP` target +be shown. For the special case of sources generated by CMake's :prop_tgt:`AUTOMOC`, +:prop_tgt:`AUTORCC` or :prop_tgt:`AUTOUIC` functionality, the +:prop_gbl:`AUTOGEN_SOURCE_GROUP`, :prop_gbl:`AUTOMOC_SOURCE_GROUP`, +:prop_gbl:`AUTORCC_SOURCE_GROUP` and :prop_gbl:`AUTOUIC_SOURCE_GROUP` target properties may influence where the generated sources are grouped in the project's file lists. -- cgit v0.12 From e8ddc1e268d2db78a2f3edde1f6edb05d9243ada Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sun, 4 Apr 2021 12:21:59 +0100 Subject: Autogen: Fix a bug in setting the UIC source group If the relative path to a UI file was empty then the source group for the corresponding autogen header file would not apply because of a double slash in the path. --- Source/cmQtAutoGenInitializer.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 6528687..e96ec63 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -943,8 +943,14 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->LocalGen->GetCurrentSourceDirectory(), cmSystemTools::GetFilenamePath(fullPath)); + // Avoid creating a path containing adjacent slashes + if (!uiHeaderRelativePath.empty() && + uiHeaderRelativePath.back() != '/') { + uiHeaderRelativePath += '/'; + } + auto uiHeaderFilePath = cmStrCat( - '/', uiHeaderRelativePath, '/', "ui_"_s, + '/', uiHeaderRelativePath, "ui_"_s, cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s); ConfigString uiHeader; -- cgit v0.12 From 3d700254f4c4b7e4dde61ea16991964d221185ad Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 5 Apr 2021 00:01:24 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 84568e0..ef5f2e4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210404) +set(CMake_VERSION_PATCH 20210405) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From f6b4db365a5e5723029c06357e81aa6c93ba1f76 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Sun, 4 Apr 2021 22:57:58 +0200 Subject: Tests: bump cmake_minimum_required version to 2.8.12 This needlessly produces warnings during the test runs that no-one sees but that are distracting when actually inspecting the logs. --- Tests/BundleGeneratorTest/CMakeLists.txt | 2 +- Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt | 2 +- Tests/CMakeOnly/CheckLanguage/CMakeLists.txt | 2 +- Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt | 2 +- Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt | 2 +- Tests/CMakeOnly/TargetScope/CMakeLists.txt | 2 +- Tests/CPackComponents/CMakeLists.txt | 2 +- Tests/CTestTest2/test.cmake.in | 2 +- Tests/CTestTestBadExe/test.cmake.in | 2 +- Tests/CTestTestChecksum/test.cmake.in | 2 +- Tests/CTestTestCostSerial/test.cmake.in | 2 +- Tests/CTestTestCrash/CMakeLists.txt | 2 +- Tests/CTestTestCrash/test.cmake.in | 2 +- Tests/CTestTestCycle/CMakeLists.txt | 2 +- Tests/CTestTestCycle/test.cmake.in | 2 +- Tests/CTestTestDepends/CMakeLists.txt | 2 +- Tests/CTestTestDepends/test.cmake.in | 2 +- Tests/CTestTestFailure/CMakeLists.txt | 2 +- Tests/CTestTestFailure/testNoBuild.cmake.in | 2 +- Tests/CTestTestFailure/testNoExe.cmake.in | 2 +- Tests/CTestTestParallel/CMakeLists.txt | 2 +- Tests/CTestTestParallel/test.cmake.in | 2 +- Tests/CTestTestResourceLock/CMakeLists.txt | 2 +- Tests/CTestTestResourceLock/test.cmake.in | 2 +- Tests/CTestTestScheduler/CMakeLists.txt | 2 +- Tests/CTestTestScheduler/test.cmake.in | 2 +- Tests/CTestTestSkipReturnCode/test.cmake.in | 2 +- Tests/CTestTestStopTime/CMakeLists.txt | 2 +- Tests/CTestTestStopTime/test.cmake.in | 2 +- Tests/CTestTestSubdir/CMakeLists.txt | 2 +- Tests/CTestTestSubdir/test.cmake.in | 2 +- Tests/CTestTestTimeout/test.cmake.in | 2 +- Tests/CTestTestUpload/CMakeLists.txt | 2 +- Tests/CTestTestUpload/test.cmake.in | 2 +- Tests/CTestTestVerboseOutput/CMakeLists.txt | 2 +- Tests/CTestTestVerboseOutput/test.cmake.in | 2 +- Tests/CTestTestZeroTimeout/CMakeLists.txt | 2 +- Tests/CTestTestZeroTimeout/test.cmake.in | 2 +- Tests/CustomCommand/CMakeLists.txt | 2 +- Tests/CustomCommandWorkingDirectory/CMakeLists.txt | 2 +- Tests/Dependency/CMakeLists.txt | 2 +- Tests/Framework/CMakeLists.txt | 2 +- Tests/FunctionTest/CMakeLists.txt | 2 +- Tests/JCTest/CMakeLists.txt | 2 +- Tests/Java/CMakeLists.txt | 2 +- Tests/JavaJavah/CMakeLists.txt | 2 +- Tests/JavaNativeHeaders/CMakeLists.txt | 2 +- Tests/LoadCommand/CMakeCommands/CMakeLists.txt | 2 +- Tests/LoadCommand/CMakeLists.txt | 2 +- Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt | 2 +- Tests/LoadCommandOneConfig/CMakeLists.txt | 2 +- Tests/MakeClean/CMakeLists.txt | 2 +- Tests/ModuleDefinition/CMakeLists.txt | 2 +- Tests/NewlineArgs/CMakeLists.txt | 2 +- Tests/Plugin/CMakeLists.txt | 4 ++-- Tests/Preprocess/CMakeLists.txt | 2 +- Tests/ReturnTest/CMakeLists.txt | 2 +- Tests/StringFileTest/CMakeLists.txt | 2 +- Tests/SubDirSpaces/CMakeLists.txt | 2 +- Tests/TargetName/CMakeLists.txt | 2 +- Tests/TestDriver/CMakeLists.txt | 2 +- Tests/TestsWorkingDirectory/CMakeLists.txt | 2 +- Tests/TryCompile/CMakeLists.txt | 2 +- Tests/TryCompile/Inner/CMakeLists.txt | 2 +- Tests/VSExternalInclude/CMakeLists.txt | 2 +- 65 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Tests/BundleGeneratorTest/CMakeLists.txt b/Tests/BundleGeneratorTest/CMakeLists.txt index 037df09..cf7e2ce 100644 --- a/Tests/BundleGeneratorTest/CMakeLists.txt +++ b/Tests/BundleGeneratorTest/CMakeLists.txt @@ -1,6 +1,6 @@ project(BundleGeneratorTest) -cmake_minimum_required(VERSION 2.7) +cmake_minimum_required(VERSION 2.8.12) # Build a shared library and install it in lib/ add_library(Library SHARED Library.cxx) diff --git a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt index 2028a13..2784e3b 100644 --- a/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckCXXSymbolExists/CMakeLists.txt @@ -9,7 +9,7 @@ project(CheckCXXSymbolExists CXX) -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/../CheckSymbolExists") diff --git a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt index 1570c37..2e5d8d3 100644 --- a/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckLanguage/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project(CheckLanguage NONE) include(CheckLanguage) diff --git a/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt index 7f01463..9a9bb2a 100644 --- a/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt +++ b/Tests/CMakeOnly/CheckSymbolExists/CMakeLists.txt @@ -9,7 +9,7 @@ project(CheckSymbolExists C) -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) set(CMAKE_REQUIRED_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt b/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt index 56e449a..d66eb06 100644 --- a/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt +++ b/Tests/CMakeOnly/LinkInterfaceLoop/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project(LinkInterfaceLoop C) # Add a shared library that incorrectly names itself as a diff --git a/Tests/CMakeOnly/TargetScope/CMakeLists.txt b/Tests/CMakeOnly/TargetScope/CMakeLists.txt index fa5d8e2..faf2250 100644 --- a/Tests/CMakeOnly/TargetScope/CMakeLists.txt +++ b/Tests/CMakeOnly/TargetScope/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project(TargetScope NONE) add_subdirectory(Sub) diff --git a/Tests/CPackComponents/CMakeLists.txt b/Tests/CPackComponents/CMakeLists.txt index 5b03c9e..c1b348e 100644 --- a/Tests/CPackComponents/CMakeLists.txt +++ b/Tests/CPackComponents/CMakeLists.txt @@ -4,7 +4,7 @@ # application (mylibapp). We create a binary installer that allows # users to select which pieces will be installed: the example # application, the library binaries, and/or the header file. -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(CPackComponents) # Create the mylib library diff --git a/Tests/CTestTest2/test.cmake.in b/Tests/CTestTest2/test.cmake.in index a9bbc52..d5d4d2f 100644 --- a/Tests/CTestTest2/test.cmake.in +++ b/Tests/CTestTest2/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in index 43a8572..dd180f0 100644 --- a/Tests/CTestTestBadExe/test.cmake.in +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in index 2a435d2..3bac0e0 100644 --- a/Tests/CTestTestChecksum/test.cmake.in +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in index 9b32a46..1c46d4c 100644 --- a/Tests/CTestTestCostSerial/test.cmake.in +++ b/Tests/CTestTestCostSerial/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestCrash/CMakeLists.txt b/Tests/CTestTestCrash/CMakeLists.txt index 77986df..663d2e4 100644 --- a/Tests/CTestTestCrash/CMakeLists.txt +++ b/Tests/CTestTestCrash/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestCrash) include(CTest) diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 3641cb0..916d4e9 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestCycle/CMakeLists.txt b/Tests/CTestTestCycle/CMakeLists.txt index 6ba6b8c..19f4dd7 100644 --- a/Tests/CTestTestCycle/CMakeLists.txt +++ b/Tests/CTestTestCycle/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestCycle) include(CTest) diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in index 4a63dd6..507d46b 100644 --- a/Tests/CTestTestCycle/test.cmake.in +++ b/Tests/CTestTestCycle/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestDepends/CMakeLists.txt b/Tests/CTestTestDepends/CMakeLists.txt index 5cd6d66..462ad8c 100644 --- a/Tests/CTestTestDepends/CMakeLists.txt +++ b/Tests/CTestTestDepends/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestDepends) include(CTest) diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in index 74fddb3..11bc92a 100644 --- a/Tests/CTestTestDepends/test.cmake.in +++ b/Tests/CTestTestDepends/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestFailure/CMakeLists.txt b/Tests/CTestTestFailure/CMakeLists.txt index 01fbb2c..db14b3d 100644 --- a/Tests/CTestTestFailure/CMakeLists.txt +++ b/Tests/CTestTestFailure/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestFailure) include(CTest) diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index 86333af..47d254f 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index 8875cee..8496c80 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestParallel/CMakeLists.txt b/Tests/CTestTestParallel/CMakeLists.txt index e47085a..819fee4 100644 --- a/Tests/CTestTestParallel/CMakeLists.txt +++ b/Tests/CTestTestParallel/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestParallel) include(CTest) diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index 045a4ca..517db72 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestResourceLock/CMakeLists.txt b/Tests/CTestTestResourceLock/CMakeLists.txt index 4001643..4bc4366 100644 --- a/Tests/CTestTestResourceLock/CMakeLists.txt +++ b/Tests/CTestTestResourceLock/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestResourceLock) include(CTest) diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in index 67dde18..826226d 100644 --- a/Tests/CTestTestResourceLock/test.cmake.in +++ b/Tests/CTestTestResourceLock/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestScheduler/CMakeLists.txt b/Tests/CTestTestScheduler/CMakeLists.txt index ccd7b2c..a3f0f27 100644 --- a/Tests/CTestTestScheduler/CMakeLists.txt +++ b/Tests/CTestTestScheduler/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project (CTestTestScheduler) include (CTest) diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in index f8c8ab7..5dcfb63 100644 --- a/Tests/CTestTestScheduler/test.cmake.in +++ b/Tests/CTestTestScheduler/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestSkipReturnCode/test.cmake.in b/Tests/CTestTestSkipReturnCode/test.cmake.in index 112b0cd..2988d2f 100644 --- a/Tests/CTestTestSkipReturnCode/test.cmake.in +++ b/Tests/CTestTestSkipReturnCode/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestStopTime/CMakeLists.txt b/Tests/CTestTestStopTime/CMakeLists.txt index bd8bebd..08116e2 100644 --- a/Tests/CTestTestStopTime/CMakeLists.txt +++ b/Tests/CTestTestStopTime/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestStopTime) include(CTest) diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in index d3a9a4a..3797d40 100644 --- a/Tests/CTestTestStopTime/test.cmake.in +++ b/Tests/CTestTestStopTime/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestSubdir/CMakeLists.txt b/Tests/CTestTestSubdir/CMakeLists.txt index b7cc7e2..87c4604 100644 --- a/Tests/CTestTestSubdir/CMakeLists.txt +++ b/Tests/CTestTestSubdir/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestSubdir) include(CTest) diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index 8b3957b..3b1fb5f 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index 4b5157e..ce9c497 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestUpload/CMakeLists.txt b/Tests/CTestTestUpload/CMakeLists.txt index 90d811c..5e02b2f 100644 --- a/Tests/CTestTestUpload/CMakeLists.txt +++ b/Tests/CTestTestUpload/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestUpload) add_executable (Sleep sleep.c) diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in index 701439d..74fd1ec 100644 --- a/Tests/CTestTestUpload/test.cmake.in +++ b/Tests/CTestTestUpload/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestVerboseOutput/CMakeLists.txt b/Tests/CTestTestVerboseOutput/CMakeLists.txt index 4cdd29c..3792385 100644 --- a/Tests/CTestTestVerboseOutput/CMakeLists.txt +++ b/Tests/CTestTestVerboseOutput/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CTestTestVerboseOutput) include(CTest) diff --git a/Tests/CTestTestVerboseOutput/test.cmake.in b/Tests/CTestTestVerboseOutput/test.cmake.in index 7f49548..9c9a4dc 100644 --- a/Tests/CTestTestVerboseOutput/test.cmake.in +++ b/Tests/CTestTestVerboseOutput/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CTestTestZeroTimeout/CMakeLists.txt b/Tests/CTestTestZeroTimeout/CMakeLists.txt index 4d2b79d..2d404c8 100644 --- a/Tests/CTestTestZeroTimeout/CMakeLists.txt +++ b/Tests/CTestTestZeroTimeout/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project (CTestTestZeroTimeout) include (CTest) diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in index b829fef..50dbba0 100644 --- a/Tests/CTestTestZeroTimeout/test.cmake.in +++ b/Tests/CTestTestZeroTimeout/test.cmake.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.4) +cmake_minimum_required(VERSION 2.8.12) # Settings: set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 80545c4..11d005f 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -1,7 +1,7 @@ # # Wrapping # -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project (CustomCommand) add_subdirectory(GeneratedHeader) diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt index 3bab1fe..7697a9b 100644 --- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt +++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(TestWorkingDir) add_custom_command( diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt index ebc2d10..58d3fb7 100644 --- a/Tests/Dependency/CMakeLists.txt +++ b/Tests/Dependency/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project( Dependency ) # to test directories with only one character One was changed to 1 diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt index 6e82f86..287be94 100644 --- a/Tests/Framework/CMakeLists.txt +++ b/Tests/Framework/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(Framework) add_library(foo SHARED diff --git a/Tests/FunctionTest/CMakeLists.txt b/Tests/FunctionTest/CMakeLists.txt index 68da972..6450447 100644 --- a/Tests/FunctionTest/CMakeLists.txt +++ b/Tests/FunctionTest/CMakeLists.txt @@ -1,5 +1,5 @@ # a simple C only test case -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project (FunctionTest) function(FAILED testname) diff --git a/Tests/JCTest/CMakeLists.txt b/Tests/JCTest/CMakeLists.txt index 31dcc3a..b120640 100644 --- a/Tests/JCTest/CMakeLists.txt +++ b/Tests/JCTest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(TestTime) enable_testing() add_executable(TestTime TestTime.cxx) diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index aea4282..e4f2821 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -1,6 +1,6 @@ project(hello Java) -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) set(CMAKE_VERBOSE_MAKEFILE 1) include(CTest) diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt index 77c292a..b56cc21 100644 --- a/Tests/JavaJavah/CMakeLists.txt +++ b/Tests/JavaJavah/CMakeLists.txt @@ -1,6 +1,6 @@ project(helloJavah Java CXX) -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) set(CMAKE_VERBOSE_MAKEFILE 1) include(CTest) diff --git a/Tests/JavaNativeHeaders/CMakeLists.txt b/Tests/JavaNativeHeaders/CMakeLists.txt index f3cc89d..2471e01 100644 --- a/Tests/JavaNativeHeaders/CMakeLists.txt +++ b/Tests/JavaNativeHeaders/CMakeLists.txt @@ -1,6 +1,6 @@ project(helloJavaNativeHeaders Java CXX) -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) set(CMAKE_VERBOSE_MAKEFILE 1) include (CTest) diff --git a/Tests/LoadCommand/CMakeCommands/CMakeLists.txt b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt index 99b1aba..cafa99b 100644 --- a/Tests/LoadCommand/CMakeCommands/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeCommands/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CMAKE_LOADED_COMMANDS) if (MUDSLIDE_TYPE MATCHES MUCHO) diff --git a/Tests/LoadCommand/CMakeLists.txt b/Tests/LoadCommand/CMakeLists.txt index cfaebad..e1c4998 100644 --- a/Tests/LoadCommand/CMakeLists.txt +++ b/Tests/LoadCommand/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(LoadCommand) # set a definition diff --git a/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt index 5ee2ed0..dc029a4 100644 --- a/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt +++ b/Tests/LoadCommandOneConfig/CMakeCommands/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(CMAKE_LOADED_COMMANDS) if (MUDSLIDE_TYPE MATCHES MUCHO) diff --git a/Tests/LoadCommandOneConfig/CMakeLists.txt b/Tests/LoadCommandOneConfig/CMakeLists.txt index 65de042..fef4bb7 100644 --- a/Tests/LoadCommandOneConfig/CMakeLists.txt +++ b/Tests/LoadCommandOneConfig/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(LoadCommand) # set a definition diff --git a/Tests/MakeClean/CMakeLists.txt b/Tests/MakeClean/CMakeLists.txt index fbd4995..809d65b 100644 --- a/Tests/MakeClean/CMakeLists.txt +++ b/Tests/MakeClean/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(MakeClean) # Build the to-clean project. diff --git a/Tests/ModuleDefinition/CMakeLists.txt b/Tests/ModuleDefinition/CMakeLists.txt index e49ebea..567fb4b 100644 --- a/Tests/ModuleDefinition/CMakeLists.txt +++ b/Tests/ModuleDefinition/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(ModuleDefinition C) # Test .def file source recognition for DLLs. diff --git a/Tests/NewlineArgs/CMakeLists.txt b/Tests/NewlineArgs/CMakeLists.txt index 7551601..3e4b436 100644 --- a/Tests/NewlineArgs/CMakeLists.txt +++ b/Tests/NewlineArgs/CMakeLists.txt @@ -1,5 +1,5 @@ # a simple CXX only test case -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project (NewlineArgs CXX) add_definitions("-DTEST_FLAG_1 diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index 729bba3..ec22bf4 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) cmake_policy(SET CMP0054 NEW) project(Plugin) @@ -46,7 +46,7 @@ target_link_libraries(example_mod_1 example_exe) if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND "${CMAKE_C_CREATE_SHARED_MODULE}" MATCHES "SONAME_FLAG") # Verify that targets export with proper IMPORTED SONAME properties. - export(TARGETS example_mod_1 NAMESPACE exp_ + export(TARGETS example_mod_1 example_exe NAMESPACE exp_ FILE ${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) include(ExternalProject) diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index bf2af64..4347459 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(Preprocess) # This test is meant both as a test and as a reference for supported diff --git a/Tests/ReturnTest/CMakeLists.txt b/Tests/ReturnTest/CMakeLists.txt index c4c606c..78e3fc1 100644 --- a/Tests/ReturnTest/CMakeLists.txt +++ b/Tests/ReturnTest/CMakeLists.txt @@ -1,5 +1,5 @@ # a simple C only test case -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project (ReturnTest) function (FAILED testname) diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt index faf3bc9..068fae9 100644 --- a/Tests/StringFileTest/CMakeLists.txt +++ b/Tests/StringFileTest/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(StringFileTest) include_directories(${StringFileTest_BINARY_DIR}) diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt index 0d45db8..ecd4353 100644 --- a/Tests/SubDirSpaces/CMakeLists.txt +++ b/Tests/SubDirSpaces/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(SUBDIR) # Some systems do not seem to support rpath with spaces. diff --git a/Tests/TargetName/CMakeLists.txt b/Tests/TargetName/CMakeLists.txt index 9729d21..21752b7 100644 --- a/Tests/TargetName/CMakeLists.txt +++ b/Tests/TargetName/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(TargetName) add_subdirectory(executables) diff --git a/Tests/TestDriver/CMakeLists.txt b/Tests/TestDriver/CMakeLists.txt index 663ecab..3cc69c0 100644 --- a/Tests/TestDriver/CMakeLists.txt +++ b/Tests/TestDriver/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(TestDriverTest) set(Extra_SRCS testExtraStuff.cxx testExtraStuff2.cxx ) diff --git a/Tests/TestsWorkingDirectory/CMakeLists.txt b/Tests/TestsWorkingDirectory/CMakeLists.txt index 6a6e9b6..2a0b015 100644 --- a/Tests/TestsWorkingDirectory/CMakeLists.txt +++ b/Tests/TestsWorkingDirectory/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(TestsWorkingDirectoryProj) add_executable(WorkingDirectory main.c) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 0c6b938..fa0549f 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(TryCompile) macro(TEST_ASSERT value msg) diff --git a/Tests/TryCompile/Inner/CMakeLists.txt b/Tests/TryCompile/Inner/CMakeLists.txt index d62bcc4..d8c22d0 100644 --- a/Tests/TryCompile/Inner/CMakeLists.txt +++ b/Tests/TryCompile/Inner/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8.12) project(TryCompileInner C) try_compile(SHOULD_PASS diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt index 8ca7252..e38df8e 100644 --- a/Tests/VSExternalInclude/CMakeLists.txt +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8.12) project(VSExternalInclude) if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[012456]") -- cgit v0.12 From 5160204fc2654c70f46dcfc025b1676f7326a5e1 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 6 Apr 2021 00:01:30 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ef5f2e4..b7ca022 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210405) +set(CMake_VERSION_PATCH 20210406) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 3654068e80247f4f06a951d258f254da70aeef89 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 4 Apr 2021 08:04:22 -0400 Subject: FindHDF5: find include directories after the library Some include paths might depend on the library location (primarily for Fortran). --- Modules/FindHDF5.cmake | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index ec5ebdd..7bacfac 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -811,26 +811,6 @@ if( NOT HDF5_FOUND ) endif() foreach(_lang IN LISTS HDF5_LANGUAGE_BINDINGS) - # find the HDF5 include directories - if("${_lang}" STREQUAL "Fortran") - set(HDF5_INCLUDE_FILENAME hdf5.mod HDF5.mod) - elseif("${_lang}" STREQUAL "CXX") - set(HDF5_INCLUDE_FILENAME H5Cpp.h) - else() - set(HDF5_INCLUDE_FILENAME hdf5.h) - endif() - - find_path(HDF5_${_lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} - HINTS ${HDF5_ROOT} - PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} - ${_HDF5_SEARCH_OPTS} - ) - mark_as_advanced(HDF5_${_lang}_INCLUDE_DIR) - # set the _DIRS variable as this is what the user will normally use - set(HDF5_${_lang}_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) - list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) - # find the HDF5 libraries foreach(LIB IN LISTS HDF5_${_lang}_LIBRARY_NAMES) if(HDF5_USE_STATIC_LIBRARIES) @@ -872,6 +852,26 @@ if( NOT HDF5_FOUND ) # required libraries. list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_LIBRARIES}) + # find the HDF5 include directories + if("${_lang}" STREQUAL "Fortran") + set(HDF5_INCLUDE_FILENAME hdf5.mod HDF5.mod) + elseif("${_lang}" STREQUAL "CXX") + set(HDF5_INCLUDE_FILENAME H5Cpp.h) + else() + set(HDF5_INCLUDE_FILENAME hdf5.h) + endif() + + find_path(HDF5_${_lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} + HINTS ${HDF5_ROOT} + PATHS $ENV{HOME}/.local/include + PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} + ${_HDF5_SEARCH_OPTS} + ) + mark_as_advanced(HDF5_${_lang}_INCLUDE_DIR) + # set the _DIRS variable as this is what the user will normally use + set(HDF5_${_lang}_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) + list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) + if(HDF5_FIND_HL) foreach(LIB IN LISTS HDF5_${_lang}_HL_LIBRARY_NAMES) if(HDF5_USE_STATIC_LIBRARIES) -- cgit v0.12 From 78287ec0af1eb5f968df09c8b4321dd56510a429 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 4 Apr 2021 08:09:23 -0400 Subject: FindHDF5: track the "main" library for each language This will be used to build up additional include paths to search. --- Modules/FindHDF5.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 7bacfac..7eec6de 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -811,6 +811,9 @@ if( NOT HDF5_FOUND ) endif() foreach(_lang IN LISTS HDF5_LANGUAGE_BINDINGS) + # The "main" library. + set(_hdf5_main_library "") + # find the HDF5 libraries foreach(LIB IN LISTS HDF5_${_lang}_LIBRARY_NAMES) if(HDF5_USE_STATIC_LIBRARIES) @@ -841,6 +844,15 @@ if( NOT HDF5_FOUND ) ${_HDF5_SEARCH_OPTS} ) + # Set the "main" library if not already set. + if (NOT _hdf5_main_library) + if (HDF5_${LIB}_LIBRARY_RELEASE) + set(_hdf5_main_library "${HDF5_${LIB}_LIBRARY_RELEASE}") + elseif (HDF5_${LIB}_LIBRARY_DEBUG) + set(_hdf5_main_library "${HDF5_${LIB}_LIBRARY_DEBUG}") + endif () + endif () + select_library_configurations( HDF5_${LIB} ) list(APPEND HDF5_${_lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY}) endforeach() @@ -861,6 +873,8 @@ if( NOT HDF5_FOUND ) set(HDF5_INCLUDE_FILENAME hdf5.h) endif() + unset(_hdf5_main_library) + find_path(HDF5_${_lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} HINTS ${HDF5_ROOT} PATHS $ENV{HOME}/.local/include -- cgit v0.12 From cd48433e96820c5e1d219696bb48174843e9c15b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Sun, 4 Apr 2021 08:09:48 -0400 Subject: FindHDF5: add compiler-specific module search paths --- Modules/FindHDF5.cmake | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 7eec6de..e335355 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -865,8 +865,21 @@ if( NOT HDF5_FOUND ) list(APPEND HDF5_LIBRARIES ${HDF5_${_lang}_LIBRARIES}) # find the HDF5 include directories + set(_hdf5_inc_extra_paths) + set(_hdf5_inc_extra_suffixes) if("${_lang}" STREQUAL "Fortran") set(HDF5_INCLUDE_FILENAME hdf5.mod HDF5.mod) + + # Add library-based search paths for Fortran modules. + if (NOT _hdf5_main_library STREQUAL "") + # gfortran module directory + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + get_filename_component(_hdf5_library_dir "${_hdf5_main_library}" DIRECTORY) + list(APPEND _hdf5_inc_extra_paths "${_hdf5_library_dir}") + unset(_hdf5_library_dir) + list(APPEND _hdf5_inc_extra_suffixes gfortran/modules) + endif () + endif () elseif("${_lang}" STREQUAL "CXX") set(HDF5_INCLUDE_FILENAME H5Cpp.h) else() @@ -877,11 +890,13 @@ if( NOT HDF5_FOUND ) find_path(HDF5_${_lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} HINTS ${HDF5_ROOT} - PATHS $ENV{HOME}/.local/include - PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} + PATHS $ENV{HOME}/.local/include ${_hdf5_inc_extra_paths} + PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes} ${_hdf5_inc_extra_suffixes} ${_HDF5_SEARCH_OPTS} ) mark_as_advanced(HDF5_${_lang}_INCLUDE_DIR) + unset(_hdf5_inc_extra_paths) + unset(_hdf5_inc_extra_suffixes) # set the _DIRS variable as this is what the user will normally use set(HDF5_${_lang}_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${_lang}_INCLUDE_DIR}) -- cgit v0.12 From 1035848e9cfcc148f99c9b6008c419b58f067d8e Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 30 Mar 2021 14:55:51 -0400 Subject: ci: Enable FindDevIL tests on Linux builds --- .gitlab/ci/configure_debian10_aarch64_ninja.cmake | 1 + .gitlab/ci/configure_debian10_ninja.cmake | 1 + .gitlab/ci/configure_fedora33_makefiles.cmake | 1 + 3 files changed, 3 insertions(+) diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake index 023cc9e..1ad3ac4 100644 --- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake +++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake @@ -5,6 +5,7 @@ set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") set(CMake_TEST_FindCups "ON" CACHE BOOL "") set(CMake_TEST_FindCURL "ON" CACHE BOOL "") +set(CMake_TEST_FindDevIL "ON" CACHE BOOL "") set(CMake_TEST_FindDoxygen_Dot "ON" CACHE BOOL "") set(CMake_TEST_FindDoxygen "ON" CACHE BOOL "") set(CMake_TEST_FindEXPAT "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake index 74d9f12..d925387 100644 --- a/.gitlab/ci/configure_debian10_ninja.cmake +++ b/.gitlab/ci/configure_debian10_ninja.cmake @@ -5,6 +5,7 @@ set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") set(CMake_TEST_FindCups "ON" CACHE BOOL "") set(CMake_TEST_FindCURL "ON" CACHE BOOL "") +set(CMake_TEST_FindDevIL "ON" CACHE BOOL "") set(CMake_TEST_FindDoxygen_Dot "ON" CACHE BOOL "") set(CMake_TEST_FindDoxygen "ON" CACHE BOOL "") set(CMake_TEST_FindEXPAT "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora33_makefiles.cmake b/.gitlab/ci/configure_fedora33_makefiles.cmake index db2d005..882ffcd 100644 --- a/.gitlab/ci/configure_fedora33_makefiles.cmake +++ b/.gitlab/ci/configure_fedora33_makefiles.cmake @@ -5,6 +5,7 @@ set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") set(CMake_TEST_FindCups "ON" CACHE BOOL "") set(CMake_TEST_FindCURL "ON" CACHE BOOL "") +set(CMake_TEST_FindDevIL "ON" CACHE BOOL "") set(CMake_TEST_FindDoxygen_Dot "ON" CACHE BOOL "") set(CMake_TEST_FindDoxygen "ON" CACHE BOOL "") set(CMake_TEST_FindEXPAT "ON" CACHE BOOL "") -- cgit v0.12 From 80da23f2a2cb5b24d0f785384640198366173a25 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 6 Apr 2021 12:42:41 -0400 Subject: Tests: Add RunCTest helper option to control CTest verbose flag --- Tests/RunCMake/RunCTest.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/RunCMake/RunCTest.cmake b/Tests/RunCMake/RunCTest.cmake index 98fdf20..59db395 100644 --- a/Tests/RunCMake/RunCTest.cmake +++ b/Tests/RunCMake/RunCTest.cmake @@ -11,10 +11,13 @@ function(run_ctest CASE_NAME) endif() configure_file(${RunCMake_SOURCE_DIR}/CMakeLists.txt.in ${RunCMake_BINARY_DIR}/${CASE_NAME}/CMakeLists.txt @ONLY) + if(NOT DEFINED RunCTest_VERBOSE_FLAG) + set(RunCTest_VERBOSE_FLAG "-V") + endif() run_cmake_command(${CASE_NAME} ${CMAKE_CTEST_COMMAND} -C Debug -S ${RunCMake_BINARY_DIR}/${CASE_NAME}/test.cmake - -V + ${RunCTest_VERBOSE_FLAG} --output-log ${RunCMake_BINARY_DIR}/${CASE_NAME}-build/testOutput.log --no-compress-output ${ARGN} -- cgit v0.12 From 82e40607a4b36d2ee8d3abec4dcd30a18b632ce9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 6 Apr 2021 12:43:44 -0400 Subject: ctest: Display test "WAITING" messages only in extra-verbose mode These messages are incidental scheduling output. Avoid cluttering the normal verbose output showing tests starting and finishing. --- Source/CTest/cmCTestMultiProcessHandler.cxx | 10 +++++----- Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake | 2 +- .../CTestCommandLine/test-load-invalid-stdout.txt | 17 +++++++++++++++-- .../RunCMake/CTestCommandLine/test-load-pass-stdout.txt | 17 +++++++++++++++-- .../RunCMake/CTestCommandLine/test-load-wait-stdout.txt | 17 +++++++++++++++-- .../RunCMake/ctest_test/CTestTestLoadInvalid-stdout.txt | 9 ++++++++- Tests/RunCMake/ctest_test/CTestTestLoadPass-stdout.txt | 9 ++++++++- Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt | 9 ++++++++- Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 2 ++ Tests/RunCMake/ctest_test/TestLoadInvalid-stdout.txt | 9 ++++++++- Tests/RunCMake/ctest_test/TestLoadOrder-stdout.txt | 9 ++++++++- Tests/RunCMake/ctest_test/TestLoadPass-stdout.txt | 9 ++++++++- Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt | 9 ++++++++- 13 files changed, 109 insertions(+), 19 deletions(-) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 852f9d9..86a8e00 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -587,24 +587,24 @@ void cmCTestMultiProcessHandler::StartNextTests() onlyRunSerialTestsLeft = false; } } - cmCTestLog(this->CTest, HANDLER_OUTPUT, "***** WAITING, "); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "***** WAITING, "); if (this->SerialTestRunning) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Waiting for RUN_SERIAL test to finish."); } else if (onlyRunSerialTestsLeft) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Only RUN_SERIAL tests remain, awaiting available slot."); } else { /* clang-format off */ - cmCTestLog(this->CTest, HANDLER_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "System Load: " << systemLoad << ", " "Max Allowed Load: " << this->TestLoad << ", " "Smallest test " << testWithMinProcessors << " requires " << minProcessorsRequired); /* clang-format on */ } - cmCTestLog(this->CTest, HANDLER_OUTPUT, "*****" << std::endl); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "*****" << std::endl); // Wait between 1 and 5 seconds before trying again. unsigned int milliseconds = (cmSystemTools::RandomSeed() % 5 + 1) * 1000; diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 6cf1476..2f4d731 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -202,7 +202,7 @@ function(run_TestLoad name load) add_test(TestLoad1 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\") add_test(TestLoad2 \"${CMAKE_COMMAND}\" -E echo \"test of --test-load\") ") - run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -j2 --test-load ${load}) + run_cmake_command(${name} ${CMAKE_CTEST_COMMAND} -VV -j2 --test-load ${load}) endfunction() # Tests for the --test-load feature of ctest diff --git a/Tests/RunCMake/CTestCommandLine/test-load-invalid-stdout.txt b/Tests/RunCMake/CTestCommandLine/test-load-invalid-stdout.txt index 7ee3dae..5101985 100644 --- a/Tests/RunCMake/CTestCommandLine/test-load-invalid-stdout.txt +++ b/Tests/RunCMake/CTestCommandLine/test-load-invalid-stdout.txt @@ -1,7 +1,20 @@ -^Test project .*/Tests/RunCMake/CTestCommandLine/TestLoad +Test project [^ +]*/Tests/RunCMake/CTestCommandLine/TestLoad( +[^*][^ +]*)* +test 1 Start 1: TestLoad1 ++( +[^*][^ +]*)* +test 2 Start 2: TestLoad2 -1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec ++( +[^*][^ +]*)* +1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec( +[^*][^ +]*)* 2/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 2 diff --git a/Tests/RunCMake/CTestCommandLine/test-load-pass-stdout.txt b/Tests/RunCMake/CTestCommandLine/test-load-pass-stdout.txt index 7ee3dae..5101985 100644 --- a/Tests/RunCMake/CTestCommandLine/test-load-pass-stdout.txt +++ b/Tests/RunCMake/CTestCommandLine/test-load-pass-stdout.txt @@ -1,7 +1,20 @@ -^Test project .*/Tests/RunCMake/CTestCommandLine/TestLoad +Test project [^ +]*/Tests/RunCMake/CTestCommandLine/TestLoad( +[^*][^ +]*)* +test 1 Start 1: TestLoad1 ++( +[^*][^ +]*)* +test 2 Start 2: TestLoad2 -1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec ++( +[^*][^ +]*)* +1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec( +[^*][^ +]*)* 2/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 2 diff --git a/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt b/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt index 11a768a..db7d7f3 100644 --- a/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt +++ b/Tests/RunCMake/CTestCommandLine/test-load-wait-stdout.txt @@ -1,8 +1,21 @@ -^Test project .*/Tests/RunCMake/CTestCommandLine/TestLoad +Test project [^ +]*/Tests/RunCMake/CTestCommandLine/TestLoad( +[^*][^ +]*)* \*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 3, Smallest test TestLoad[1-2] requires 1\*\*\*\*\* +test 1 Start 1: TestLoad1 ++( +[^*][^ +]*)* +test 2 Start 2: TestLoad2 -1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec ++( +[^*][^ +]*)* +1/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec( +[^*][^ +]*)* 2/2 Test #[1-2]: TestLoad[1-2] ........................ Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 2 diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadInvalid-stdout.txt b/Tests/RunCMake/ctest_test/CTestTestLoadInvalid-stdout.txt index b54220c..acda9e2 100644 --- a/Tests/RunCMake/ctest_test/CTestTestLoadInvalid-stdout.txt +++ b/Tests/RunCMake/ctest_test/CTestTestLoadInvalid-stdout.txt @@ -1,5 +1,12 @@ -Test project .*/Tests/RunCMake/ctest_test/CTestTestLoadInvalid-build +Test project [^ +]*/Tests/RunCMake/ctest_test/CTestTestLoadInvalid-build( +[^*][^ +]*)* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadPass-stdout.txt b/Tests/RunCMake/ctest_test/CTestTestLoadPass-stdout.txt index c221eed..4081f98 100644 --- a/Tests/RunCMake/ctest_test/CTestTestLoadPass-stdout.txt +++ b/Tests/RunCMake/ctest_test/CTestTestLoadPass-stdout.txt @@ -1,5 +1,12 @@ -Test project .*/Tests/RunCMake/ctest_test/CTestTestLoadPass-build +Test project [^ +]*/Tests/RunCMake/ctest_test/CTestTestLoadPass-build( +[^*][^ +]*)* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt b/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt index 2af3838..2f4468f 100644 --- a/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt +++ b/Tests/RunCMake/ctest_test/CTestTestLoadWait-stdout.txt @@ -1,6 +1,13 @@ -Test project .*/Tests/RunCMake/ctest_test/CTestTestLoadWait-build +Test project [^ +]*/Tests/RunCMake/ctest_test/CTestTestLoadWait-build( +[^*][^ +]*)* \*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 4, Smallest test RunCMakeVersion requires 1\*\*\*\*\* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake index b82335f..8cf6a61 100644 --- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake @@ -18,6 +18,7 @@ run_ctest_test(TestQuiet QUIET) # # Spoof a load average value to make these tests more reliable. set(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING} 5) +set(RunCTest_VERBOSE_FLAG -VV) # Verify that new tests are started when the load average falls below # our threshold. @@ -53,6 +54,7 @@ run_ctest_test(TestLoadOrder TEST_LOAD "ERR4") unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING}) unset(CASE_CTEST_TEST_LOAD) +unset(RunCTest_VERBOSE_FLAG) function(run_TestChangeId) set(CASE_TEST_PREFIX_CODE [[ diff --git a/Tests/RunCMake/ctest_test/TestLoadInvalid-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadInvalid-stdout.txt index c4fd35b..8d21f91 100644 --- a/Tests/RunCMake/ctest_test/TestLoadInvalid-stdout.txt +++ b/Tests/RunCMake/ctest_test/TestLoadInvalid-stdout.txt @@ -1,5 +1,12 @@ -Test project .*/Tests/RunCMake/ctest_test/TestLoadInvalid-build +Test project [^ +]*/Tests/RunCMake/ctest_test/TestLoadInvalid-build( +[^*][^ +]*)* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/ctest_test/TestLoadOrder-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadOrder-stdout.txt index 22da092..1ef5f5a 100644 --- a/Tests/RunCMake/ctest_test/TestLoadOrder-stdout.txt +++ b/Tests/RunCMake/ctest_test/TestLoadOrder-stdout.txt @@ -1,5 +1,12 @@ -Test project .*/Tests/RunCMake/ctest_test/TestLoadOrder-build +Test project [^ +]*/Tests/RunCMake/ctest_test/TestLoadOrder-build( +[^*][^ +]*)* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/ctest_test/TestLoadPass-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadPass-stdout.txt index e5048f4..f3e7cd1 100644 --- a/Tests/RunCMake/ctest_test/TestLoadPass-stdout.txt +++ b/Tests/RunCMake/ctest_test/TestLoadPass-stdout.txt @@ -1,5 +1,12 @@ -Test project .*/Tests/RunCMake/ctest_test/TestLoadPass-build +Test project [^ +]*/Tests/RunCMake/ctest_test/TestLoadPass-build( +[^*][^ +]*)* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 diff --git a/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt b/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt index 07f4ed3..fc32958 100644 --- a/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt +++ b/Tests/RunCMake/ctest_test/TestLoadWait-stdout.txt @@ -1,6 +1,13 @@ -Test project .*/Tests/RunCMake/ctest_test/TestLoadWait-build +Test project [^ +]*/Tests/RunCMake/ctest_test/TestLoadWait-build( +[^*][^ +]*)* \*\*\*\*\* WAITING, System Load: 5, Max Allowed Load: 2, Smallest test RunCMakeVersion requires 1\*\*\*\*\* +test 1 Start 1: RunCMakeVersion ++( +[^*][^ +]*)* 1/1 Test #1: RunCMakeVersion .................. Passed +[0-9.]+ sec + 100% tests passed, 0 tests failed out of 1 -- cgit v0.12 From d6da6784bfdb59456942d11d476593906945adbb Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 6 Apr 2021 10:36:57 -0400 Subject: FindThreads: Reduce amount of false positive error logging When a CMake based project fails, users start looking at CMakeError.log and think that the FindThread output is the problem, but it is a false positive. Now FindThreads only logs to `CMakeError.log` when it fails to find a suitable flag, reducing the amount of false positives in `CMakeError.log`. Fixes #16540, Fixes #19344 --- Modules/FindThreads.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 87e88bc..28dffc0 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -119,7 +119,10 @@ macro(_check_pthreads_flag) ${CMAKE_BINARY_DIR} ${_threads_src} CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread - OUTPUT_VARIABLE OUTPUT) + OUTPUT_VARIABLE _cmake_check_pthreads_output) + + string(APPEND _cmake_find_threads_output "${_cmake_check_pthreads_output}") + unset(_cmake_check_pthreads_output) unset(_threads_src) if(THREADS_HAVE_PTHREAD_ARG) @@ -127,9 +130,6 @@ macro(_check_pthreads_flag) message(CHECK_PASS "yes") else() message(CHECK_FAIL "no") - file(APPEND - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if compiler accepts -pthread failed with the following output:\n${OUTPUT}\n\n") endif() endif() @@ -249,4 +249,10 @@ if(THREADS_FOUND AND NOT TARGET Threads::Threads) if(CMAKE_THREAD_LIBS_INIT) set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif() +elseif(NOT THREADS_FOUND AND _cmake_find_threads_output) + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if compiler accepts -pthread failed with the following output:\n${_cmake_find_threads_output}\n\n") endif() + +unset(_cmake_find_threads_output) -- cgit v0.12 From 06e69813360560347434a5320f1a366ba004e033 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Fri, 26 Mar 2021 13:31:43 +0100 Subject: cmake-presets: Make generator and binaryDir fields optional In v3 of the presets, generator and buildDir can be omitted to fall back to regular cmake behavior when these values are not explicitly provided by the user. Fixes: #21987 --- Help/manual/cmake-presets.7.rst | 7 ++-- Help/manual/presets/schema.json | 8 +++++ ...ke-presets-optional-generator-and-binarydir.rst | 5 +++ Source/QtDialog/QCMake.cxx | 2 +- Source/cmCMakePresetsFile.cxx | 38 +++++++++++++--------- Source/cmCMakePresetsFile.h | 8 ++--- Source/cmake.cxx | 9 +++-- .../CMakePresets/OptionalBinaryDirField.cmake | 3 ++ .../CMakePresets/OptionalBinaryDirField.json.in | 9 +++++ .../CMakePresets/OptionalGeneratorField.cmake | 3 ++ .../CMakePresets/OptionalGeneratorField.json.in | 9 +++++ Tests/RunCMake/CMakePresets/RunCMakeTest.cmake | 5 +++ 12 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 Help/release/dev/cmake-presets-optional-generator-and-binarydir.rst create mode 100644 Tests/RunCMake/CMakePresets/OptionalBinaryDirField.cmake create mode 100644 Tests/RunCMake/CMakePresets/OptionalBinaryDirField.json.in create mode 100644 Tests/RunCMake/CMakePresets/OptionalGeneratorField.cmake create mode 100644 Tests/RunCMake/CMakePresets/OptionalGeneratorField.json.in diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 8543be3..3714004 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -145,7 +145,9 @@ that may contain the following fields: An optional string representing the generator to use for the preset. If ``generator`` is not specified, it must be inherited from the - ``inherits`` preset (unless this preset is ``hidden``). + ``inherits`` preset (unless this preset is ``hidden``). In version ``3`` + or above, this field may be omitted to fall back to regular generator + discovery procedure. Note that for Visual Studio generators, unlike in the command line ``-G`` argument, you cannot include the platform name in the generator name. Use @@ -186,7 +188,8 @@ that may contain the following fields: This field supports `macro expansion`_. If a relative path is specified, it is calculated relative to the source directory. If ``binaryDir`` is not specified, it must be inherited from the ``inherits`` preset (unless this - preset is ``hidden``). + preset is ``hidden``). In version ``3`` or above, this field may be + omitted. ``installDir`` diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index 9261519..e066362 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -79,6 +79,14 @@ "type": "object", "description": "A configure preset object.", "properties": { + "binaryDir": { + "type": "string", + "description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, the path is calculated using regular methods." + }, + "generator": { + "type": "string", + "description": "An optional string representing the generator to use for the preset. If generator is not specified, the normal generator discovery procedure is used. Note that for Visual Studio generators, unlike in the command line -G argument, you cannot include the platform name in the generator name. Use the architecture field instead." + }, "installDir": { "type": "string", "description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, it must be inherited from the inherits preset (unless this preset is hidden)." diff --git a/Help/release/dev/cmake-presets-optional-generator-and-binarydir.rst b/Help/release/dev/cmake-presets-optional-generator-and-binarydir.rst new file mode 100644 index 0000000..7973489 --- /dev/null +++ b/Help/release/dev/cmake-presets-optional-generator-and-binarydir.rst @@ -0,0 +1,5 @@ +cmake-presets-optional-generator-and-binarydir +---------------------------------------------- + +* :manual:`cmake-presets(7)` now support omitting the ``generator`` and + ``binaryDir`` fields. diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 7d037e3..6796e25 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -160,7 +160,7 @@ void QCMake::setPreset(const QString& name, bool setBinary) auto const& expandedPreset = this->CMakePresetsFile.ConfigurePresets[presetName].Expanded; if (expandedPreset) { - if (setBinary) { + if (setBinary && !expandedPreset->BinaryDir.empty()) { QString binaryDir = QString::fromLocal8Bit(expandedPreset->BinaryDir.data()); this->setBinaryDirectory(binaryDir); diff --git a/Source/cmCMakePresetsFile.cxx b/Source/cmCMakePresetsFile.cxx index d44dfb3..39cce98 100644 --- a/Source/cmCMakePresetsFile.cxx +++ b/Source/cmCMakePresetsFile.cxx @@ -78,7 +78,7 @@ void InheritVector(std::vector& child, const std::vector& parent) template ReadFileResult VisitPreset( T& preset, std::map>& presets, - std::map cycleStatus) + std::map cycleStatus, int version) { switch (cycleStatus[preset.Name]) { case CycleStatus::InProgress: @@ -108,7 +108,7 @@ ReadFileResult VisitPreset( return ReadFileResult::USER_PRESET_INHERITANCE; } - auto result = VisitPreset(parentPreset, presets, cycleStatus); + auto result = VisitPreset(parentPreset, presets, cycleStatus, version); if (result != ReadFileResult::READ_OK) { return result; } @@ -128,7 +128,7 @@ ReadFileResult VisitPreset( preset.ConditionEvaluator.reset(); } - CHECK_OK(preset.VisitPresetAfterInherit()) + CHECK_OK(preset.VisitPresetAfterInherit(version)) cycleStatus[preset.Name] = CycleStatus::Verified; return ReadFileResult::READ_OK; @@ -136,7 +136,8 @@ ReadFileResult VisitPreset( template ReadFileResult ComputePresetInheritance( - std::map>& presets) + std::map>& presets, + const cmCMakePresetsFile& file) { std::map cycleStatus; for (auto const& it : presets) { @@ -144,7 +145,9 @@ ReadFileResult ComputePresetInheritance( } for (auto& it : presets) { - auto result = VisitPreset(it.second.Unexpanded, presets, cycleStatus); + auto& preset = it.second.Unexpanded; + auto result = + VisitPreset(preset, presets, cycleStatus, file.GetVersion(preset)); if (result != ReadFileResult::READ_OK) { return result; } @@ -667,16 +670,19 @@ cmCMakePresetsFile::ConfigurePreset::VisitPresetBeforeInherit() } cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::ConfigurePreset::VisitPresetAfterInherit() +cmCMakePresetsFile::ConfigurePreset::VisitPresetAfterInherit(int version) { auto& preset = *this; if (!preset.Hidden) { - if (preset.Generator.empty()) { - return ReadFileResult::INVALID_PRESET; - } - if (preset.BinaryDir.empty()) { - return ReadFileResult::INVALID_PRESET; + if (version < 3) { + if (preset.Generator.empty()) { + return ReadFileResult::INVALID_PRESET; + } + if (preset.BinaryDir.empty()) { + return ReadFileResult::INVALID_PRESET; + } } + if (preset.WarnDev == false && preset.ErrorDev == true) { return ReadFileResult::INVALID_PRESET; } @@ -712,7 +718,7 @@ cmCMakePresetsFile::BuildPreset::VisitPresetInherit( } cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::BuildPreset::VisitPresetAfterInherit() +cmCMakePresetsFile::BuildPreset::VisitPresetAfterInherit(int /* version */) { auto& preset = *this; if (!preset.Hidden && preset.ConfigurePreset.empty()) { @@ -822,7 +828,7 @@ cmCMakePresetsFile::TestPreset::VisitPresetInherit( } cmCMakePresetsFile::ReadFileResult -cmCMakePresetsFile::TestPreset::VisitPresetAfterInherit() +cmCMakePresetsFile::TestPreset::VisitPresetAfterInherit(int /* version */) { auto& preset = *this; if (!preset.Hidden && preset.ConfigurePreset.empty()) { @@ -883,9 +889,9 @@ cmCMakePresetsFile::ReadProjectPresetsInternal(bool allowNoFiles) : ReadFileResult::FILE_NOT_FOUND; } - CHECK_OK(ComputePresetInheritance(this->ConfigurePresets)) - CHECK_OK(ComputePresetInheritance(this->BuildPresets)) - CHECK_OK(ComputePresetInheritance(this->TestPresets)) + CHECK_OK(ComputePresetInheritance(this->ConfigurePresets, *this)) + CHECK_OK(ComputePresetInheritance(this->BuildPresets, *this)) + CHECK_OK(ComputePresetInheritance(this->TestPresets, *this)) for (auto& it : this->ConfigurePresets) { if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { diff --git a/Source/cmCMakePresetsFile.h b/Source/cmCMakePresetsFile.h index 0999d5a..fc14830 100644 --- a/Source/cmCMakePresetsFile.h +++ b/Source/cmCMakePresetsFile.h @@ -89,7 +89,7 @@ public: return ReadFileResult::READ_OK; } - virtual ReadFileResult VisitPresetAfterInherit() + virtual ReadFileResult VisitPresetAfterInherit(int /* version */) { return ReadFileResult::READ_OK; } @@ -132,7 +132,7 @@ public: ReadFileResult VisitPresetInherit(const Preset& parent) override; ReadFileResult VisitPresetBeforeInherit() override; - ReadFileResult VisitPresetAfterInherit() override; + ReadFileResult VisitPresetAfterInherit(int version) override; }; class BuildPreset : public Preset @@ -158,7 +158,7 @@ public: std::vector NativeToolOptions; ReadFileResult VisitPresetInherit(const Preset& parent) override; - ReadFileResult VisitPresetAfterInherit() override; + ReadFileResult VisitPresetAfterInherit(int /* version */) override; }; class TestPreset : public Preset @@ -285,7 +285,7 @@ public: cm::optional Execution; ReadFileResult VisitPresetInherit(const Preset& parent) override; - ReadFileResult VisitPresetAfterInherit() override; + ReadFileResult VisitPresetAfterInherit(int /* version */) override; }; template diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a04338f..1d4bbf4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1223,10 +1223,11 @@ void cmake::SetArgs(const std::vector& args) return; } - if (!this->State->IsCacheLoaded() && !haveBArg) { + if (!this->State->IsCacheLoaded() && !haveBArg && + !expandedPreset->BinaryDir.empty()) { this->SetHomeOutputDirectory(expandedPreset->BinaryDir); } - if (!this->GlobalGenerator) { + if (!this->GlobalGenerator && !expandedPreset->Generator.empty()) { if (!this->CreateAndSetGlobalGenerator(expandedPreset->Generator, false)) { return; @@ -3203,7 +3204,9 @@ int cmake::Build(int jobs, std::string dir, std::vector targets, return 1; } - dir = expandedConfigurePreset->BinaryDir; + if (!expandedConfigurePreset->BinaryDir.empty()) { + dir = expandedConfigurePreset->BinaryDir; + } this->UnprocessedPresetEnvironment = expandedPreset->Environment; this->ProcessPresetEnvironment(); diff --git a/Tests/RunCMake/CMakePresets/OptionalBinaryDirField.cmake b/Tests/RunCMake/CMakePresets/OptionalBinaryDirField.cmake new file mode 100644 index 0000000..49e7a25 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/OptionalBinaryDirField.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_BINARY_DIR "" "${CMAKE_SOURCE_DIR}/build") diff --git a/Tests/RunCMake/CMakePresets/OptionalBinaryDirField.json.in b/Tests/RunCMake/CMakePresets/OptionalBinaryDirField.json.in new file mode 100644 index 0000000..ee17a22 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/OptionalBinaryDirField.json.in @@ -0,0 +1,9 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "OptionalBinaryDirField", + "generator": "@RunCMake_GENERATOR@" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/OptionalGeneratorField.cmake b/Tests/RunCMake/CMakePresets/OptionalGeneratorField.cmake new file mode 100644 index 0000000..4319e72 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/OptionalGeneratorField.cmake @@ -0,0 +1,3 @@ +include(${CMAKE_CURRENT_LIST_DIR}/TestVariable.cmake) + +test_variable(CMAKE_GENERATOR "" "${RunCMake_GENERATOR}") diff --git a/Tests/RunCMake/CMakePresets/OptionalGeneratorField.json.in b/Tests/RunCMake/CMakePresets/OptionalGeneratorField.json.in new file mode 100644 index 0000000..920d056 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/OptionalGeneratorField.json.in @@ -0,0 +1,9 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "OptionalGeneratorField", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 9523430..bcbd177 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -275,6 +275,11 @@ set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Conditions.json.in") run_cmake_presets(ListConditions --list-presets) run_cmake_presets(SimpleTrue) run_cmake_presets(SimpleFalse) +unset(CMakePresets_FILE) + +# Test optional generator and buildDir fields +run_cmake_presets(OptionalBinaryDirField -B "${RunCMake_BINARY_DIR}/OptionalBinaryDirField/build") +run_cmake_presets(OptionalGeneratorField -G "${RunCMake_GENERATOR}") # Test the example from the documentation file(READ "${RunCMake_SOURCE_DIR}/../../../Help/manual/presets/example.json" _example) -- cgit v0.12 From a8b6b54239ac39493947e97cbe5164ac2b1c323e Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 7 Apr 2021 00:06:15 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b7ca022..7072e53 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210406) +set(CMake_VERSION_PATCH 20210407) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From f71e7b8156423512f4631f393d955b31557cdd8e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 7 Apr 2021 12:28:57 -0400 Subject: Help/dev/review: mention `--pretty=reference` This was added in Git 2.25 (13 Jan 2020). --- Help/dev/review.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Help/dev/review.rst b/Help/dev/review.rst index 8326e70..10ff87b 100644 --- a/Help/dev/review.rst +++ b/Help/dev/review.rst @@ -254,7 +254,8 @@ The preferred form for references to other commits is The author date of the commit, in its original time zone, formatted as ``CCYY-MM-DD``. ``git-log(1)`` shows the original time zone by default. -This may be generated with +This may be generated with ``git show -s --pretty=reference `` with +Git 2.25 and newer. Older versions of Git can generate the same format via ``git show -s --date=short --pretty="format:%h (%s, %ad)" ``. If the commit is a fix for the mentioned commit, consider using a ``Fixes:`` -- cgit v0.12 From 8ffd3b49464005b6bb6ba2902616b2e8a5ce3a8d Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 8 Apr 2021 00:01:25 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7072e53..f37f3b9 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210407) +set(CMake_VERSION_PATCH 20210408) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From eb62097dec525ade99299697365d9e129455ddaf Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 9 Apr 2021 00:01:21 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f37f3b9..fc8d6f9 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210408) +set(CMake_VERSION_PATCH 20210409) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From aa283fdba161eb458b02caaa9f0c32d97c648d6f Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 10 Apr 2021 00:01:04 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index fc8d6f9..9d81c40 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210409) +set(CMake_VERSION_PATCH 20210410) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 0656bebeaecb85c2297b3d87634aed6ce8a80f34 Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sat, 3 Apr 2021 11:49:11 +0100 Subject: Autogen: Rename the variable for UI files with UIC options Monitoring for UI file changes in the target sources will require keeping track of the files without options as well so this will improve clarity. --- Source/cmQtAutoGenInitializer.cxx | 5 +++-- Source/cmQtAutoGenInitializer.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index e96ec63..f0c799e 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -936,7 +936,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Check if the .ui file has uic options std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); if (!uicOpts.empty()) { - this->Uic.UiFiles.emplace_back(fullPath, cmExpandedList(uicOpts)); + this->Uic.UiFilesWithOptions.emplace_back(fullPath, + cmExpandedList(uicOpts)); } auto uiHeaderRelativePath = cmSystemTools::RelativePath( @@ -1626,7 +1627,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() uic_skip.insert(this->Uic.SkipUi.begin(), this->Uic.SkipUi.end()); info.SetArray("UIC_SKIP", uic_skip); - info.SetArrayArray("UIC_UI_FILES", this->Uic.UiFiles, + info.SetArrayArray("UIC_UI_FILES", this->Uic.UiFilesWithOptions, [](Json::Value& jval, UicT::UiFileT const& uiFile) { jval.resize(2u); jval[0u] = uiFile.first; diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index fdb65d3..9fe0cf0 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -236,7 +236,7 @@ private: : GenVarsT(GenT::UIC){}; std::set SkipUi; - std::vector UiFiles; + std::vector UiFilesWithOptions; ConfigStrings> Options; std::vector SearchPaths; std::vector> -- cgit v0.12 From 087b717aefd5439fc5bc6ae25b9795cbb5563e02 Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sat, 3 Apr 2021 19:52:53 +0100 Subject: Autogen: Move duplicated executable dependency code into a function --- Source/cmQtAutoGenInitializer.cxx | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index f0c799e..a1602bd 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -294,6 +294,17 @@ bool InfoWriter::Save(std::string const& filename) return fileStream.Close(); } +void AddAutogenExecutableToDependencies( + cmQtAutoGenInitializer::GenVarsT const& genVars, + std::vector& dependencies) +{ + if (genVars.ExecutableTarget != nullptr) { + dependencies.push_back(genVars.ExecutableTarget->Target->GetName()); + } else if (!genVars.Executable.empty()) { + dependencies.push_back(genVars.Executable); + } +} + } // End of unnamed namespace cmQtAutoGenInitializer::cmQtAutoGenInitializer( @@ -1279,16 +1290,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() dependencies.clear(); dependencies.push_back(timestampTargetName); - if (this->Moc.ExecutableTarget != nullptr) { - dependencies.push_back(this->Moc.ExecutableTarget->Target->GetName()); - } else if (!this->Moc.Executable.empty()) { - dependencies.push_back(this->Moc.Executable); - } - if (this->Uic.ExecutableTarget != nullptr) { - dependencies.push_back(this->Uic.ExecutableTarget->Target->GetName()); - } else if (!this->Uic.Executable.empty()) { - dependencies.push_back(this->Uic.Executable); - } + AddAutogenExecutableToDependencies(this->Moc, dependencies); + AddAutogenExecutableToDependencies(this->Uic, dependencies); // Create the custom command that outputs the timestamp file. const char timestampFileName[] = "timestamp"; -- cgit v0.12 From 1876f2d03fe3ccc4ea02c27fe345657b3366b48e Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sat, 10 Apr 2021 15:04:22 +0100 Subject: Autogen: Move duplicated filename generation code into a function --- Source/cmQtAutoGenInitializer.cxx | 47 +++++++++++++++++---------------------- Source/cmQtAutoGenInitializer.h | 2 ++ 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a1602bd..816d7e5 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -430,12 +430,8 @@ bool cmQtAutoGenInitializer::InitCustomTargets() cmSystemTools::ConvertToUnixSlashes(this->Dir.Work); // Include directory - this->ConfigFileNames(this->Dir.Include, - cmStrCat(this->Dir.Build, "/include"), ""); - this->Dir.IncludeGenExp = this->Dir.Include.Default; - if (this->MultiConfig) { - this->Dir.IncludeGenExp += "_$"; - } + this->ConfigFileNamesAndGenex(this->Dir.Include, this->Dir.IncludeGenExp, + cmStrCat(this->Dir.Build, "/include"), ""); } // Moc, Uic and _autogen target settings @@ -586,15 +582,9 @@ bool cmQtAutoGenInitializer::InitMoc() cmStrCat(this->Dir.Build, "/mocs_compilation.cpp"); this->Moc.CompilationFileGenex = this->Moc.CompilationFile.Default; } else { - this->ConfigFileNames(this->Moc.CompilationFile, - cmStrCat(this->Dir.Build, "/mocs_compilation"), - ".cpp"); - if (this->MultiConfig) { - this->Moc.CompilationFileGenex = - cmStrCat(this->Dir.Build, "/mocs_compilation_$.cpp"_s); - } else { - this->Moc.CompilationFileGenex = this->Moc.CompilationFile.Default; - } + this->ConfigFileNamesAndGenex( + this->Moc.CompilationFile, this->Moc.CompilationFileGenex, + cmStrCat(this->Dir.Build, "/mocs_compilation"_s), ".cpp"_s); } // Moc predefs @@ -966,17 +956,10 @@ bool cmQtAutoGenInitializer::InitScanFiles() cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s); ConfigString uiHeader; - uiHeader.Default = - cmStrCat(this->Dir.Build, "/include"_s, uiHeaderFilePath); - auto uiHeaderGenex = uiHeader.Default; - if (this->MultiConfig) { - uiHeaderGenex = cmStrCat(this->Dir.Build, "/include_$"_s, - uiHeaderFilePath); - for (std::string const& cfg : this->ConfigsList) { - uiHeader.Config[cfg] = cmStrCat(this->Dir.Build, "/include_"_s, - cfg, uiHeaderFilePath); - } - } + std::string uiHeaderGenex; + this->ConfigFileNamesAndGenex( + uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s), + uiHeaderFilePath); this->Uic.UiHeaders.emplace_back( std::make_pair(uiHeader, uiHeaderGenex)); @@ -1790,6 +1773,18 @@ void cmQtAutoGenInitializer::ConfigFileNames(ConfigString& configString, } } +void cmQtAutoGenInitializer::ConfigFileNamesAndGenex( + ConfigString& configString, std::string& genex, cm::string_view const prefix, + cm::string_view const suffix) +{ + this->ConfigFileNames(configString, prefix, suffix); + if (this->MultiConfig) { + genex = cmStrCat(prefix, "_$"_s, suffix); + } else { + genex = configString.Default; + } +} + void cmQtAutoGenInitializer::ConfigFileClean(ConfigString& configString) { this->AddCleanFile(configString.Default); diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 9fe0cf0..d096315 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -141,6 +141,8 @@ private: void ConfigFileNames(ConfigString& configString, cm::string_view prefix, cm::string_view suffix); + void ConfigFileNamesAndGenex(ConfigString& configString, std::string& genex, + cm::string_view prefix, cm::string_view suffix); void ConfigFileClean(ConfigString& configString); std::string GetMocBuildPath(MUFile const& muf); -- cgit v0.12 From a8d879cf4507f0460dd8386a10c3b4ffe79c3566 Mon Sep 17 00:00:00 2001 From: Duncan Barber <7744-dunquan@users.noreply.gitlab.kitware.com> Date: Sat, 3 Apr 2021 11:53:53 +0100 Subject: Autogen: Add detection of UI file changes to the pre-build VS case This is achieved by adding a rule file which carries the UI files as dependencies but performs no meaningful command. Its output path points to a timestamp file which is instead touched by the pre-build command that runs autogen. The rule file therefore triggers the build if any of the files have been changed more recently than the last autogen run. Fixes: #17959 Fixes: #18741 --- Source/cmQtAutoGenInitializer.cxx | 40 ++++++++++++++++++++++++++++++++++++++- Source/cmQtAutoGenInitializer.h | 1 + 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 816d7e5..3adeb1a 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -936,7 +936,9 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (!skipUic) { // Check if the .ui file has uic options std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS); - if (!uicOpts.empty()) { + if (uicOpts.empty()) { + this->Uic.UiFilesNoOptions.emplace_back(fullPath); + } else { this->Uic.UiFilesWithOptions.emplace_back(fullPath, cmExpandedList(uicOpts)); } @@ -1181,6 +1183,42 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() this->Makefile); } + if (!this->Uic.UiFilesNoOptions.empty() || + !this->Uic.UiFilesWithOptions.empty()) { + // Add a generated timestamp file + ConfigString timestampFile; + std::string timestampFileGenex; + ConfigFileNamesAndGenex(timestampFile, timestampFileGenex, + cmStrCat(this->Dir.Build, "/autouic"_s), + ".stamp"_s); + this->AddGeneratedSource(timestampFile, this->Uic); + + // Add a step in the pre-build command to touch the timestamp file + commandLines.push_back( + cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E", "touch", + timestampFileGenex })); + + // UIC needs to be re-run if any of the known UI files change or the + // executable itself has been updated + auto uicDependencies = this->Uic.UiFilesNoOptions; + for (auto const& uiFile : this->Uic.UiFilesWithOptions) { + uicDependencies.push_back(uiFile.first); + } + AddAutogenExecutableToDependencies(this->Uic, uicDependencies); + + // Add a rule file to cause the target to build if a dependency has + // changed, which will trigger the pre-build command to run autogen + std::string no_main_dependency; + cmCustomCommandLines no_command_lines; + this->LocalGen->AddCustomCommandToOutput( + timestampFileGenex, uicDependencies, no_main_dependency, + no_command_lines, /*comment=*/"", this->Dir.Work.c_str(), + /*cmp0116=*/cmPolicies::NEW, /*replace=*/false, + /*escapeOldStyle=*/false, /*uses_terminal=*/false, + /*command_expand_lists=*/false, /*depfile=*/"", /*job_pool=*/"", + stdPipesUTF8); + } + // Add the pre-build command directly to bypass the OBJECT_LIBRARY // rejection in cmMakefile::AddCustomCommandToTarget because we know // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case. diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index d096315..8a6d8f9 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -238,6 +238,7 @@ private: : GenVarsT(GenT::UIC){}; std::set SkipUi; + std::vector UiFilesNoOptions; std::vector UiFilesWithOptions; ConfigStrings> Options; std::vector SearchPaths; -- cgit v0.12 From b1c739ad8bcacae6d66d88514102dcd4423c2dcb Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 11 Apr 2021 00:01:04 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9d81c40..b2c866b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210410) +set(CMake_VERSION_PATCH 20210411) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From f62a2bf44f392f6a23836848714ed36cd02975af Mon Sep 17 00:00:00 2001 From: Craig Scott Date: Sun, 11 Apr 2021 18:05:14 +1000 Subject: Tests: Factor out XcodeProject-Embed check function findAttribute() --- .../EmbedFrameworksFlagsOff-check.cmake | 16 +++------------- .../EmbedFrameworksFlagsOnNoSubdir-check.cmake | 16 +++------------- .../EmbedFrameworksFlagsOnWithSubdir-check.cmake | 16 +++------------- Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 39 deletions(-) create mode 100644 Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake index 9cc03b9..dbd3e87 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOff-check.cmake @@ -1,14 +1,4 @@ -function(findAttribute project attr) - execute_process( - COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj - OUTPUT_VARIABLE output_var - RESULT_VARIABLE result_var - ) +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) - if(NOT result_var) - set(RunCMake_TEST_FAILED "${attr} attribute is set" PARENT_SCOPE) - endif() -endfunction() - -findAttribute(${test} "RemoveHeadersOnCopy") -findAttribute(${test} "CodeSignOnCopy") +findAttribute(${test} "RemoveHeadersOnCopy" FALSE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake index 3f62640..0f57820 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnNoSubdir-check.cmake @@ -1,14 +1,4 @@ -function(findAttribute project attr) - execute_process( - COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj - OUTPUT_VARIABLE output_var - RESULT_VARIABLE result_var - ) +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) - if(result_var) - set(RunCMake_TEST_FAILED "${attr} attribute not set" PARENT_SCOPE) - endif() -endfunction() - -findAttribute(${test} "RemoveHeadersOnCopy") -findAttribute(${test} "CodeSignOnCopy") +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake index 3f62640..0f57820 100644 --- a/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedFrameworksFlagsOnWithSubdir-check.cmake @@ -1,14 +1,4 @@ -function(findAttribute project attr) - execute_process( - COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj - OUTPUT_VARIABLE output_var - RESULT_VARIABLE result_var - ) +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) - if(result_var) - set(RunCMake_TEST_FAILED "${attr} attribute not set" PARENT_SCOPE) - endif() -endfunction() - -findAttribute(${test} "RemoveHeadersOnCopy") -findAttribute(${test} "CodeSignOnCopy") +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" TRUE) diff --git a/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake b/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake new file mode 100644 index 0000000..b1963e2 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/findAttribute.cmake @@ -0,0 +1,19 @@ +cmake_policy(VERSION 3.1...3.20) + +function(findAttribute project attr expectPresent) + execute_process( + COMMAND grep ${attr} ${RunCMake_TEST_BINARY_DIR}/${project}.xcodeproj/project.pbxproj + OUTPUT_VARIABLE output_var + RESULT_VARIABLE result_var + ) + + if(${expectPresent}) + if(result_var) + set(RunCMake_TEST_FAILED "${attr} attribute is not set" PARENT_SCOPE) + endif() + else() + if(NOT result_var) + set(RunCMake_TEST_FAILED "${attr} attribute is set" PARENT_SCOPE) + endif() + endif() +endfunction() -- cgit v0.12 From 43ecda68eb85bdb38c635ecd3e5a5296a2451f81 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 12 Apr 2021 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b2c866b..22237e6 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210411) +set(CMake_VERSION_PATCH 20210412) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 0c47b91fccf5d55a0edc1512a543b8445a8fa4ba Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 9 Apr 2021 19:09:52 +0200 Subject: Genex: add_custom_command: DEPFILE supports genex This facility is very useful for 'Ninja Multi-Config' and required as well for future support of DEPFILE in 'Xcode' and 'Visual Studio' generators (#20286). --- Help/command/add_custom_command.rst | 7 ++++++- .../dev/add_custom_command-DEPFILE-genex.rst | 5 +++++ Source/cmCustomCommandGenerator.cxx | 21 ++++++++++++++++++++- Source/cmCustomCommandGenerator.h | 1 + Source/cmLocalNinjaGenerator.cxx | 2 +- .../BuildDepends/CustomCommandDepfile.cmake | 8 ++++---- .../RunCMake/Ninja/CustomCommandDepfile-check.cmake | 7 ++++++- Tests/RunCMake/Ninja/CustomCommandDepfile.cmake | 13 ++++++++++++- Tests/RunCMake/Ninja/RunCMakeTest.cmake | 2 +- .../CustomCommandDepfile-check.cmake | 7 ++++++- .../NinjaMultiConfig/CustomCommandDepfile.cmake | 13 ++++++++++++- 11 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 Help/release/dev/add_custom_command-DEPFILE-genex.rst diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index c0b9593..b6ff0ea 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -272,7 +272,9 @@ The options are: .. versionadded:: 3.7 Specify a ``.d`` depfile for the :generator:`Ninja` generator and - :ref:`Makefile Generators`. + :ref:`Makefile Generators`. The depfile may use "generator expressions" with + the syntax ``$<...>``. See the :manual:`generator-expressions(7) + ` manual for available expressions. A ``.d`` file holds dependencies usually emitted by the custom command itself. Using ``DEPFILE`` with other generators than :generator:`Ninja` or @@ -281,6 +283,9 @@ The options are: .. versionadded:: 3.20 Added the support of :ref:`Makefile Generators`. + .. versionadded:: 3.21 + Added the support of :manual:`generator expressions `. + If the ``DEPFILE`` argument is relative, it should be relative to :variable:`CMAKE_CURRENT_BINARY_DIR`, and any relative paths inside the ``DEPFILE`` should also be relative to :variable:`CMAKE_CURRENT_BINARY_DIR` diff --git a/Help/release/dev/add_custom_command-DEPFILE-genex.rst b/Help/release/dev/add_custom_command-DEPFILE-genex.rst new file mode 100644 index 0000000..52e5e9f --- /dev/null +++ b/Help/release/dev/add_custom_command-DEPFILE-genex.rst @@ -0,0 +1,5 @@ +add_custom_command-DEPFILE-genex +-------------------------------- + +* The :command:`add_custom_command` command ``DEPFILE`` option learned to + support :manual:`generator expressions `. diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 4329caf..4705443 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -139,6 +139,14 @@ std::vector EvaluateOutputs(std::vector const& paths, } return outputs; } + +std::string EvaluateDepfile(std::string const& path, + cmGeneratorExpression const& ge, + cmLocalGenerator* lg, std::string const& config) +{ + std::unique_ptr cge = ge.Parse(path); + return cge->Evaluate(lg, config); +} } cmCustomCommandGenerator::cmCustomCommandGenerator( @@ -381,9 +389,20 @@ void cmCustomCommandGenerator::AppendArguments(unsigned int c, } } +std::string cmCustomCommandGenerator::GetDepfile() const +{ + const auto& depfile = this->CC->GetDepfile(); + if (depfile.empty()) { + return ""; + } + + cmGeneratorExpression ge(this->CC->GetBacktrace()); + return EvaluateDepfile(depfile, ge, this->LG, this->OutputConfig); +} + std::string cmCustomCommandGenerator::GetFullDepfile() const { - std::string depfile = this->CC->GetDepfile(); + std::string depfile = this->GetDepfile(); if (depfile.empty()) { return ""; } diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 4be5b3f..53e5573 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -57,6 +57,7 @@ public: std::vector const& GetDepends() const; std::set>> const& GetUtilities() const; bool HasOnlyEmptyCommandLines() const; + std::string GetDepfile() const; std::string GetFullDepfile() const; std::string GetInternalDepfile() const; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 03d1697..c2a6410 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -670,7 +670,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement( cmCryptoHash hash(cmCryptoHash::AlgoSHA256); customStep += hash.HashString(ninjaOutputs[0]).substr(0, 7); - std::string depfile = cc->GetDepfile(); + std::string depfile = ccg.GetDepfile(); if (!depfile.empty()) { switch (cc->GetCMP0116Status()) { case cmPolicies::WARN: diff --git a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake index 01eac91..e4fdb4a 100644 --- a/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake +++ b/Tests/RunCMake/BuildDepends/CustomCommandDepfile.cmake @@ -3,15 +3,15 @@ enable_language(C) add_custom_command( OUTPUT topcc.c - DEPFILE topcc.c.d - COMMAND ${CMAKE_COMMAND} -DOUTFILE=${CMAKE_CURRENT_BINARY_DIR}/topcc.c -DINFILE=topccdep.txt -DDEPFILE=topcc.c.d -P "${CMAKE_CURRENT_LIST_DIR}/WriteDepfile.cmake" + DEPFILE topcc_$.c.d + COMMAND ${CMAKE_COMMAND} -DOUTFILE=${CMAKE_CURRENT_BINARY_DIR}/topcc.c -DINFILE=topccdep.txt -DDEPFILE=topcc_$.c.d -P "${CMAKE_CURRENT_LIST_DIR}/WriteDepfile.cmake" ) add_custom_target(topcc ALL DEPENDS topcc.c) add_custom_command( OUTPUT topexe.c - DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/topexe.c.d - COMMAND ${CMAKE_COMMAND} -DOUTFILE=topexe.c "-DINFILE=${CMAKE_CURRENT_BINARY_DIR}/topexedep.txt" -DDEPFILE=topexe.c.d -P "${CMAKE_CURRENT_LIST_DIR}/WriteDepfile.cmake" + DEPFILE ${CMAKE_CURRENT_BINARY_DIR}/topexe_$.c.d + COMMAND ${CMAKE_COMMAND} -DOUTFILE=topexe.c "-DINFILE=${CMAKE_CURRENT_BINARY_DIR}/topexedep.txt" -DDEPFILE=topexe_$.c.d -P "${CMAKE_CURRENT_LIST_DIR}/WriteDepfile.cmake" ) add_executable(topexe "${CMAKE_CURRENT_BINARY_DIR}/topexe.c") diff --git a/Tests/RunCMake/Ninja/CustomCommandDepfile-check.cmake b/Tests/RunCMake/Ninja/CustomCommandDepfile-check.cmake index 189de64..51f4f52 100644 --- a/Tests/RunCMake/Ninja/CustomCommandDepfile-check.cmake +++ b/Tests/RunCMake/Ninja/CustomCommandDepfile-check.cmake @@ -1,5 +1,10 @@ set(log "${RunCMake_BINARY_DIR}/CustomCommandDepfile-build/build.ninja") file(READ "${log}" build_file) + +set(RunCMake_TEST_FAILED) if(NOT "${build_file}" MATCHES "depfile = test\\.d") - set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: depfile = test.d") + list(APPEND RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: depfile = test.d") +endif() +if(NOT "${build_file}" MATCHES "depfile = test_Debug\\.d") + list(APPEND RunCMake_TEST_FAILED "\nLog file:\n ${log}\ndoes not have expected line: depfile = test_Debug.d") endif() diff --git a/Tests/RunCMake/Ninja/CustomCommandDepfile.cmake b/Tests/RunCMake/Ninja/CustomCommandDepfile.cmake index dbef2a5..0838d14 100644 --- a/Tests/RunCMake/Ninja/CustomCommandDepfile.cmake +++ b/Tests/RunCMake/Ninja/CustomCommandDepfile.cmake @@ -6,6 +6,17 @@ add_custom_command( WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DEPFILE "test.d" ) -add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hello.copy.c") + +add_custom_command( + OUTPUT hello.copy2.c + COMMAND "${CMAKE_COMMAND}" -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/hello.c" + hello.copy2.c + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + DEPFILE "test_$.d" + ) + +add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hello.copy.c" + "${CMAKE_CURRENT_BINARY_DIR}/hello.copy2.c") include(CheckNoPrefixSubDir.cmake) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 0c0619d..1350326 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -67,7 +67,7 @@ run_CMP0058(WARN-by) run_CMP0058(NEW-no) run_CMP0058(NEW-by) -run_cmake(CustomCommandDepfile) +run_cmake_with_options(CustomCommandDepfile -DCMAKE_BUILD_TYPE=Debug) run_cmake(CustomCommandJobPool) run_cmake(JobPoolUsesTerminal) diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake index c595b10..a7837ca 100644 --- a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile-check.cmake @@ -1,5 +1,10 @@ set(log "${RunCMake_BINARY_DIR}/CustomCommandDepfile-build/CMakeFiles/impl-Debug.ninja") file(READ "${log}" build_file) + +set(RunCMake_TEST_FAILED) if(NOT "${build_file}" MATCHES "depfile = test\\.d") - set(RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: depfile = test.d") + list(APPEND RunCMake_TEST_FAILED "Log file:\n ${log}\ndoes not have expected line: depfile = test.d") +endif() +if(NOT "${build_file}" MATCHES "depfile = test_Debug\\.d") + list(APPEND RunCMake_TEST_FAILED "\nLog file:\n ${log}\ndoes not have expected line: depfile = test_Debug.d") endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake index 1a42670..4f8c114 100644 --- a/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/CustomCommandDepfile.cmake @@ -6,4 +6,15 @@ add_custom_command( WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" DEPFILE "test.d" ) -add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/main.copy.c") + +add_custom_command( + OUTPUT main.copy2.c + COMMAND "${CMAKE_COMMAND}" -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/main.c" + main.copy2.c + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + DEPFILE "test_$.d" + ) + +add_custom_target(copy ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/main.copy.c" + "${CMAKE_CURRENT_BINARY_DIR}/main.copy2.c") -- cgit v0.12 From 4bfe724e8149938031dde808610d369b1dc890ba Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 13 Apr 2021 00:01:05 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 22237e6..2d072ce 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210412) +set(CMake_VERSION_PATCH 20210413) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 156504fe755dedbdc9ed9147a65f4c730aad4b8a Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 14 Apr 2021 00:01:04 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2d072ce..8930a5f 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210413) +set(CMake_VERSION_PATCH 20210414) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From a790167101290eaf77d7a3ef8fd807160af1b9a9 Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Wed, 14 Apr 2021 12:02:30 -0400 Subject: KWSys 2021-04-14 (7ab1c601) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 7ab1c60177e76707fbdd462fdbf7304ad2532edc (master). Upstream Shortlog ----------------- Brad King (11): 85e76a10 Status: Add class to hold an OS-specific status of a system operation eec0add2 Directory: Return Status from Load 955e7c1e SystemTools: Return Status from RemoveFile and RemoveADirectory c5a99e59 SystemTools: Return Status from GetPermissions and SetPermissions fadfd7a0 SystemTools: Return Status from Touch 06216f0b SystemTools: Return Status from FileTimeCompare ab198a22 SystemTools: Return Status from GetShortPath 2446b205 SystemTools: Return Status from MakeDirectory 6aec6af9 SystemTools: Return Status from ChangeDirectory 0664553b SystemTools: Return Status from copy operations a95f61cf SystemTools: Return Status from symlink operations --- CMakeLists.txt | 6 +- Directory.cxx | 35 +++---- Directory.hxx.in | 6 +- Status.cxx | 60 +++++++++++ Status.hxx.in | 101 ++++++++++++++++++ SystemTools.cxx | 300 +++++++++++++++++++++++++++++------------------------ SystemTools.hxx.in | 65 ++++++------ testDirectory.cxx | 4 +- testStatus.cxx | 117 +++++++++++++++++++++ 9 files changed, 503 insertions(+), 191 deletions(-) create mode 100644 Status.cxx create mode 100644 Status.hxx.in create mode 100644 testStatus.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index b0a8542..bf8543e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR) set(KWSYS_USE_MD5 1) set(KWSYS_USE_Process 1) set(KWSYS_USE_RegularExpression 1) + set(KWSYS_USE_Status 1) set(KWSYS_USE_System 1) set(KWSYS_USE_SystemTools 1) set(KWSYS_USE_CommandLineArguments 1) @@ -157,6 +158,7 @@ if(KWSYS_USE_SystemTools) set(KWSYS_USE_Directory 1) set(KWSYS_USE_FStream 1) set(KWSYS_USE_Encoding 1) + set(KWSYS_USE_Status 1) endif() if(KWSYS_USE_Glob) set(KWSYS_USE_Directory 1) @@ -177,6 +179,7 @@ if(KWSYS_USE_System) endif() if(KWSYS_USE_Directory) set(KWSYS_USE_Encoding 1) + set(KWSYS_USE_Status 1) endif() if(KWSYS_USE_DynamicLoader) set(KWSYS_USE_Encoding 1) @@ -630,7 +633,7 @@ set(KWSYS_HXX_FILES Configure String) # Add selected C++ classes. set(cppclasses Directory DynamicLoader Encoding Glob RegularExpression SystemTools - CommandLineArguments FStream SystemInformation ConsoleBuf + CommandLineArguments FStream SystemInformation ConsoleBuf Status ) foreach(cpp ${cppclasses}) if(KWSYS_USE_${cpp}) @@ -963,6 +966,7 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR) # C++ tests set(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testConfigure.cxx + testStatus.cxx testSystemTools.cxx testCommandLineArguments.cxx testCommandLineArguments1.cxx diff --git a/Directory.cxx b/Directory.cxx index e70d4e8..2e8aa83 100644 --- a/Directory.cxx +++ b/Directory.cxx @@ -94,7 +94,7 @@ void Directory::Clear() namespace KWSYS_NAMESPACE { -bool Directory::Load(const std::string& name, std::string* errorMessage) +Status Directory::Load(std::string const& name, std::string* errorMessage) { this->Clear(); intptr_t srchHandle; @@ -121,21 +121,11 @@ bool Directory::Load(const std::string& name, std::string* errorMessage) delete[] buf; if (srchHandle == -1) { + Status status = Status::POSIX_errno(); if (errorMessage) { - if (unsigned int errorId = GetLastError()) { - LPSTR message = nullptr; - DWORD size = FormatMessageA( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&message, 0, nullptr); - *errorMessage = std::string(message, size); - LocalFree(message); - } else { - *errorMessage = "Unknown error."; - } + *errorMessage = status.GetString(); } - return false; + return status; } // Loop through names @@ -143,7 +133,14 @@ bool Directory::Load(const std::string& name, std::string* errorMessage) this->Internal->Files.push_back(Encoding::ToNarrow(data.name)); } while (_wfindnext(srchHandle, &data) != -1); this->Internal->Path = name; - return _findclose(srchHandle) != -1; + if (_findclose(srchHandle) == -1) { + Status status = Status::POSIX_errno(); + if (errorMessage) { + *errorMessage = status.GetString(); + } + return status; + } + return Status::Success(); } unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name, @@ -220,7 +217,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name, namespace KWSYS_NAMESPACE { -bool Directory::Load(const std::string& name, std::string* errorMessage) +Status Directory::Load(std::string const& name, std::string* errorMessage) { this->Clear(); @@ -231,7 +228,7 @@ bool Directory::Load(const std::string& name, std::string* errorMessage) if (errorMessage != nullptr) { *errorMessage = std::string(strerror(errno)); } - return false; + return Status::POSIX_errno(); } errno = 0; @@ -242,12 +239,12 @@ bool Directory::Load(const std::string& name, std::string* errorMessage) if (errorMessage != nullptr) { *errorMessage = std::string(strerror(errno)); } - return false; + return Status::POSIX_errno(); } this->Internal->Path = name; closedir(dir); - return true; + return Status::Success(); } unsigned long Directory::GetNumberOfFilesInDirectory(const std::string& name, diff --git a/Directory.hxx.in b/Directory.hxx.in index 7bc9db0..d501116 100644 --- a/Directory.hxx.in +++ b/Directory.hxx.in @@ -4,6 +4,7 @@ #define @KWSYS_NAMESPACE@_Directory_hxx #include <@KWSYS_NAMESPACE@/Configure.h> +#include <@KWSYS_NAMESPACE@/Status.hxx> #include @@ -32,10 +33,9 @@ public: /** * Load the specified directory and load the names of the files - * in that directory. 0 is returned if the directory can not be - * opened, 1 if it is opened. + * in that directory. */ - bool Load(const std::string&, std::string* errorMessage = nullptr); + Status Load(std::string const&, std::string* errorMessage = nullptr); /** * Return the number of files in the current directory. diff --git a/Status.cxx b/Status.cxx new file mode 100644 index 0000000..503d1e1 --- /dev/null +++ b/Status.cxx @@ -0,0 +1,60 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Status.hxx) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Status.hxx.in" +#endif + +#include +#include +#include + +#if defined(_WIN32) +# include +#endif + +namespace KWSYS_NAMESPACE { + +Status Status::POSIX_errno() +{ + return Status::POSIX(errno); +} + +#ifdef _WIN32 +Status Status::Windows_GetLastError() +{ + return Status::Windows(GetLastError()); +} +#endif + +std::string Status::GetString() const +{ + std::string err; + switch (this->Kind_) { + case Kind::Success: + err = "Success"; + break; + case Kind::POSIX: + err = strerror(this->POSIX_); + break; +#ifdef _WIN32 + case Kind::Windows: { + LPSTR message = NULL; + DWORD size = FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, this->Windows_, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR)&message, 0, NULL); + err = std::string(message, size); + LocalFree(message); + } break; +#endif + }; + return err; +} + +} // namespace KWSYS_NAMESPACE diff --git a/Status.hxx.in b/Status.hxx.in new file mode 100644 index 0000000..feb5b84 --- /dev/null +++ b/Status.hxx.in @@ -0,0 +1,101 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ +#ifndef @KWSYS_NAMESPACE@_Status_hxx +#define @KWSYS_NAMESPACE@_Status_hxx + +#include <@KWSYS_NAMESPACE@/Configure.hxx> + +#include + +namespace @KWSYS_NAMESPACE@ { + +/** \class Status + * \brief OS-specific status of a system operation. + */ +class @KWSYS_NAMESPACE@_EXPORT Status +{ +public: + enum class Kind + { + Success, + POSIX, +#ifdef _WIN32 + Windows, +#endif + }; + + /** Construct with kind "Success". */ + Status() = default; + + /** Construct with kind "Success". */ + static Status Success() { return Status(); } + + /** Construct with kind "POSIX" using given errno-style value. */ + static Status POSIX(int e) + { + Status s(Kind::POSIX); + s.POSIX_ = e; + return s; + } + + /** Construct with kind "POSIX" using errno. */ + static Status POSIX_errno(); + +#ifdef _WIN32 + /** Construct with kind "Windows" using given GetLastError()-style value. */ + static Status Windows(unsigned int e) + { + Status s(Kind::Windows); + s.Windows_ = e; + return s; + } + + /** Construct with kind "Windows" using GetLastError(). */ + static Status Windows_GetLastError(); +#endif + + /** Return true on "Success", false otherwise. */ + explicit operator bool() const { return this->Kind_ == Kind::Success; } + + /** Return the kind of status. */ + Kind GetKind() const { return this->Kind_; } + + /** If the kind is "POSIX", returns the errno-style value. + Otherwise, returns 0. */ + int GetPOSIX() const + { + return this->Kind_ == Kind::POSIX ? this->POSIX_ : 0; + } + +#ifdef _WIN32 + /** If the kind is "Windows", returns the GetLastError()-style value. + Otherwise, returns 0. */ + int GetWindows() const + { + return this->Kind_ == Kind::Windows ? this->Windows_ : 0; + } +#endif + + /** Return a human-readable description of the status. */ + std::string GetString() const; + +private: + Status(Kind kind) + : Kind_(kind) + { + } + + Kind Kind_ = Kind::Success; + + union + { + int POSIX_; +#ifdef _WIN32 + unsigned int Windows_; +#endif + }; +}; + +} // namespace @KWSYS_NAMESPACE@ + +#endif diff --git a/SystemTools.cxx b/SystemTools.cxx index 4d974a8..2518845 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -882,21 +882,24 @@ FILE* SystemTools::Fopen(const std::string& file, const char* mode) #endif } -bool SystemTools::MakeDirectory(const char* path, const mode_t* mode) +Status SystemTools::MakeDirectory(const char* path, const mode_t* mode) { if (!path) { - return false; + return Status::POSIX(EINVAL); } return SystemTools::MakeDirectory(std::string(path), mode); } -bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) +Status SystemTools::MakeDirectory(std::string const& path, const mode_t* mode) { - if (SystemTools::PathExists(path)) { - return SystemTools::FileIsDirectory(path); - } if (path.empty()) { - return false; + return Status::POSIX(EINVAL); + } + if (SystemTools::PathExists(path)) { + if (SystemTools::FileIsDirectory(path)) { + return Status::Success(); + } + return Status::POSIX(EEXIST); } std::string dir = path; SystemTools::ConvertToUnixSlashes(dir); @@ -914,15 +917,11 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode) ++pos; } topdir = dir; - if (Mkdir(topdir, mode) != 0) { - // if it is some other error besides directory exists - // then return false - if (errno != EEXIST) { - return false; - } + if (Mkdir(topdir, mode) != 0 && errno != EEXIST) { + return Status::POSIX_errno(); } - return true; + return Status::Success(); } // replace replace with with as many times as it shows up in source. @@ -1411,18 +1410,18 @@ int SystemTools::Stat(const std::string& path, SystemTools::Stat_t* buf) #endif } -bool SystemTools::Touch(const std::string& filename, bool create) +Status SystemTools::Touch(std::string const& filename, bool create) { if (!SystemTools::FileExists(filename)) { if (create) { FILE* file = Fopen(filename, "a+b"); if (file) { fclose(file); - return true; + return Status::Success(); } - return false; + return Status::POSIX_errno(); } else { - return true; + return Status::Success(); } } #if defined(_WIN32) && !defined(__CYGWIN__) @@ -1430,31 +1429,32 @@ bool SystemTools::Touch(const std::string& filename, bool create) FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!h) { - return false; + return Status::Windows_GetLastError(); } FILETIME mtime; GetSystemTimeAsFileTime(&mtime); if (!SetFileTime(h, 0, 0, &mtime)) { + Status status = Status::Windows_GetLastError(); CloseHandle(h); - return false; + return status; } CloseHandle(h); #elif KWSYS_CXX_HAS_UTIMENSAT // utimensat is only available on newer Unixes and macOS 10.13+ if (utimensat(AT_FDCWD, filename.c_str(), nullptr, 0) < 0) { - return false; + return Status::POSIX_errno(); } #else // fall back to utimes if (utimes(filename.c_str(), nullptr) < 0) { - return false; + return Status::POSIX_errno(); } #endif - return true; + return Status::Success(); } -bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, - int* result) +Status SystemTools::FileTimeCompare(std::string const& f1, + std::string const& f2, int* result) { // Default to same time. *result = 0; @@ -1462,11 +1462,11 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, // POSIX version. Use stat function to get file modification time. struct stat s1; if (stat(f1.c_str(), &s1) != 0) { - return false; + return Status::POSIX_errno(); } struct stat s2; if (stat(f2.c_str(), &s2) != 0) { - return false; + return Status::POSIX_errno(); } # if KWSYS_CXX_STAT_HAS_ST_MTIM // Compare using nanosecond resolution. @@ -1504,17 +1504,17 @@ bool SystemTools::FileTimeCompare(const std::string& f1, const std::string& f2, WIN32_FILE_ATTRIBUTE_DATA f2d; if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f1).c_str(), GetFileExInfoStandard, &f1d)) { - return false; + return Status::Windows_GetLastError(); } if (!GetFileAttributesExW(Encoding::ToWindowsExtendedPath(f2).c_str(), GetFileExInfoStandard, &f2d)) { - return false; + return Status::Windows_GetLastError(); } // Compare the file times using resolution provided by system call. *result = (int)CompareFileTime(&f1d.ftLastWriteTime, &f2d.ftLastWriteTime); #endif - return true; + return Status::Success(); } // Return a capitalized string (i.e the first letter is uppercased, all other @@ -2129,8 +2129,8 @@ static std::string FileInDir(const std::string& source, const std::string& dir) return new_destination + '/' + SystemTools::GetFilenameName(source); } -bool SystemTools::CopyFileIfDifferent(const std::string& source, - const std::string& destination) +Status SystemTools::CopyFileIfDifferent(std::string const& source, + std::string const& destination) { // special check for a destination that is a directory // FilesDiffer does not handle file to directory compare @@ -2147,7 +2147,7 @@ bool SystemTools::CopyFileIfDifferent(const std::string& source, } } // at this point the files must be the same so return true - return true; + return Status::Success(); } #define KWSYS_ST_BUFFER 4096 @@ -2273,13 +2273,13 @@ bool SystemTools::TextFilesDiffer(const std::string& path1, return false; } -bool SystemTools::CopyFileContentBlockwise(const std::string& source, - const std::string& destination) +Status SystemTools::CopyFileContentBlockwise(std::string const& source, + std::string const& destination) { // Open files kwsys::ifstream fin(source.c_str(), std::ios::in | std::ios::binary); if (!fin) { - return false; + return Status::POSIX_errno(); } // try and remove the destination file so that read only destination files @@ -2291,7 +2291,7 @@ bool SystemTools::CopyFileContentBlockwise(const std::string& source, kwsys::ofstream fout(destination.c_str(), std::ios::out | std::ios::trunc | std::ios::binary); if (!fout) { - return false; + return Status::POSIX_errno(); } // This copy loop is very sensitive on certain platforms with @@ -2320,10 +2320,10 @@ bool SystemTools::CopyFileContentBlockwise(const std::string& source, fout.close(); if (!fout) { - return false; + return Status::POSIX_errno(); } - return true; + return Status::Success(); } /** @@ -2338,13 +2338,13 @@ bool SystemTools::CopyFileContentBlockwise(const std::string& source, * - The underlying filesystem does not support file cloning * - An unspecified error occurred */ -bool SystemTools::CloneFileContent(const std::string& source, - const std::string& destination) +Status SystemTools::CloneFileContent(std::string const& source, + std::string const& destination) { #if defined(__linux) && defined(FICLONE) int in = open(source.c_str(), O_RDONLY); if (in < 0) { - return false; + return Status::POSIX_errno(); } SystemTools::RemoveFile(destination); @@ -2352,38 +2352,42 @@ bool SystemTools::CloneFileContent(const std::string& source, int out = open(destination.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (out < 0) { + Status status = Status::POSIX_errno(); close(in); - return false; + return status; } - int result = ioctl(out, FICLONE, in); + Status status = Status::Success(); + if (ioctl(out, FICLONE, in) < 0) { + status = Status::POSIX_errno(); + } close(in); close(out); - if (result < 0) { - return false; - } - - return true; + return status; #else (void)source; (void)destination; - return false; + return Status::POSIX(ENOSYS); #endif } /** * Copy a file named by "source" to the file named by "destination". */ -bool SystemTools::CopyFileAlways(const std::string& source, - const std::string& destination) +Status SystemTools::CopyFileAlways(std::string const& source, + std::string const& destination) { + Status status; mode_t perm = 0; - bool perms = SystemTools::GetPermissions(source, perm); + Status perms = SystemTools::GetPermissions(source, perm); std::string real_destination = destination; if (SystemTools::FileIsDirectory(source)) { - SystemTools::MakeDirectory(destination); + status = SystemTools::MakeDirectory(destination); + if (!status) { + return status; + } } else { // If destination is a directory, try to create a file with the same // name as the source in that directory. @@ -2400,30 +2404,34 @@ bool SystemTools::CopyFileAlways(const std::string& source, } // If files are the same do not copy if (SystemTools::SameFile(source, real_destination)) { - return true; + return status; } // Create destination directory - - SystemTools::MakeDirectory(destination_dir); - - if (!SystemTools::CloneFileContent(source, real_destination)) { - // if cloning did not succeed, fall back to blockwise copy - if (!SystemTools::CopyFileContentBlockwise(source, real_destination)) { - return false; + if (!destination_dir.empty()) { + status = SystemTools::MakeDirectory(destination_dir); + if (!status) { + return status; } } + + status = SystemTools::CloneFileContent(source, real_destination); + // if cloning did not succeed, fall back to blockwise copy + if (!status) { + status = SystemTools::CopyFileContentBlockwise(source, real_destination); + } + if (!status) { + return status; + } } if (perms) { - if (!SystemTools::SetPermissions(real_destination, perm)) { - return false; - } + status = SystemTools::SetPermissions(real_destination, perm); } - return true; + return status; } -bool SystemTools::CopyAFile(const std::string& source, - const std::string& destination, bool always) +Status SystemTools::CopyAFile(std::string const& source, + std::string const& destination, bool always) { if (always) { return SystemTools::CopyFileAlways(source, destination); @@ -2436,18 +2444,21 @@ bool SystemTools::CopyAFile(const std::string& source, * Copy a directory content from "source" directory to the directory named by * "destination". */ -bool SystemTools::CopyADirectory(const std::string& source, - const std::string& destination, bool always) +Status SystemTools::CopyADirectory(std::string const& source, + std::string const& destination, bool always) { + Status status; Directory dir; - if (dir.Load(source) == 0) { - return false; + status = dir.Load(source); + if (!status) { + return status; } - size_t fileNum; - if (!SystemTools::MakeDirectory(destination)) { - return false; + status = SystemTools::MakeDirectory(destination); + if (!status) { + return status; } - for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { + + for (size_t fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { if (strcmp(dir.GetFile(static_cast(fileNum)), ".") != 0 && strcmp(dir.GetFile(static_cast(fileNum)), "..") != 0) { std::string fullPath = source; @@ -2457,18 +2468,20 @@ bool SystemTools::CopyADirectory(const std::string& source, std::string fullDestPath = destination; fullDestPath += "/"; fullDestPath += dir.GetFile(static_cast(fileNum)); - if (!SystemTools::CopyADirectory(fullPath, fullDestPath, always)) { - return false; + status = SystemTools::CopyADirectory(fullPath, fullDestPath, always); + if (!status) { + return status; } } else { - if (!SystemTools::CopyAFile(fullPath, destination, always)) { - return false; + status = SystemTools::CopyAFile(fullPath, destination, always); + if (!status) { + return status; } } } } - return true; + return status; } // return size of file; also returns zero if no file exists @@ -2550,26 +2563,26 @@ std::string SystemTools::GetLastSystemError() return strerror(e); } -bool SystemTools::RemoveFile(const std::string& source) +Status SystemTools::RemoveFile(std::string const& source) { #ifdef _WIN32 std::wstring const& ws = Encoding::ToWindowsExtendedPath(source); if (DeleteFileW(ws.c_str())) { - return true; + return Status::Success(); } DWORD err = GetLastError(); if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND) { - return true; + return Status::Success(); } if (err != ERROR_ACCESS_DENIED) { - return false; + return Status::Windows(err); } /* The file may be read-only. Try adding write permission. */ mode_t mode; if (!SystemTools::GetPermissions(source, mode) || !SystemTools::SetPermissions(source, S_IWRITE)) { SetLastError(err); - return false; + return Status::Windows(err); } const DWORD DIRECTORY_SOFT_LINK_ATTRS = @@ -2578,26 +2591,29 @@ bool SystemTools::RemoveFile(const std::string& source) if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & DIRECTORY_SOFT_LINK_ATTRS) == DIRECTORY_SOFT_LINK_ATTRS && RemoveDirectoryW(ws.c_str())) { - return true; + return Status::Success(); } if (DeleteFileW(ws.c_str()) || GetLastError() == ERROR_FILE_NOT_FOUND || GetLastError() == ERROR_PATH_NOT_FOUND) { - return true; + return Status::Success(); } /* Try to restore the original permissions. */ SystemTools::SetPermissions(source, mode); SetLastError(err); - return false; + return Status::Windows(err); #else - return unlink(source.c_str()) == 0 || errno == ENOENT; + if (unlink(source.c_str()) != 0 && errno != ENOENT) { + return Status::POSIX_errno(); + } + return Status::Success(); #endif } -bool SystemTools::RemoveADirectory(const std::string& source) +Status SystemTools::RemoveADirectory(std::string const& source) { // Add write permission to the directory so we can modify its // content to remove files and directories from it. - mode_t mode; + mode_t mode = 0; if (SystemTools::GetPermissions(source, mode)) { #if defined(_WIN32) && !defined(__CYGWIN__) mode |= S_IWRITE; @@ -2607,8 +2623,13 @@ bool SystemTools::RemoveADirectory(const std::string& source) SystemTools::SetPermissions(source, mode); } + Status status; Directory dir; - dir.Load(source); + status = dir.Load(source); + if (!status) { + return status; + } + size_t fileNum; for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) { if (strcmp(dir.GetFile(static_cast(fileNum)), ".") != 0 && @@ -2618,18 +2639,23 @@ bool SystemTools::RemoveADirectory(const std::string& source) fullPath += dir.GetFile(static_cast(fileNum)); if (SystemTools::FileIsDirectory(fullPath) && !SystemTools::FileIsSymlink(fullPath)) { - if (!SystemTools::RemoveADirectory(fullPath)) { - return false; + status = SystemTools::RemoveADirectory(fullPath); + if (!status) { + return status; } } else { - if (!SystemTools::RemoveFile(fullPath)) { - return false; + status = SystemTools::RemoveFile(fullPath); + if (!status) { + return status; } } } } - return (Rmdir(source) == 0); + if (Rmdir(source) != 0) { + status = Status::POSIX_errno(); + } + return status; } /** @@ -3023,44 +3049,49 @@ bool SystemTools::FileIsFIFO(const std::string& name) } #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::CreateSymlink(const std::string&, const std::string&) +Status SystemTools::CreateSymlink(std::string const&, std::string const&) { - return false; + return Status::Windows(ERROR_NOT_SUPPORTED); } #else -bool SystemTools::CreateSymlink(const std::string& origName, - const std::string& newName) +Status SystemTools::CreateSymlink(std::string const& origName, + std::string const& newName) { - return symlink(origName.c_str(), newName.c_str()) >= 0; + if (symlink(origName.c_str(), newName.c_str()) < 0) { + return Status::POSIX_errno(); + } + return Status::Success(); } #endif #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadSymlink(const std::string&, std::string&) +Status SystemTools::ReadSymlink(std::string const&, std::string&) { - return false; + return Status::Windows(ERROR_NOT_SUPPORTED); } #else -bool SystemTools::ReadSymlink(const std::string& newName, - std::string& origName) +Status SystemTools::ReadSymlink(std::string const& newName, + std::string& origName) { char buf[KWSYS_SYSTEMTOOLS_MAXPATH + 1]; int count = static_cast( readlink(newName.c_str(), buf, KWSYS_SYSTEMTOOLS_MAXPATH)); - if (count >= 0) { - // Add null-terminator. - buf[count] = 0; - origName = buf; - return true; - } else { - return false; + if (count < 0) { + return Status::POSIX_errno(); } + // Add null-terminator. + buf[count] = 0; + origName = buf; + return Status::Success(); } #endif -int SystemTools::ChangeDirectory(const std::string& dir) +Status SystemTools::ChangeDirectory(std::string const& dir) { - return Chdir(dir); + if (Chdir(dir) < 0) { + return Status::POSIX_errno(); + } + return Status::Success(); } std::string SystemTools::GetCurrentWorkingDirectory() @@ -3957,7 +3988,8 @@ bool SystemToolsStatic::FileIsFullPath(const char* in_name, size_t len) return false; } -bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath) +Status SystemTools::GetShortPath(std::string const& path, + std::string& shortPath) { #if defined(_WIN32) && !defined(__CYGWIN__) std::string tempPath = path; // create a buffer @@ -3977,14 +4009,14 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath) } if (ret == 0) { - return false; + return Status::Windows_GetLastError(); } else { shortPath = Encoding::ToNarrow(&buffer[0]); - return true; + return Status::Success(); } #else shortPath = path; - return true; + return Status::Success(); #endif } @@ -4085,21 +4117,21 @@ int SystemTools::GetTerminalWidth() return width; } -bool SystemTools::GetPermissions(const char* file, mode_t& mode) +Status SystemTools::GetPermissions(const char* file, mode_t& mode) { if (!file) { - return false; + return Status::POSIX(EINVAL); } return SystemTools::GetPermissions(std::string(file), mode); } -bool SystemTools::GetPermissions(const std::string& file, mode_t& mode) +Status SystemTools::GetPermissions(std::string const& file, mode_t& mode) { #if defined(_WIN32) DWORD attr = GetFileAttributesW(Encoding::ToWindowsExtendedPath(file).c_str()); if (attr == INVALID_FILE_ATTRIBUTES) { - return false; + return Status::Windows_GetLastError(); } if ((attr & FILE_ATTRIBUTE_READONLY) != 0) { mode = (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)); @@ -4122,27 +4154,27 @@ bool SystemTools::GetPermissions(const std::string& file, mode_t& mode) #else struct stat st; if (stat(file.c_str(), &st) < 0) { - return false; + return Status::POSIX_errno(); } mode = st.st_mode; #endif - return true; + return Status::Success(); } -bool SystemTools::SetPermissions(const char* file, mode_t mode, - bool honor_umask) +Status SystemTools::SetPermissions(const char* file, mode_t mode, + bool honor_umask) { if (!file) { - return false; + return Status::POSIX(EINVAL); } return SystemTools::SetPermissions(std::string(file), mode, honor_umask); } -bool SystemTools::SetPermissions(const std::string& file, mode_t mode, - bool honor_umask) +Status SystemTools::SetPermissions(std::string const& file, mode_t mode, + bool honor_umask) { if (!SystemTools::PathExists(file)) { - return false; + return Status::POSIX(ENOENT); } if (honor_umask) { mode_t currentMask = umask(0); @@ -4155,10 +4187,10 @@ bool SystemTools::SetPermissions(const std::string& file, mode_t mode, if (chmod(file.c_str(), mode) < 0) #endif { - return false; + return Status::POSIX_errno(); } - return true; + return Status::Success(); } std::string SystemTools::GetParentDirectory(const std::string& fileOrDir) diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index a7b1288..e5d115e 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -4,6 +4,7 @@ #define @KWSYS_NAMESPACE@_SystemTools_hxx #include <@KWSYS_NAMESPACE@/Configure.hxx> +#include <@KWSYS_NAMESPACE@/Status.hxx> #include #include @@ -339,7 +340,7 @@ public: /** Change the modification time or create a file */ - static bool Touch(const std::string& filename, bool create); + static Status Touch(std::string const& filename, bool create); /** * Compare file modification times. @@ -347,8 +348,8 @@ public: * When true is returned, result has -1, 0, +1 for * f1 older, same, or newer than f2. */ - static bool FileTimeCompare(const std::string& f1, const std::string& f2, - int* result); + static Status FileTimeCompare(std::string const& f1, std::string const& f2, + int* result); /** * Get the file extension (including ".") needed for an executable @@ -507,7 +508,7 @@ public: * For windows return the short path for the given path, * Unix just a pass through */ - static bool GetShortPath(const std::string& path, std::string& result); + static Status GetShortPath(std::string const& path, std::string& result); /** * Read line from file. Make sure to read a full line and truncates it if @@ -553,16 +554,16 @@ public: * can make a full path even if none of the directories existed * prior to calling this function. */ - static bool MakeDirectory(const char* path, const mode_t* mode = nullptr); - static bool MakeDirectory(const std::string& path, - const mode_t* mode = nullptr); + static Status MakeDirectory(const char* path, const mode_t* mode = nullptr); + static Status MakeDirectory(std::string const& path, + const mode_t* mode = nullptr); /** * Copy the source file to the destination file only * if the two files differ. */ - static bool CopyFileIfDifferent(const std::string& source, - const std::string& destination); + static Status CopyFileIfDifferent(std::string const& source, + std::string const& destination); /** * Compare the contents of two files. Return true if different @@ -580,13 +581,13 @@ public: /** * Blockwise copy source to destination file */ - static bool CopyFileContentBlockwise(const std::string& source, - const std::string& destination); + static Status CopyFileContentBlockwise(std::string const& source, + std::string const& destination); /** * Clone the source file to the destination file */ - static bool CloneFileContent(const std::string& source, - const std::string& destination); + static Status CloneFileContent(std::string const& source, + std::string const& destination); /** * Return true if the two files are the same file @@ -596,16 +597,16 @@ public: /** * Copy a file. */ - static bool CopyFileAlways(const std::string& source, - const std::string& destination); + static Status CopyFileAlways(std::string const& source, + std::string const& destination); /** * Copy a file. If the "always" argument is true the file is always * copied. If it is false, the file is copied only if it is new or * has changed. */ - static bool CopyAFile(const std::string& source, - const std::string& destination, bool always = true); + static Status CopyAFile(std::string const& source, + std::string const& destination, bool always = true); /** * Copy content directory to another directory with all files and @@ -613,19 +614,19 @@ public: * always copied. If it is false, only files that have changed or * are new are copied. */ - static bool CopyADirectory(const std::string& source, - const std::string& destination, - bool always = true); + static Status CopyADirectory(std::string const& source, + std::string const& destination, + bool always = true); /** * Remove a file */ - static bool RemoveFile(const std::string& source); + static Status RemoveFile(std::string const& source); /** * Remove a directory */ - static bool RemoveADirectory(const std::string& source); + static Status RemoveADirectory(std::string const& source); /** * Get the maximum full file path length @@ -719,14 +720,14 @@ public: * Create a symbolic link if the platform supports it. Returns whether * creation succeeded. */ - static bool CreateSymlink(const std::string& origName, - const std::string& newName); + static Status CreateSymlink(std::string const& origName, + std::string const& newName); /** * Read the contents of a symbolic link. Returns whether reading * succeeded. */ - static bool ReadSymlink(const std::string& newName, std::string& origName); + static Status ReadSymlink(std::string const& newName, std::string& origName); /** * Try to locate the file 'filename' in the directory 'dir'. @@ -776,12 +777,12 @@ public: * WARNING: A non-thread-safe method is currently used to get the umask * if a honor_umask parameter is set to true. */ - static bool GetPermissions(const char* file, mode_t& mode); - static bool GetPermissions(const std::string& file, mode_t& mode); - static bool SetPermissions(const char* file, mode_t mode, - bool honor_umask = false); - static bool SetPermissions(const std::string& file, mode_t mode, - bool honor_umask = false); + static Status GetPermissions(const char* file, mode_t& mode); + static Status GetPermissions(std::string const& file, mode_t& mode); + static Status SetPermissions(const char* file, mode_t mode, + bool honor_umask = false); + static Status SetPermissions(std::string const& file, mode_t mode, + bool honor_umask = false); /** ----------------------------------------------------------------- * Time Manipulation Routines @@ -878,7 +879,7 @@ public: /** * Change directory to the directory specified */ - static int ChangeDirectory(const std::string& dir); + static Status ChangeDirectory(std::string const& dir); /** * Get the result of strerror(errno) diff --git a/testDirectory.cxx b/testDirectory.cxx index eb3ca32..06a22dc 100644 --- a/testDirectory.cxx +++ b/testDirectory.cxx @@ -88,7 +88,7 @@ int _nonExistentDirectoryTest() errorMessage = "foo"; // Increment res failure if directory lists - res += testdir.Load(testdirpath, &errorMessage); + res += testdir.Load(testdirpath, &errorMessage) ? 1 : 0; #if !defined(_WIN32) || defined(__CYGWIN__) // Increment res failure if errorMessage is unmodified res += (errorMessage == "foo"); @@ -120,7 +120,7 @@ int _copyDirectoryTest() std::cerr << destination << " shouldn't exist before test" << std::endl; return 2; } - const bool copysuccess = SystemTools::CopyADirectory(source, destination); + const Status copysuccess = SystemTools::CopyADirectory(source, destination); const bool destinationexists = SystemTools::PathExists(destination); if (copysuccess) { std::cerr << "CopyADirectory should have returned false" << std::endl; diff --git a/testStatus.cxx b/testStatus.cxx new file mode 100644 index 0000000..f85ef42 --- /dev/null +++ b/testStatus.cxx @@ -0,0 +1,117 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying +file Copyright.txt or https://cmake.org/licensing#kwsys for details. */ +#include "kwsysPrivate.h" +#include KWSYS_HEADER(Status.hxx) + +// Work-around CMake dependency scanning limitation. This must +// duplicate the above list of headers. +#if 0 +# include "Status.hxx.in" +#endif + +#include +#include + +#ifdef _WIN32 +# include +#endif + +int testStatus(int, char* []) +{ + bool res = true; + { + kwsys::Status status; + if (status.GetKind() != kwsys::Status::Kind::Success) { + std::cerr << "Status default constructor does not produce Success\n"; + res = false; + } + + status = kwsys::Status::Success(); + if (status.GetKind() != kwsys::Status::Kind::Success) { + std::cerr << "Status Success constructor does not produce Success\n"; + res = false; + } + if (!status) { + std::cerr << "Status Success kind is not true\n"; + res = false; + } + if (status.GetPOSIX() != 0) { + std::cerr << "Status Success kind does not return POSIX 0\n"; + res = false; + } +#ifdef _WIN32 + if (status.GetWindows() != 0) { + std::cerr << "Status Success kind does not return Windows 0\n"; + res = false; + } +#endif + if (status.GetString() != "Success") { + std::cerr << "Status Success kind does not return \"Success\" string\n"; + res = false; + } + + status = kwsys::Status::POSIX(EINVAL); + if (status.GetKind() != kwsys::Status::Kind::POSIX) { + std::cerr << "Status POSIX constructor does not produce POSIX\n"; + res = false; + } + if (status) { + std::cerr << "Status POSIX kind is not false\n"; + res = false; + } + if (status.GetPOSIX() != EINVAL) { + std::cerr << "Status POSIX kind does not preserve POSIX value\n"; + res = false; + } +#ifdef _WIN32 + if (status.GetWindows() != 0) { + std::cerr << "Status POSIX kind does not return Windows 0\n"; + res = false; + } +#endif + if (status.GetString().empty()) { + std::cerr << "Status POSIX kind returns empty string\n"; + res = false; + } + errno = ENOENT; + status = kwsys::Status::POSIX_errno(); + if (status.GetPOSIX() != ENOENT) { + std::cerr << "Status POSIX_errno did not use errno\n"; + res = false; + } + errno = 0; + +#ifdef _WIN32 + status = kwsys::Status::Windows(ERROR_INVALID_PARAMETER); + if (status.GetKind() != kwsys::Status::Kind::Windows) { + std::cerr << "Status Windows constructor does not produce Windows\n"; + res = false; + } + if (status) { + std::cerr << "Status Windows kind is not false\n"; + res = false; + } + if (status.GetWindows() != ERROR_INVALID_PARAMETER) { + std::cerr << "Status Windows kind does not preserve Windows value\n"; + res = false; + } + if (status.GetPOSIX() != 0) { + std::cerr << "Status Windows kind does not return POSIX 0\n"; + res = false; + } + if (status.GetString().empty()) { + std::cerr << "Status Windows kind returns empty string\n"; + res = false; + } + + SetLastError(ERROR_FILE_NOT_FOUND); + status = kwsys::Status::Windows_GetLastError(); + if (status.GetWindows() != ERROR_FILE_NOT_FOUND) { + std::cerr << "Status Windows_GetLastError did not use GetLastError()\n"; + res = false; + } + SetLastError(ERROR_SUCCESS); +#endif + } + return res ? 0 : 1; +} -- cgit v0.12 From ec1b6157cbfefdcac5c971021a5700dd80318a09 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 12:15:54 -0400 Subject: Update CMake code using KWSys to account for Status return values KWSys as of 2021-04-14 changed the return type of `SystemTools` operations from `bool` to `Status`. Update our call sites. This may improve error reporting accuracy in a few places. --- Source/CPack/cmCPackSTGZGenerator.cxx | 13 +++++++------ Source/CTest/cmCTestScriptHandler.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/cmCTest.cxx | 6 +++--- Source/cmConditionEvaluator.cxx | 4 ++-- Source/cmFileCommand.cxx | 9 ++++++--- Source/cmQtAutoGenerator.cxx | 2 +- Source/cmSystemTools.cxx | 4 ++-- Source/cmSystemTools.h | 1 + Source/cmWorkingDirectory.cxx | 2 +- Source/cmcmd.cxx | 2 +- bootstrap | 2 ++ 12 files changed, 28 insertions(+), 21 deletions(-) diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index 3e36e8c..ad0a3e2 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -51,15 +51,16 @@ int cmCPackSTGZGenerator::PackageFiles() * so we must iterate over generated packages. */ for (std::string const& pfn : this->packageFileNames) { - retval &= cmSystemTools::SetPermissions(pfn.c_str(), + retval &= static_cast( + cmSystemTools::SetPermissions(pfn.c_str(), #if defined(_MSC_VER) || defined(__MINGW32__) - S_IREAD | S_IWRITE | S_IEXEC + S_IREAD | S_IWRITE | S_IEXEC #else - S_IRUSR | S_IWUSR | S_IXUSR | - S_IRGRP | S_IWGRP | S_IXGRP | - S_IROTH | S_IWOTH | S_IXOTH + S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | + S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | + S_IXOTH #endif - ); + )); } return retval; } diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index ff0b179..d2cad39 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -921,7 +921,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( } } - return cmSystemTools::RemoveADirectory(directoryPath); + return static_cast(cmSystemTools::RemoveADirectory(directoryPath)); } cmDuration cmCTestScriptHandler::GetRemainingTimeAllowed() diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 742e78a..db5cb9c 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1881,7 +1881,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed() std::string dirName = this->CTest->GetBinaryDir() + "/Testing/Temporary"; cmsys::Directory directory; - if (directory.Load(dirName) == 0) { + if (!directory.Load(dirName)) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of " << dirName << std::endl); return; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 0dfd1bd..643b43f 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -2842,9 +2841,10 @@ int cmCTest::ExecuteTests() cmCTestLog(this, OUTPUT, "Internal ctest changing into directory: " << workDir << std::endl); - if (cmSystemTools::ChangeDirectory(workDir) != 0) { + cmsys::Status status = cmSystemTools::ChangeDirectory(workDir); + if (!status) { auto msg = "Failed to change working directory to \"" + workDir + - "\" : " + std::strerror(errno) + "\n"; + "\" : " + status.GetString() + "\n"; cmCTestLog(this, ERROR_MESSAGE, msg); return 1; } diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 62bc526..f99592c 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -654,10 +654,10 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, if (argP1 != newArgs.end() && argP2 != newArgs.end() && this->IsKeyword(keyIS_NEWER_THAN, *argP1)) { int fileIsNewer = 0; - bool success = cmSystemTools::FileTimeCompare( + cmsys::Status ftcStatus = cmSystemTools::FileTimeCompare( arg->GetValue(), (argP2)->GetValue(), &fileIsNewer); this->HandleBinaryOp( - (!success || fileIsNewer == 1 || fileIsNewer == 0), reducible, arg, + (!ftcStatus || fileIsNewer == 1 || fileIsNewer == 0), reducible, arg, newArgs, argP1, argP2); } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index a06ed48..26bdedf 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2956,9 +2956,12 @@ bool HandleCreateLinkCommand(std::vector const& args, // Check if copy-on-error is enabled in the arguments. if (!completed && arguments.CopyOnError) { - completed = cmsys::SystemTools::CopyFileAlways(fileName, newFileName); - if (!completed) { - result = "Copy failed: " + cmSystemTools::GetLastSystemError(); + cmsys::Status copied = + cmsys::SystemTools::CopyFileAlways(fileName, newFileName); + if (copied) { + completed = true; + } else { + result = "Copy failed: " + copied.GetString(); } } diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 6e88e26..568926e 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -116,7 +116,7 @@ bool cmQtAutoGenerator::MakeParentDirectory(std::string const& filename) bool success = true; std::string const dirName = cmSystemTools::GetFilenamePath(filename); if (!dirName.empty()) { - success = cmSystemTools::MakeDirectory(dirName); + success = static_cast(cmSystemTools::MakeDirectory(dirName)); } return success; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 3a438fd..a2a406c 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1016,7 +1016,7 @@ cmSystemTools::CopyResult cmSystemTools::CopySingleFile( } mode_t perm = 0; - bool perms = SystemTools::GetPermissions(oldname, perm); + cmsys::Status perms = SystemTools::GetPermissions(oldname, perm); // If files are the same do not copy if (SystemTools::SameFile(oldname, newname)) { @@ -3130,7 +3130,7 @@ bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) } return false; #else - return cmSystemTools::RemoveADirectory(dir); + return static_cast(cmSystemTools::RemoveADirectory(dir)); #endif } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 5620899..99f20e0 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -12,6 +12,7 @@ #include #include "cmsys/Process.h" +#include "cmsys/Status.hxx" // IWYU pragma: export #include "cmsys/SystemTools.hxx" // IWYU pragma: export #include "cmCryptoHash.h" diff --git a/Source/cmWorkingDirectory.cxx b/Source/cmWorkingDirectory.cxx index 5700b1c..12fae12 100644 --- a/Source/cmWorkingDirectory.cxx +++ b/Source/cmWorkingDirectory.cxx @@ -19,7 +19,7 @@ cmWorkingDirectory::~cmWorkingDirectory() bool cmWorkingDirectory::SetDirectory(std::string const& newdir) { - if (cmSystemTools::ChangeDirectory(newdir) == 0) { + if (cmSystemTools::ChangeDirectory(newdir)) { this->ResultCode = 0; return true; } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 9ba4b93..a47eccd 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1635,7 +1635,7 @@ bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link) cmSystemTools::RemoveFile(link); } #if defined(_WIN32) && !defined(__CYGWIN__) - return cmSystemTools::CopyFileAlways(file, link); + return static_cast(cmSystemTools::CopyFileAlways(file, link)); #else std::string linktext = cmSystemTools::GetFilenameName(file); return cmSystemTools::CreateSymlink(linktext, link); diff --git a/bootstrap b/bootstrap index 768750d..2a81ef2 100755 --- a/bootstrap +++ b/bootstrap @@ -525,6 +525,7 @@ KWSYS_CXX_SOURCES="\ FStream \ Glob \ RegularExpression \ + Status \ SystemTools" KWSYS_FILES="\ @@ -535,6 +536,7 @@ KWSYS_FILES="\ Glob.hxx \ Process.h \ RegularExpression.hxx \ + Status.hxx \ String.h \ String.hxx \ System.h \ -- cgit v0.12 From 3ef5dab010aef5ebab2022021989cb80718d00fc Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 12:20:00 -0400 Subject: cmSystemTools: Simplify using KWSys Status --- Source/cmSystemTools.cxx | 57 ++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a2a406c..2b3266d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -153,27 +153,6 @@ static int cm_archive_read_open_file(struct archive* a, const char* file, # define environ (*_NSGetEnviron()) #endif -namespace { -void ReportError(std::string* err) -{ - if (!err) { - return; - } -#ifdef _WIN32 - LPSTR message = NULL; - DWORD size = FormatMessageA( - FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPSTR)&message, 0, NULL); - *err = std::string(message, size); - LocalFree(message); -#else - *err = strerror(errno); -#endif -} -} - bool cmSystemTools::s_RunCommandHideConsole = false; bool cmSystemTools::s_DisableRunCommandOutput = false; bool cmSystemTools::s_ErrorOccured = false; @@ -1023,16 +1002,24 @@ cmSystemTools::CopyResult cmSystemTools::CopySingleFile( return CopyResult::Success; } - if (!cmsys::SystemTools::CloneFileContent(oldname, newname)) { + cmsys::Status status; + status = cmsys::SystemTools::CloneFileContent(oldname, newname); + if (!status) { // if cloning did not succeed, fall back to blockwise copy - if (!cmsys::SystemTools::CopyFileContentBlockwise(oldname, newname)) { - ReportError(err); - return CopyResult::Failure; + status = cmsys::SystemTools::CopyFileContentBlockwise(oldname, newname); + } + if (!status) { + if (err) { + *err = status.GetString(); } + return CopyResult::Failure; } if (perms) { - if (!SystemTools::SetPermissions(newname, perm)) { - ReportError(err); + status = SystemTools::SetPermissions(newname, perm); + if (!status) { + if (err) { + *err = status.GetString(); + } return CopyResult::Failure; } } @@ -1090,7 +1077,9 @@ cmSystemTools::RenameResult cmSystemTools::RenameFile( if (replace == Replace::No && move_last_error == ERROR_ALREADY_EXISTS) { return RenameResult::NoReplace; } - ReportError(err); + if (err) { + *err = cmsys::Status::Windows(move_last_error).GetString(); + } return RenameResult::Failure; } @@ -1121,7 +1110,9 @@ cmSystemTools::RenameResult cmSystemTools::RenameFile( if (replace == Replace::No && GetLastError() == ERROR_ALREADY_EXISTS) { return RenameResult::NoReplace; } - ReportError(err); + if (err) { + *err = cmsys::Status::Windows_GetLastError().GetString(); + } return RenameResult::Failure; #else // On UNIX we have OS-provided calls to create 'newname' atomically. @@ -1132,13 +1123,17 @@ cmSystemTools::RenameResult cmSystemTools::RenameFile( if (errno == EEXIST) { return RenameResult::NoReplace; } - ReportError(err); + if (err) { + *err = cmsys::Status::POSIX_errno().GetString(); + } return RenameResult::Failure; } if (rename(oldname.c_str(), newname.c_str()) == 0) { return RenameResult::Success; } - ReportError(err); + if (err) { + *err = cmsys::Status::POSIX_errno().GetString(); + } return RenameResult::Failure; #endif } -- cgit v0.12 From 44bcec240bed6980fdc6f38e7238371d7d3c1f1b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 13:58:47 -0400 Subject: ci: factor out Intel Compiler common configure script Share common content between the intelclassic and inteloneapi variants. --- .gitlab/ci/configure_intelclassic_makefiles.cmake | 2 +- .gitlab/ci/configure_intelcompiler_common.cmake | 1 + .gitlab/ci/configure_inteloneapi_makefiles.cmake | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .gitlab/ci/configure_intelcompiler_common.cmake diff --git a/.gitlab/ci/configure_intelclassic_makefiles.cmake b/.gitlab/ci/configure_intelclassic_makefiles.cmake index 20863a2..469b825 100644 --- a/.gitlab/ci/configure_intelclassic_makefiles.cmake +++ b/.gitlab/ci/configure_intelclassic_makefiles.cmake @@ -1 +1 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_intelcompiler_common.cmake") diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake new file mode 100644 index 0000000..20863a2 --- /dev/null +++ b/.gitlab/ci/configure_intelcompiler_common.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_inteloneapi_makefiles.cmake b/.gitlab/ci/configure_inteloneapi_makefiles.cmake index 20863a2..469b825 100644 --- a/.gitlab/ci/configure_inteloneapi_makefiles.cmake +++ b/.gitlab/ci/configure_inteloneapi_makefiles.cmake @@ -1 +1 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_intelcompiler_common.cmake") -- cgit v0.12 From 116edb5c04790e5d9127b5cfb51943eebd5d33d8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 13:33:42 -0400 Subject: Find{BLAS,LAPACK}: Revert bad refactoring of internal CHECK_*_LIBRARIES Refactoring in commit 4c74c86f40 (FindBLAS/LAPACK: Add support for the Fujitsu SSL2 library, 2021-01-27) was done in order to support calling `find_library` on the dependencies as well as the candidate libraries. However, it broke a few things: * Intel MKL's BLAS/LAPACK are no longer found. We specify their dependencies using `-l...` flags, so we should not try to use `find_library` for them. * The dependencies are repeated because we accumulate them in the `find_library` search loop and then append them at the end too. Revert the incorrect part of the refactoring. Retain the flags part needed for the Fujitsu vendor. Fixes: #22056 --- Modules/FindBLAS.cmake | 16 +++++++++------- Modules/FindLAPACK.cmake | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 510f47d..fafbc0f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -236,23 +236,25 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add endif() list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - foreach(_library ${_list} ${_threadlibs}) + foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) set(${LIBRARIES} ${${LIBRARIES}} "${_library}") else() - string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") - set(_combined_name ${_combined_name}_${_lib_var}) + set(_combined_name ${_combined_name}_${_library}) + if(NOT "${_threadlibs}" STREQUAL "") + set(_combined_name ${_combined_name}_threadlibs) + endif() if(_libraries_work) - find_library(${_prefix}_${_lib_var}_LIBRARY + find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() endforeach() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index a5b16ca..74e1c5d 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -218,23 +218,25 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endif() list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") - foreach(_library ${_list} ${_threadlibs}) + foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) set(${LIBRARIES} ${${LIBRARIES}} "${_library}") else() - string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") - set(_combined_name ${_combined_name}_${_lib_var}) + set(_combined_name ${_combined_name}_${_library}) + if(NOT "${_threadlibs}" STREQUAL "") + set(_combined_name ${_combined_name}_threadlibs) + endif() if(_libraries_work) - find_library(${_prefix}_${_lib_var}_LIBRARY + find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_lib_var}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) + mark_as_advanced(${_prefix}_${_library}_LIBRARY) + set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() endforeach() -- cgit v0.12 From e4649d1d159de9c1a6f4833d6f9a5a44e5c4781b Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 13:53:03 -0400 Subject: Find{BLAS,LAPACK}: Add test case covering Intel MKL --- .gitlab/ci/configure_debian10_aarch64_ninja.cmake | 4 ++-- .gitlab/ci/configure_debian10_ninja.cmake | 4 ++-- .gitlab/ci/configure_fedora33_makefiles.cmake | 4 ++-- .gitlab/ci/configure_intelcompiler_common.cmake | 3 +++ Tests/FindBLAS/CMakeLists.txt | 22 ++++++++++++---------- Tests/FindBLAS/Test/CMakeLists.txt | 6 ++++++ Tests/FindLAPACK/CMakeLists.txt | 22 ++++++++++++---------- Tests/FindLAPACK/Test/CMakeLists.txt | 6 ++++++ 8 files changed, 45 insertions(+), 26 deletions(-) diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake index 1ad3ac4..f665f7d 100644 --- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake +++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake @@ -1,5 +1,5 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") -set(CMake_TEST_FindBLAS "ON" CACHE BOOL "") +set(CMake_TEST_FindBLAS "All" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -23,7 +23,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "") set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") -set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "") +set(CMake_TEST_FindLAPACK "All" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake index d925387..9de3013 100644 --- a/.gitlab/ci/configure_debian10_ninja.cmake +++ b/.gitlab/ci/configure_debian10_ninja.cmake @@ -1,5 +1,5 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") -set(CMake_TEST_FindBLAS "ON" CACHE BOOL "") +set(CMake_TEST_FindBLAS "All" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -23,7 +23,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "") set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") -set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "") +set(CMake_TEST_FindLAPACK "All" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora33_makefiles.cmake b/.gitlab/ci/configure_fedora33_makefiles.cmake index 882ffcd..4143134 100644 --- a/.gitlab/ci/configure_fedora33_makefiles.cmake +++ b/.gitlab/ci/configure_fedora33_makefiles.cmake @@ -1,5 +1,5 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") -set(CMake_TEST_FindBLAS "ON" CACHE BOOL "") +set(CMake_TEST_FindBLAS "All" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -23,7 +23,7 @@ set(CMake_TEST_FindIconv "ON" CACHE BOOL "") set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") -set(CMake_TEST_FindLAPACK "ON" CACHE BOOL "") +set(CMake_TEST_FindLAPACK "All" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake index 20863a2..be3d15b 100644 --- a/.gitlab/ci/configure_intelcompiler_common.cmake +++ b/.gitlab/ci/configure_intelcompiler_common.cmake @@ -1 +1,4 @@ +set(CMake_TEST_FindBLAS "Intel10_64lp" CACHE STRING "") +set(CMake_TEST_FindLAPACK "Intel10_64lp" CACHE STRING "") + include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/Tests/FindBLAS/CMakeLists.txt b/Tests/FindBLAS/CMakeLists.txt index 667195d..47ec568 100644 --- a/Tests/FindBLAS/CMakeLists.txt +++ b/Tests/FindBLAS/CMakeLists.txt @@ -1,10 +1,12 @@ -add_test(NAME FindBLAS.Test COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" - "${CMake_BINARY_DIR}/Tests/FindBLAS/Test" - ${build_generator_args} - --build-project TestFindBLAS - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) +foreach(vendor IN LISTS CMake_TEST_FindBLAS) + add_test(NAME FindBLAS.Test_${vendor} COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" + "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${vendor}" + ${build_generator_args} + --build-project TestFindBLAS + --build-options ${build_options} -DBLA_VENDOR=${vendor} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +endforeach() diff --git a/Tests/FindBLAS/Test/CMakeLists.txt b/Tests/FindBLAS/Test/CMakeLists.txt index 59418f3..1bebf8e 100644 --- a/Tests/FindBLAS/Test/CMakeLists.txt +++ b/Tests/FindBLAS/Test/CMakeLists.txt @@ -11,3 +11,9 @@ add_test(NAME test_tgt COMMAND test_tgt) add_executable(test_var main.c) target_link_libraries(test_var PRIVATE ${BLAS_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +if(BLA_VENDOR STREQUAL "Intel10_64lp") + if(NOT BLAS_LIBRARIES MATCHES "^[^;]*mkl_intel_lp64") + message(FATAL_ERROR "BLAS_LIBRARIES does not start in mkl_intel_lp64:\n ${BLAS_LIBRARIES}") + endif() +endif() diff --git a/Tests/FindLAPACK/CMakeLists.txt b/Tests/FindLAPACK/CMakeLists.txt index 2081d59..5e2ea7a 100644 --- a/Tests/FindLAPACK/CMakeLists.txt +++ b/Tests/FindLAPACK/CMakeLists.txt @@ -1,10 +1,12 @@ -add_test(NAME FindLAPACK.Test COMMAND - ${CMAKE_CTEST_COMMAND} -C $ - --build-and-test - "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" - "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test" - ${build_generator_args} - --build-project TestFindLAPACK - --build-options ${build_options} - --test-command ${CMAKE_CTEST_COMMAND} -V -C $ - ) +foreach(vendor IN LISTS CMake_TEST_FindLAPACK) + add_test(NAME FindLAPACK.Test_${vendor} COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" + "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${vendor}" + ${build_generator_args} + --build-project TestFindLAPACK + --build-options ${build_options} -DBLA_VENDOR=${vendor} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +endforeach() diff --git a/Tests/FindLAPACK/Test/CMakeLists.txt b/Tests/FindLAPACK/Test/CMakeLists.txt index 8afa36a..67fb9bd 100644 --- a/Tests/FindLAPACK/Test/CMakeLists.txt +++ b/Tests/FindLAPACK/Test/CMakeLists.txt @@ -11,3 +11,9 @@ add_test(NAME test_tgt COMMAND test_tgt) add_executable(test_var main.c) target_link_libraries(test_var PRIVATE ${LAPACK_LIBRARIES}) add_test(NAME test_var COMMAND test_var) + +if(BLA_VENDOR STREQUAL "Intel10_64lp") + if(NOT LAPACK_LIBRARIES MATCHES "^[^;]*mkl_intel_lp64") + message(FATAL_ERROR "LAPACK_LIBRARIES does not start in mkl_intel_lp64:\n ${LAPACK_LIBRARIES}") + endif() +endif() -- cgit v0.12 From d248401d12a4766dad7ddd69ee3f2947960f6f5f Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:11:39 -0400 Subject: Find{BLAS,LAPACK}: Simplify appending to list of libraries --- Modules/FindBLAS.cmake | 6 +++--- Modules/FindLAPACK.cmake | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index fafbc0f..84d7074 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -239,7 +239,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_threadlibs}" STREQUAL "") @@ -253,7 +253,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() @@ -279,7 +279,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add if("${_list}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - set(${LIBRARIES} ${${LIBRARIES}} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_threadlibs}) endif() else() set(${LIBRARIES} FALSE) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 74e1c5d..ea49629 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -221,7 +221,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - set(${LIBRARIES} ${${LIBRARIES}} "${_library}") + list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_threadlibs}" STREQUAL "") @@ -235,7 +235,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() @@ -262,7 +262,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a if("${_list}${_blas}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_blas} ${_threadlibs}) endif() else() set(${LIBRARIES} FALSE) -- cgit v0.12 From a5a6ac7033f107626e76eb09ccd86bf49ccdbecd Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:12:33 -0400 Subject: Find{BLAS,LAPACK}: Clarify name of internal argument for dependencies --- Modules/FindBLAS.cmake | 10 +++++----- Modules/FindLAPACK.cmake | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 84d7074..a61d71f 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -208,7 +208,7 @@ endif() # TODO: move this stuff to a separate module -macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs) +macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -242,8 +242,8 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_threadlibs}" STREQUAL "") - set(_combined_name ${_combined_name}_threadlibs) + if(NOT "${_deps}" STREQUAL "") + set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) find_library(${_prefix}_${_library}_LIBRARY @@ -265,7 +265,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threadlibs}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -279,7 +279,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _add if("${_list}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_deps}) endif() else() set(${LIBRARIES} FALSE) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index ea49629..239a438 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -190,7 +190,7 @@ endmacro() # TODO: move this stuff to a separate module -macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _addlibdir _subdirs _blas) +macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) # This macro checks for the existence of the combination of fortran libraries # given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library @@ -224,8 +224,8 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a list(APPEND ${LIBRARIES} "${_library}") else() set(_combined_name ${_combined_name}_${_library}) - if(NOT "${_threadlibs}" STREQUAL "") - set(_combined_name ${_combined_name}_threadlibs) + if(NOT "${_deps}" STREQUAL "") + set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) find_library(${_prefix}_${_library}_LIBRARY @@ -248,7 +248,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threadlibs}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -262,7 +262,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _threadlibs _a if("${_list}${_blas}" STREQUAL "") set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_blas} ${_threadlibs}) + list(APPEND ${LIBRARIES} ${_blas} ${_deps}) endif() else() set(${LIBRARIES} FALSE) -- cgit v0.12 From a57c4eef76d623078fe7ff718951a71da000a499 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:14:46 -0400 Subject: Find{BLAS,LAPACK}: Convert internal CHECK_*_LIBRARIES to functions --- Modules/FindBLAS.cmake | 37 ++++++++++++++++--------------------- Modules/FindLAPACK.cmake | 42 ++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 47 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index a61d71f..0ad5d8c 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -208,22 +208,16 @@ endif() # TODO: move this stuff to a separate module -macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) - # This macro checks for the existence of the combination of fortran libraries - # given by _list. If the combination is found, this macro checks (using the - # Check_Fortran_Function_Exists macro) whether can link against that library - # combination using the name of a routine given by _name using the linker - # flags given by _flags. If the combination of libraries is found and passes - # the link test, LIBRARIES is set to the list of complete library paths that - # have been found. Otherwise, LIBRARIES is set to FALSE. - - # N.B. _prefix is the prefix applied to the names of all cached variables that - # are generated internally and marked advanced by this macro. - # _addlibdir is a list of additional search paths. _subdirs is a list of path - # suffixes to be used by find_library(). +function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) + # This function checks for the existence of the combination of libraries + # given by _list. If the combination is found, this checks whether can link + # against that library combination using the name of a routine given by _name + # using the linker flags given by _flags. If the combination of libraries is + # found and passes the link test, ${LIBRARIES} is set to the list of complete + # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE. set(_libraries_work TRUE) - set(${LIBRARIES}) + set(_libraries) set(_combined_name) set(_extaddlibdir "${_addlibdir}") @@ -239,7 +233,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - list(APPEND ${LIBRARIES} "${_library}") + list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_deps}" STREQUAL "") @@ -253,7 +247,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() @@ -265,7 +259,7 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_deps}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -277,14 +271,15 @@ macro(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir if(_libraries_work) if("${_list}" STREQUAL "") - set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_deps}) + list(APPEND _libraries ${_deps}) endif() else() - set(${LIBRARIES} FALSE) + set(_libraries FALSE) endif() -endmacro() + set(${LIBRARIES} "${_libraries}" PARENT_SCOPE) +endfunction() set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 239a438..2c74c6e 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -190,22 +190,16 @@ endmacro() # TODO: move this stuff to a separate module -macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) - # This macro checks for the existence of the combination of fortran libraries - # given by _list. If the combination is found, this macro checks (using the - # Check_Fortran_Function_Exists macro) whether can link against that library - # combination using the name of a routine given by _name using the linker - # flags given by _flags. If the combination of libraries is found and passes - # the link test, LIBRARIES is set to the list of complete library paths that - # have been found. Otherwise, LIBRARIES is set to FALSE. - - # N.B. _prefix is the prefix applied to the names of all cached variables that - # are generated internally and marked advanced by this macro. - # _addlibdir is a list of additional search paths. _subdirs is a list of path - # suffixes to be used by find_library(). +function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) + # This function checks for the existence of the combination of libraries + # given by _list. If the combination is found, this checks whether can link + # against that library combination using the name of a routine given by _name + # using the linker flags given by _flags. If the combination of libraries is + # found and passes the link test, ${LIBRARIES} is set to the list of complete + # library paths that have been found. Otherwise, ${LIBRARIES} is set to FALSE. set(_libraries_work TRUE) - set(${LIBRARIES}) + set(_libraries) set(_combined_name) set(_extaddlibdir "${_addlibdir}") @@ -221,7 +215,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd foreach(_library ${_list}) if(_library MATCHES "^-Wl,--(start|end)-group$") # Respect linker flags like --start/end-group (required by MKL) - list(APPEND ${LIBRARIES} "${_library}") + list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) if(NOT "${_deps}" STREQUAL "") @@ -235,12 +229,11 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd PATH_SUFFIXES ${_subdirs} ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND ${LIBRARIES} ${${_prefix}_${_library}_LIBRARY}) + list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) endif() endif() endforeach() - unset(_library) foreach(_flag ${_flags}) string(REGEX REPLACE "[^A-Za-z0-9]" "_" _flag_var "${_flag}") @@ -248,7 +241,7 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd endforeach() if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_deps}) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_blas} ${_deps}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -260,18 +253,15 @@ macro(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibd if(_libraries_work) if("${_list}${_blas}" STREQUAL "") - set(${LIBRARIES} "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") + set(_libraries "${LIBRARIES}-PLACEHOLDER-FOR-EMPTY-LIBRARIES") else() - list(APPEND ${LIBRARIES} ${_blas} ${_deps}) + list(APPEND _libraries ${_blas} ${_deps}) endif() else() - set(${LIBRARIES} FALSE) + set(_libraries FALSE) endif() - - unset(_extaddlibdir) - unset(_libraries_work) - unset(_combined_name) -endmacro() + set(${LIBRARIES} "${_libraries}" PARENT_SCOPE) +endfunction() macro(_lapack_find_dependency dep) set(_lapack_quiet_arg) -- cgit v0.12 From 98ef6632d9f7de15472246ccde76a749be0d37ca Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:18:25 -0400 Subject: Find{BLAS,LAPACK}: Generalize recognition of dependencies as link flags --- Modules/FindBLAS.cmake | 4 ++-- Modules/FindLAPACK.cmake | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 0ad5d8c..61e92c9 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -231,8 +231,8 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - if(_library MATCHES "^-Wl,--(start|end)-group$") - # Respect linker flags like --start/end-group (required by MKL) + if(_library MATCHES "^-") + # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 2c74c6e..11bd411 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -213,8 +213,8 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl list(APPEND _extaddlibdir "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}") foreach(_library ${_list}) - if(_library MATCHES "^-Wl,--(start|end)-group$") - # Respect linker flags like --start/end-group (required by MKL) + if(_library MATCHES "^-") + # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() set(_combined_name ${_combined_name}_${_library}) -- cgit v0.12 From dcd604ee621e191acf9e91faab8e47507184d7e9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Apr 2021 14:46:49 -0400 Subject: Find{BLAS,LAPACK}: Make library variable names more robust --- Modules/FindBLAS.cmake | 11 ++++++----- Modules/FindLAPACK.cmake | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 61e92c9..c23e41b 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -235,20 +235,21 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() - set(_combined_name ${_combined_name}_${_library}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) if(NOT "${_deps}" STREQUAL "") set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY + find_library(${_prefix}_${_lib_var}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) endif() endif() endforeach() diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 11bd411..d89c40d 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -217,20 +217,21 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl # Respect linker flags as-is (required by MKL) list(APPEND _libraries "${_library}") else() - set(_combined_name ${_combined_name}_${_library}) + string(REGEX REPLACE "[^A-Za-z0-9]" "_" _lib_var "${_library}") + set(_combined_name ${_combined_name}_${_lib_var}) if(NOT "${_deps}" STREQUAL "") set(_combined_name ${_combined_name}_deps) endif() if(_libraries_work) - find_library(${_prefix}_${_library}_LIBRARY + find_library(${_prefix}_${_lib_var}_LIBRARY NAMES ${_library} NAMES_PER_DIR PATHS ${_extaddlibdir} PATH_SUFFIXES ${_subdirs} ) - mark_as_advanced(${_prefix}_${_library}_LIBRARY) - list(APPEND _libraries ${${_prefix}_${_library}_LIBRARY}) - set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) + mark_as_advanced(${_prefix}_${_lib_var}_LIBRARY) + list(APPEND _libraries ${${_prefix}_${_lib_var}_LIBRARY}) + set(_libraries_work ${${_prefix}_${_lib_var}_LIBRARY}) endif() endif() endforeach() -- cgit v0.12 From ec78e86cc868ffb39f144dd1c2ae29552413f65d Mon Sep 17 00:00:00 2001 From: Paul Zehner Date: Fri, 9 Apr 2021 19:25:53 +0900 Subject: FujitsuClang: Use GNU-like command-line --- Modules/CMakeDetermineCompilerId.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index d7b7f26..519fe6b 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -223,6 +223,8 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) else() set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") endif() + elseif("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xFujitsuClang") + set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "GNU") else() set(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT "") endif() -- cgit v0.12 From cc0d2004b208d893c20f243ed83391e344589226 Mon Sep 17 00:00:00 2001 From: Paul Zehner Date: Fri, 9 Apr 2021 19:28:08 +0900 Subject: Fujitsu: Fix C90 standard flags Fix typos from commit 3c867cff4a (Fujitsu: Add support for the Fujitsu compiler in Trad mode, 2020-12-22). --- Modules/Compiler/Fujitsu-C.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Modules/Compiler/Fujitsu-C.cmake b/Modules/Compiler/Fujitsu-C.cmake index 0e0f1dc..dd31e43 100644 --- a/Modules/Compiler/Fujitsu-C.cmake +++ b/Modules/Compiler/Fujitsu-C.cmake @@ -4,9 +4,9 @@ include(Compiler/Fujitsu) __compiler_fujitsu(C) if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 4) - set(CMAKE_C89_STANDARD_COMPILE_OPTION -std=c89) - set(CMAKE_C89_EXTENSION_COMPILE_OPTION -std=gnu89) - set(CMAKE_C89_STANDARD__HAS_FULL_SUPPORT ON) + set(CMAKE_C90_STANDARD_COMPILE_OPTION -std=c89) + set(CMAKE_C90_EXTENSION_COMPILE_OPTION -std=gnu89) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION -std=c99) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -std=gnu99) -- cgit v0.12 From 498b916cdd96330baa33bc10667b43cbb78674d4 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 15 Apr 2021 00:04:10 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 8930a5f..14ed182 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210414) +set(CMake_VERSION_PATCH 20210415) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 13838bbb36dbfeb36243d661378732672477ac8a Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Thu, 15 Apr 2021 10:12:15 -0400 Subject: CMAKE_TOOLCHAIN_FILE: Document relative path behavior --- Help/variable/CMAKE_TOOLCHAIN_FILE.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst index 168ee74..423da9c 100644 --- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst +++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst @@ -7,3 +7,6 @@ This variable is specified on the command line when cross-compiling with CMake. It is the path to a file which is read early in the CMake run and which specifies locations for compilers and toolchain utilities, and other target platform and compiler related information. + +Relative paths are allowed and are interpreted first as relative to the +build directory, and if not found, relative to the soruce directory. -- cgit v0.12 From d5c3e4ac326328dd4ca48b12b27b11ea19d87363 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 7 Apr 2021 14:24:14 -0400 Subject: cmake: add support for --toolchain command argument --- Help/manual/OPTIONS_BUILD.txt | 4 ++++ Help/manual/cmake-toolchains.7.rst | 4 ++-- Help/release/dev/cmake-toolchain-command.rst | 5 +++++ Source/cmake.cxx | 14 +++++++++++++ Source/cmake.h | 2 ++ Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 24 +++++++++++++++++++++- .../RunCMake/CommandLine/Toolchain/CMakeLists.txt | 3 +++ .../RunCMake/CommandLine/Toolchain/toolchain.cmake | 2 ++ .../CommandLine/toolchain-no-arg-result.txt | 1 + .../CommandLine/toolchain-no-arg-stderr.txt | 1 + .../toolchain-valid-abs-path-result.txt | 1 + .../toolchain-valid-abs-path-stderr.txt | 1 + .../toolchain-valid-rel-build-path-result.txt | 1 + .../toolchain-valid-rel-build-path-stderr.txt | 1 + .../toolchain-valid-rel-src-path-result.txt | 1 + .../toolchain-valid-rel-src-path-stderr.txt | 1 + 16 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 Help/release/dev/cmake-toolchain-command.rst create mode 100644 Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt create mode 100644 Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake create mode 100644 Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt create mode 100644 Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt diff --git a/Help/manual/OPTIONS_BUILD.txt b/Help/manual/OPTIONS_BUILD.txt index c4f9be8..c4f83f7 100644 --- a/Help/manual/OPTIONS_BUILD.txt +++ b/Help/manual/OPTIONS_BUILD.txt @@ -76,6 +76,10 @@ native build system to choose a compiler or SDK. See the :variable:`CMAKE_GENERATOR_PLATFORM` variable for details. +``--toolchain `` + Specify the cross compiling toolchain file, equivalant to setting + :variable:`CMAKE_TOOLCHAIN_FILE` variable. + ``--install-prefix `` Specify the installation directory, used by the :variable:`CMAKE_INSTALL_PREFIX` variable. Must be an absolute path. diff --git a/Help/manual/cmake-toolchains.7.rst b/Help/manual/cmake-toolchains.7.rst index 1ededee..a941310 100644 --- a/Help/manual/cmake-toolchains.7.rst +++ b/Help/manual/cmake-toolchains.7.rst @@ -96,8 +96,8 @@ Cross Compiling =============== If :manual:`cmake(1)` is invoked with the command line parameter -``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the file will be loaded early to set -values for the compilers. +``--toolchain path/to/file`` or ``-DCMAKE_TOOLCHAIN_FILE=path/to/file``, the +file will be loaded early to set values for the compilers. The :variable:`CMAKE_CROSSCOMPILING` variable is set to true when CMake is cross-compiling. diff --git a/Help/release/dev/cmake-toolchain-command.rst b/Help/release/dev/cmake-toolchain-command.rst new file mode 100644 index 0000000..111ca49 --- /dev/null +++ b/Help/release/dev/cmake-toolchain-command.rst @@ -0,0 +1,5 @@ +cmake-toolchain-command +---------------------------- + +* The :manual:`cmake(1)` command gained the ``--toolchain `` + command line option to specify a toolchain file. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a04338f..9191abd 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -509,6 +509,16 @@ bool cmake::SetCacheArgs(const std::vector& args) return false; }; + auto ToolchainLambda = [&](std::string const& path, cmake* state) -> bool { + const std::string var = "CMAKE_TOOLCHAIN_FILE"; + cmStateEnums::CacheEntryType type = cmStateEnums::FILEPATH; +#ifndef CMAKE_BOOTSTRAP + state->UnprocessedPresetVariables.erase(var); +#endif + state->ProcessCacheArg(var, path, type); + return true; + }; + std::vector arguments = { CommandArgument{ "-D", "-D must be followed with VAR=VALUE.", CommandArgument::Values::One, DefineLambda }, @@ -530,6 +540,8 @@ bool cmake::SetCacheArgs(const std::vector& args) CommandArgument{ "-P", "-P must be followed by a file name.", CommandArgument::Values::One, ScriptLambda }, + CommandArgument{ "--toolchain", "No file specified for --toolchain", + CommandArgument::Values::One, ToolchainLambda }, CommandArgument{ "--install-prefix", "No install directory specified for --install-prefix", CommandArgument::Values::One, PrefixLambda }, @@ -835,6 +847,8 @@ void cmake::SetArgs(const std::vector& args) CommandArgument::Values::One, PlatformLambda }, CommandArgument{ "-T", "No toolset specified for -T", CommandArgument::Values::One, ToolsetLamda }, + CommandArgument{ "--toolchain", "No file specified for --toolchain", + CommandArgument::Values::One, IgnoreAndTrueLambda }, CommandArgument{ "--install-prefix", "No install directory specified for --install-prefix", CommandArgument::Values::One, IgnoreAndTrueLambda }, diff --git a/Source/cmake.h b/Source/cmake.h index ab2ed21..9b29098 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -712,6 +712,8 @@ private: "Specify toolset name if supported by generator." }, \ { "-A ", \ "Specify platform name if supported by generator." }, \ + { "--toolchain ", \ + "Specify toolchain file [CMAKE_TOOLCHAIN_FILE]." }, \ { "--install-prefix ", \ "Specify install directory [CMAKE_INSTALL_PREFIX]." }, \ { "-Wdev", "Enable developer warnings." }, \ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index c497472..bf5a96e 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -61,7 +61,6 @@ run_cmake_command(build-bad-dir run_cmake_command(build-bad-generator ${CMAKE_COMMAND} --build ${RunCMake_SOURCE_DIR}/cache-bad-generator) - run_cmake_command(install-prefix-no-arg ${CMAKE_COMMAND} -B DummyBuildDir --install-prefix) run_cmake_command(install-no-dir @@ -153,6 +152,29 @@ project(ExplicitDirsMissing LANGUAGES NONE) endfunction() run_ExplicitDirs() +function(run_Toolchain) + set(RunCMake_TEST_NO_SOURCE_DIR 1) + set(source_dir ${RunCMake_SOURCE_DIR}/Toolchain) + + run_cmake_with_options(toolchain-no-arg -S ${source_dir} --toolchain=) + run_cmake_with_options(toolchain-valid-abs-path -S ${source_dir} --toolchain "${source_dir}/toolchain.cmake") + run_cmake_with_options(toolchain-valid-rel-src-path -S ${source_dir} --toolchain=toolchain.cmake) + + set(RunCMake_TEST_NO_CLEAN 1) + set(binary_dir ${RunCMake_BINARY_DIR}/Toolchain-build) + set(RunCMake_TEST_BINARY_DIR "${binary_dir}") + file(REMOVE_RECURSE "${binary_dir}") + + # Test that we both search the binary dir for toolchain files, and it takes + # precedence over source dir + file(WRITE ${binary_dir}/toolchain.cmake [=[ +set(CMAKE_SYSTEM_NAME Linux) +set(toolchain_file binary_dir) +]=]) + run_cmake_with_options(toolchain-valid-rel-build-path ${CMAKE_COMMAND} -S ${source_dir} -B ${binary_dir} --toolchain toolchain.cmake) +endfunction() +run_Toolchain() + function(run_BuildDir) # Use a single build tree for a few tests without cleaning. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BuildDir-build) diff --git a/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt b/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt new file mode 100644 index 0000000..80d42b8 --- /dev/null +++ b/Tests/RunCMake/CommandLine/Toolchain/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.20) +project(Toolchain LANGUAGES NONE) +message(FATAL_ERROR "${toolchain_file}") diff --git a/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake b/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake new file mode 100644 index 0000000..719556c --- /dev/null +++ b/Tests/RunCMake/CommandLine/Toolchain/toolchain.cmake @@ -0,0 +1,2 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(toolchain_file source_dir) diff --git a/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt b/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-no-arg-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt new file mode 100644 index 0000000..2fec517 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-no-arg-stderr.txt @@ -0,0 +1 @@ +^CMake Error: No file specified for --toolchain diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt new file mode 100644 index 0000000..21d5db6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-abs-path-stderr.txt @@ -0,0 +1 @@ +^CMake Error.*source_dir diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt new file mode 100644 index 0000000..1980051 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-build-path-stderr.txt @@ -0,0 +1 @@ +^CMake Error.*binary_dir diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt new file mode 100644 index 0000000..21d5db6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/toolchain-valid-rel-src-path-stderr.txt @@ -0,0 +1 @@ +^CMake Error.*source_dir -- cgit v0.12 From d67cc4882d54a18abbd5d01365ce1fc72d702a0e Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Thu, 15 Apr 2021 14:13:57 +0200 Subject: Xcode: Add support of DEPFILE for add_custom_command Issue: #20286 --- Help/command/add_custom_command.rst | 30 +++++++++++++------- .../dev/Xcode-add_custom_command-DEPFILE.rst | 5 ++++ Source/cmCustomCommandGenerator.cxx | 30 +++++++++++++++----- Source/cmCustomCommandGenerator.h | 13 +++++++-- Source/cmGlobalXCodeGenerator.cxx | 33 +++++++++++++++++++--- Source/cmGlobalXCodeGenerator.h | 13 +++++++++ Source/cmTransformDepfile.cxx | 14 +++++++-- Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 3 +- Tests/RunCMake/CMakeLists.txt | 1 + 9 files changed, 115 insertions(+), 27 deletions(-) create mode 100644 Help/release/dev/Xcode-add_custom_command-DEPFILE.rst diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index b6ff0ea..c0ff81a 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -271,32 +271,42 @@ The options are: ``DEPFILE`` .. versionadded:: 3.7 - Specify a ``.d`` depfile for the :generator:`Ninja` generator and - :ref:`Makefile Generators`. The depfile may use "generator expressions" with - the syntax ``$<...>``. See the :manual:`generator-expressions(7) - ` manual for available expressions. - A ``.d`` file holds dependencies usually emitted by the custom - command itself. - Using ``DEPFILE`` with other generators than :generator:`Ninja` or - :ref:`Makefile Generators` is an error. + Specify a ``.d`` depfile for the :generator:`Ninja`, :generator:`Xcode` and + :ref:`Makefile ` generators. The depfile may use + "generator expressions" with the syntax ``$<...>``. See the + :manual:`generator-expressions(7) ` manual + for available expressions. A ``.d`` file holds dependencies usually emitted + by the custom command itself. + + Using ``DEPFILE`` with other generators than :generator:`Ninja`, + :generator:`Xcode` or :ref:`Makefile ` is an error. .. versionadded:: 3.20 Added the support of :ref:`Makefile Generators`. .. versionadded:: 3.21 - Added the support of :manual:`generator expressions `. + Added the support of :generator:`Xcode` generator and + :manual:`generator expressions `. If the ``DEPFILE`` argument is relative, it should be relative to :variable:`CMAKE_CURRENT_BINARY_DIR`, and any relative paths inside the ``DEPFILE`` should also be relative to :variable:`CMAKE_CURRENT_BINARY_DIR` (see policy :policy:`CMP0116`. This policy is always ``NEW`` for - :ref:`Makefile Generators`). + :ref:`Makefile ` and :generator:`Xcode` generators). .. note:: For :ref:`Makefile Generators`, this option cannot be specified at the same time as ``IMPLICIT_DEPENDS`` option. + .. note:: + + For the :generator:`Xcode` generator, this option requires that the + :ref:`Xcode Build System Selection` uses the ``buildsystem=12`` variant + or higher. This is the default when using Xcode 12 or above. + The :variable:`CMAKE_XCODE_BUILD_SYSTEM` variable indicates which variant + of the Xcode build system is used. + Examples: Generating Files ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/release/dev/Xcode-add_custom_command-DEPFILE.rst b/Help/release/dev/Xcode-add_custom_command-DEPFILE.rst new file mode 100644 index 0000000..4c4d48c --- /dev/null +++ b/Help/release/dev/Xcode-add_custom_command-DEPFILE.rst @@ -0,0 +1,5 @@ +Xcode-add_custom_command-DEPFILE +-------------------------------- + +* The :command:`add_custom_command` command gained ``DEPFILE`` support on + :generator:`Xcode` generator. diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 4705443..7659792 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -151,7 +151,9 @@ std::string EvaluateDepfile(std::string const& path, cmCustomCommandGenerator::cmCustomCommandGenerator( cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg, - bool transformDepfile, cm::optional crossConfig) + bool transformDepfile, cm::optional crossConfig, + std::function + computeInternalDepfile) : CC(&cc) , OutputConfig(crossConfig ? *crossConfig : config) , CommandConfig(std::move(config)) @@ -159,7 +161,15 @@ cmCustomCommandGenerator::cmCustomCommandGenerator( , OldStyle(cc.GetEscapeOldStyle()) , MakeVars(cc.GetEscapeAllowMakeVars()) , EmulatorsWithArguments(cc.GetCommandLines().size()) + , ComputeInternalDepfile(std::move(computeInternalDepfile)) { + if (!this->ComputeInternalDepfile) { + this->ComputeInternalDepfile = + [this](const std::string& cfg, const std::string& file) -> std::string { + return this->GetInternalDepfileName(cfg, file); + }; + } + cmGeneratorExpression ge(cc.GetBacktrace()); const cmCustomCommandLines& cmdlines = this->CC->GetCommandLines(); @@ -413,13 +423,9 @@ std::string cmCustomCommandGenerator::GetFullDepfile() const return cmSystemTools::CollapseFullPath(depfile); } -std::string cmCustomCommandGenerator::GetInternalDepfile() const +std::string cmCustomCommandGenerator::GetInternalDepfileName( + const std::string& /*config*/, const std::string& depfile) { - std::string depfile = this->GetFullDepfile(); - if (depfile.empty()) { - return ""; - } - cmCryptoHash hash(cmCryptoHash::AlgoSHA256); std::string extension; switch (*this->LG->GetGlobalGenerator()->DepfileFormat()) { @@ -434,6 +440,16 @@ std::string cmCustomCommandGenerator::GetInternalDepfile() const hash.HashString(depfile), extension); } +std::string cmCustomCommandGenerator::GetInternalDepfile() const +{ + std::string depfile = this->GetFullDepfile(); + if (depfile.empty()) { + return ""; + } + + return this->ComputeInternalDepfile(this->OutputConfig, depfile); +} + const char* cmCustomCommandGenerator::GetComment() const { return this->CC->GetComment(); diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h index 53e5573..e70909a 100644 --- a/Source/cmCustomCommandGenerator.h +++ b/Source/cmCustomCommandGenerator.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include #include #include #include @@ -19,6 +20,8 @@ class cmLocalGenerator; class cmCustomCommandGenerator { + std::string GetInternalDepfileName(const std::string&, const std::string&); + cmCustomCommand const* CC; std::string OutputConfig; std::string CommandConfig; @@ -32,15 +35,19 @@ class cmCustomCommandGenerator std::vector Depends; std::string WorkingDirectory; std::set>> Utilities; + std::function + ComputeInternalDepfile; void FillEmulatorsWithArguments(); std::vector GetCrossCompilingEmulator(unsigned int c) const; const char* GetArgv0Location(unsigned int c) const; public: - cmCustomCommandGenerator(cmCustomCommand const& cc, std::string config, - cmLocalGenerator* lg, bool transformDepfile = true, - cm::optional crossConfig = {}); + cmCustomCommandGenerator( + cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg, + bool transformDepfile = true, cm::optional crossConfig = {}, + std::function + computeInternalDepfile = {}); cmCustomCommandGenerator(const cmCustomCommandGenerator&) = delete; cmCustomCommandGenerator(cmCustomCommandGenerator&&) = default; cmCustomCommandGenerator& operator=(const cmCustomCommandGenerator&) = diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dd1704..dc3d3f2 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -17,6 +17,7 @@ #include "cmsys/RegularExpression.hxx" +#include "cmCMakePath.h" #include "cmComputeLinkInformation.h" #include "cmCryptoHash.h" #include "cmCustomCommand.h" @@ -1864,9 +1865,20 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateRunScriptBuildPhase( std::set allConfigInputs; std::set allConfigOutputs; + cmXCodeObject* buildPhase = + this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase, + cmStrCat(gt->GetName(), ':', sf->GetFullPath())); + + auto depfilesDirectory = cmStrCat( + gt->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/CMakeFiles/d/"); + auto depfilesPrefix = cmStrCat(depfilesDirectory, buildPhase->GetId(), "."); + std::string shellScript = "set -e\n"; for (std::string const& configName : this->CurrentConfigurationTypes) { - cmCustomCommandGenerator ccg(cc, configName, this->CurrentLocalGenerator); + cmCustomCommandGenerator ccg( + cc, configName, this->CurrentLocalGenerator, true, {}, + [&depfilesPrefix](const std::string& config, const std::string&) + -> std::string { return cmStrCat(depfilesPrefix, config, ".d"); }); std::vector realDepends; realDepends.reserve(ccg.GetDepends().size()); for (auto const& d : ccg.GetDepends()) { @@ -1886,9 +1898,22 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateRunScriptBuildPhase( "\"; then :\n", this->ConstructScript(ccg), "fi\n"); } - cmXCodeObject* buildPhase = - this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase, - cmStrCat(gt->GetName(), ':', sf->GetFullPath())); + if (!cc.GetDepfile().empty()) { + buildPhase->AddAttribute( + "dependencyFile", + this->CreateString(cmStrCat(depfilesDirectory, buildPhase->GetId(), + ".$(CONFIGURATION).d"))); + // to avoid spurious errors during first build, create empty dependency + // files + cmSystemTools::MakeDirectory(depfilesDirectory); + for (std::string const& configName : this->CurrentConfigurationTypes) { + auto file = cmStrCat(depfilesPrefix, configName, ".d"); + if (!cmSystemTools::FileExists(file)) { + cmSystemTools::Touch(file, true); + } + } + } + buildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 1ab56e2..2406472 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -14,6 +14,7 @@ #include #include "cmGlobalGenerator.h" +#include "cmTransformDepfile.h" #include "cmXCodeObject.h" class cmCustomCommand; @@ -111,6 +112,18 @@ public: bool ShouldStripResourcePath(cmMakefile*) const override; + /** + * Used to determine if this generator supports DEPFILE option. + */ + bool SupportsCustomCommandDepfile() const override + { + return this->XcodeBuildSystem >= BuildSystem::Twelve; + } + virtual cm::optional DepfileFormat() const override + { + return cmDepfileFormat::GccDepfile; + } + bool SetSystemName(std::string const& s, cmMakefile* mf) override; bool SetGeneratorToolset(std::string const& ts, bool build, cmMakefile* mf) override; diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx index 78aa4b2..b693582 100644 --- a/Source/cmTransformDepfile.cxx +++ b/Source/cmTransformDepfile.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTransformDepfile.h" +#include #include #include #include @@ -13,6 +14,7 @@ #include "cmGccDepfileReader.h" #include "cmGccDepfileReaderTypes.h" +#include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmSystemTools.h" @@ -38,6 +40,14 @@ void WriteGccDepfile(cmsys::ofstream& fout, const cmLocalGenerator& lg, const cmGccDepfileContent& content) { const auto& binDir = lg.GetBinaryDirectory(); + std::function formatPath = + [&lg, &binDir](const std::string& path) -> std::string { + return lg.MaybeConvertToRelativePath(binDir, path); + }; + if (lg.GetGlobalGenerator()->GetName() == "Xcode") { + // full paths must be preserved for Xcode compliance + formatPath = [](const std::string& path) -> std::string { return path; }; + } for (auto const& dep : content) { bool first = true; @@ -46,12 +56,12 @@ void WriteGccDepfile(cmsys::ofstream& fout, const cmLocalGenerator& lg, fout << " \\\n "; } first = false; - WriteFilenameGcc(fout, lg.MaybeConvertToRelativePath(binDir, rule)); + WriteFilenameGcc(fout, formatPath(rule)); } fout << ':'; for (auto const& path : dep.paths) { fout << " \\\n "; - WriteFilenameGcc(fout, lg.MaybeConvertToRelativePath(binDir, path)); + WriteFilenameGcc(fout, formatPath(path)); } fout << '\n'; } diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index 6232634..a6e08da 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -155,7 +155,8 @@ if (RunCMake_GENERATOR MATCHES "Makefiles") run_cmake(CustomCommandDependencies-BadArgs) endif() -if(RunCMake_GENERATOR MATCHES "Make|Ninja") +if(RunCMake_GENERATOR MATCHES "Make|Ninja" OR + (RunCMake_GENERATOR STREQUAL "Xcode" AND CMAKE_XCODE_BUILD_SYSTEM GREATER_EQUAL "12")) unset(run_BuildDepends_skip_step_3) run_BuildDepends(CustomCommandDepfile) set(run_BuildDepends_skip_step_3 1) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 5f23c05..be59a55 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -222,6 +222,7 @@ endif() add_RunCMake_test(BuildDepends -DMSVC_VERSION=${MSVC_VERSION} + -DCMAKE_XCODE_BUILD_SYSTEM=${CMAKE_XCODE_BUILD_SYSTEM} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMake_TEST_BuildDepends_GNU_AS=${CMake_TEST_BuildDepends_GNU_AS} ) -- cgit v0.12 From 7f89053953f81aaa3d0283ba4b8d8b29ce234292 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 15 Apr 2021 12:31:41 -0400 Subject: cmSystemTools: Return KWSys Status from CreateLink and CreateSymlink --- Source/cmFileCommand.cxx | 6 ++++-- Source/cmSystemTools.cxx | 24 ++++++++++++------------ Source/cmSystemTools.h | 12 ++++++------ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 26bdedf..05ebcca 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2949,9 +2949,11 @@ bool HandleCreateLinkCommand(std::vector const& args, // Check if the command requires a symbolic link. if (arguments.Symbolic) { - completed = cmSystemTools::CreateSymlink(fileName, newFileName, &result); + completed = static_cast( + cmSystemTools::CreateSymlink(fileName, newFileName, &result)); } else { - completed = cmSystemTools::CreateLink(fileName, newFileName, &result); + completed = static_cast( + cmSystemTools::CreateLink(fileName, newFileName, &result)); } // Check if copy-on-error is enabled in the arguments. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 2b3266d..5382fac 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3158,9 +3158,9 @@ std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes) return out; } -bool cmSystemTools::CreateSymlink(const std::string& origName, - const std::string& newName, - std::string* errorMessage) +cmsys::Status cmSystemTools::CreateSymlink(std::string const& origName, + std::string const& newName, + std::string* errorMessage) { uv_fs_t req; int flags = 0; @@ -3171,7 +3171,9 @@ bool cmSystemTools::CreateSymlink(const std::string& origName, #endif int err = uv_fs_symlink(nullptr, &req, origName.c_str(), newName.c_str(), flags, nullptr); + cmsys::Status status; if (err) { + status = cmsys::Status::POSIX(-err); std::string e = "failed to create symbolic link '" + newName + "': " + uv_strerror(err); if (errorMessage) { @@ -3179,20 +3181,20 @@ bool cmSystemTools::CreateSymlink(const std::string& origName, } else { cmSystemTools::Error(e); } - return false; } - - return true; + return status; } -bool cmSystemTools::CreateLink(const std::string& origName, - const std::string& newName, - std::string* errorMessage) +cmsys::Status cmSystemTools::CreateLink(std::string const& origName, + std::string const& newName, + std::string* errorMessage) { uv_fs_t req; int err = uv_fs_link(nullptr, &req, origName.c_str(), newName.c_str(), nullptr); + cmsys::Status status; if (err) { + status = cmsys::Status::POSIX(-err); std::string e = "failed to create link '" + newName + "': " + uv_strerror(err); if (errorMessage) { @@ -3200,10 +3202,8 @@ bool cmSystemTools::CreateLink(const std::string& origName, } else { cmSystemTools::Error(e); } - return false; } - - return true; + return status; } cm::string_view cmSystemTools::GetSystemName() diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 99f20e0..0aecf71 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -489,15 +489,15 @@ public: /** Create a symbolic link if the platform supports it. Returns whether creation succeeded. */ - static bool CreateSymlink(const std::string& origName, - const std::string& newName, - std::string* errorMessage = nullptr); + static cmsys::Status CreateSymlink(std::string const& origName, + std::string const& newName, + std::string* errorMessage = nullptr); /** Create a hard link if the platform supports it. Returns whether creation succeeded. */ - static bool CreateLink(const std::string& origName, - const std::string& newName, - std::string* errorMessage = nullptr); + static cmsys::Status CreateLink(std::string const& origName, + std::string const& newName, + std::string* errorMessage = nullptr); /** Get the system name. */ static cm::string_view GetSystemName(); -- cgit v0.12 From 79a2f1e22a4ff95d7d96478d579a7f52b3c289da Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 15 Apr 2021 12:39:57 -0400 Subject: cmcmd: Improve error message from cmake_symlink_{library,executable} --- Source/cmcmd.cxx | 23 +++++++++++++++-------- Source/cmcmd.h | 6 ++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index a47eccd..928435e 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1601,14 +1601,18 @@ int cmcmd::SymlinkLibrary(std::vector const& args) cmSystemTools::ConvertToUnixSlashes(soName); cmSystemTools::ConvertToUnixSlashes(name); if (soName != realName) { - if (!cmcmd::SymlinkInternal(realName, soName)) { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + cmsys::Status status = cmcmd::SymlinkInternal(realName, soName); + if (!status) { + cmSystemTools::Error( + cmStrCat("cmake_symlink_library: System Error: ", status.GetString())); result = 1; } } if (name != soName) { - if (!cmcmd::SymlinkInternal(soName, name)) { - cmSystemTools::ReportLastSystemError("cmake_symlink_library"); + cmsys::Status status = cmcmd::SymlinkInternal(soName, name); + if (!status) { + cmSystemTools::Error( + cmStrCat("cmake_symlink_library: System Error: ", status.GetString())); result = 1; } } @@ -1621,21 +1625,24 @@ int cmcmd::SymlinkExecutable(std::vector const& args) std::string const& realName = args[2]; std::string const& name = args[3]; if (name != realName) { - if (!cmcmd::SymlinkInternal(realName, name)) { - cmSystemTools::ReportLastSystemError("cmake_symlink_executable"); + cmsys::Status status = cmcmd::SymlinkInternal(realName, name); + if (!status) { + cmSystemTools::Error(cmStrCat("cmake_symlink_executable: System Error: ", + status.GetString())); result = 1; } } return result; } -bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link) +cmsys::Status cmcmd::SymlinkInternal(std::string const& file, + std::string const& link) { if (cmSystemTools::FileExists(link) || cmSystemTools::FileIsSymlink(link)) { cmSystemTools::RemoveFile(link); } #if defined(_WIN32) && !defined(__CYGWIN__) - return static_cast(cmSystemTools::CopyFileAlways(file, link)); + return cmSystemTools::CopyFileAlways(file, link); #else std::string linktext = cmSystemTools::GetFilenameName(file); return cmSystemTools::CreateSymlink(linktext, link); diff --git a/Source/cmcmd.h b/Source/cmcmd.h index a2e0b1e..ba78edb 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -8,6 +8,8 @@ #include #include +#include "cmsys/Status.hxx" + #include "cmCryptoHash.h" class cmConsoleBuf; @@ -28,8 +30,8 @@ protected: cmCryptoHash::Algo algo); static int SymlinkLibrary(std::vector const& args); static int SymlinkExecutable(std::vector const& args); - static bool SymlinkInternal(std::string const& file, - std::string const& link); + static cmsys::Status SymlinkInternal(std::string const& file, + std::string const& link); static int ExecuteEchoColor(std::vector const& args); static int ExecuteLinkScript(std::vector const& args); static int WindowsCEEnvironment(const char* version, -- cgit v0.12 From c2d2772f15d08f006c0841d4caf028c41f315ca4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 15 Apr 2021 12:02:16 -0400 Subject: try_compile: Improve error message when a file cannot be removed --- Source/cmCoreTryCompile.cxx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 6672aa6..cb84d1d 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -1015,17 +1015,21 @@ void cmCoreTryCompile::CleanupFiles(std::string const& binDir) // cannot delete them immediately. Try a few times. cmSystemTools::WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry(); - while (!cmSystemTools::RemoveFile(fullPath) && --retry.Count && - cmSystemTools::FileExists(fullPath)) { + cmsys::Status status; + while (!((status = cmSystemTools::RemoveFile(fullPath))) && + --retry.Count && cmSystemTools::FileExists(fullPath)) { cmSystemTools::Delay(retry.Delay); } if (retry.Count == 0) #else - if (!cmSystemTools::RemoveFile(fullPath)) + cmsys::Status status = cmSystemTools::RemoveFile(fullPath); + if (!status) #endif { - std::string m = "Remove failed on file: " + fullPath; - cmSystemTools::ReportLastSystemError(m.c_str()); + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + cmStrCat("The file:\n ", fullPath, + "\ncould not be removed:\n ", status.GetString())); } } } -- cgit v0.12 From e5a098968c3a25df75b82363515795e793a668ae Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 16 Apr 2021 00:01:04 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 14ed182..985d944 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210415) +set(CMake_VERSION_PATCH 20210416) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From ae2c24b0bafd341928fd6e95acc60ece2c45aa0e Mon Sep 17 00:00:00 2001 From: nic-kaczinsky Date: Fri, 16 Apr 2021 06:55:30 +0000 Subject: Tests: Fix warning clang-analyzer-cplusplus.NewDeleteLeaks Fix the warning: `potential leak of memory pointed to by "vp"`. --- Tests/CompileFeatures/cxx_contextual_conversions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/CompileFeatures/cxx_contextual_conversions.cpp b/Tests/CompileFeatures/cxx_contextual_conversions.cpp index 247f13f..fe8d5c0 100644 --- a/Tests/CompileFeatures/cxx_contextual_conversions.cpp +++ b/Tests/CompileFeatures/cxx_contextual_conversions.cpp @@ -1,4 +1,3 @@ - #define assert(E) \ if (!(E)) \ return 1; @@ -38,6 +37,7 @@ int someFunc() } int* vp = new int[i]; + delete[] vp; return 0; } -- cgit v0.12 From 94fb2516f00fe345326f6a82dc41f2236c481ed3 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 17 Apr 2021 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 985d944..49e9326 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210416) +set(CMake_VERSION_PATCH 20210417) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 253aff6c94401f468ea8f9c953d325c5a8c72eb0 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 16 Apr 2021 14:39:23 +0200 Subject: Xcode: Add support of DEPFILE for add_custom_command, part 2 This MR extend the support of 'DEPFILE' to buildsystem version 1. Issue: #20286 --- Help/command/add_custom_command.rst | 8 -------- Source/cmCustomCommandGenerator.cxx | 4 ++++ Source/cmGlobalXCodeGenerator.cxx | 28 ++++++++++++++++++++++++-- Source/cmGlobalXCodeGenerator.h | 9 ++++----- Source/cmTransformDepfile.cxx | 20 +++++++++++++++--- Source/cmTransformDepfile.h | 1 + Source/cmcmd.cxx | 2 ++ Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 3 +-- Tests/RunCMake/CMakeLists.txt | 1 - 9 files changed, 55 insertions(+), 21 deletions(-) diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index c0ff81a..569f1e8 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -299,14 +299,6 @@ The options are: For :ref:`Makefile Generators`, this option cannot be specified at the same time as ``IMPLICIT_DEPENDS`` option. - .. note:: - - For the :generator:`Xcode` generator, this option requires that the - :ref:`Xcode Build System Selection` uses the ``buildsystem=12`` variant - or higher. This is the default when using Xcode 12 or above. - The :variable:`CMAKE_XCODE_BUILD_SYSTEM` variable indicates which variant - of the Xcode build system is used. - Examples: Generating Files ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 7659792..1054beb 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -226,6 +226,9 @@ cmCustomCommandGenerator::cmCustomCommandGenerator( case cmDepfileFormat::VsTlog: argv.emplace_back("vstlog"); break; + case cmDepfileFormat::MakeDepfile: + argv.emplace_back("makedepfile"); + break; } argv.push_back(this->LG->GetSourceDirectory()); argv.push_back(this->LG->GetCurrentSourceDirectory()); @@ -430,6 +433,7 @@ std::string cmCustomCommandGenerator::GetInternalDepfileName( std::string extension; switch (*this->LG->GetGlobalGenerator()->DepfileFormat()) { case cmDepfileFormat::GccDepfile: + case cmDepfileFormat::MakeDepfile: extension = ".d"; break; case cmDepfileFormat::VsTlog: diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index dc3d3f2..92dd555 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2213,9 +2213,33 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile( } } makefileStream << "\n\n"; + + auto depfilesDirectory = + cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), + "/CMakeFiles/d/"); + for (auto const& command : commands) { - cmCustomCommandGenerator ccg(command, configName, - this->CurrentLocalGenerator); + cmCustomCommandGenerator ccg( + command, configName, this->CurrentLocalGenerator, true, {}, + [this, &depfilesDirectory](const std::string& config, + const std::string& file) -> std::string { + return cmStrCat( + depfilesDirectory, + this->GetObjectId(cmXCodeObject::PBXShellScriptBuildPhase, file), + ".", config, ".d"); + }); + + auto depfile = ccg.GetInternalDepfile(); + if (!depfile.empty()) { + makefileStream << "include " + << cmSystemTools::ConvertToOutputPath(depfile) << "\n\n"; + + cmSystemTools::MakeDirectory(depfilesDirectory); + if (!cmSystemTools::FileExists(depfile)) { + cmSystemTools::Touch(depfile, true); + } + } + std::vector realDepends; realDepends.reserve(ccg.GetDepends().size()); for (auto const& d : ccg.GetDepends()) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 2406472..ef61601 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -115,13 +115,12 @@ public: /** * Used to determine if this generator supports DEPFILE option. */ - bool SupportsCustomCommandDepfile() const override - { - return this->XcodeBuildSystem >= BuildSystem::Twelve; - } + bool SupportsCustomCommandDepfile() const override { return true; } virtual cm::optional DepfileFormat() const override { - return cmDepfileFormat::GccDepfile; + return this->XcodeBuildSystem == BuildSystem::One + ? cmDepfileFormat::MakeDepfile + : cmDepfileFormat::GccDepfile; } bool SetSystemName(std::string const& s, cmMakefile* mf) override; diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx index b693582..6e0366c 100644 --- a/Source/cmTransformDepfile.cxx +++ b/Source/cmTransformDepfile.cxx @@ -36,8 +36,9 @@ void WriteFilenameGcc(cmsys::ofstream& fout, const std::string& filename) } } -void WriteGccDepfile(cmsys::ofstream& fout, const cmLocalGenerator& lg, - const cmGccDepfileContent& content) +void WriteDepfile(cmDepfileFormat format, cmsys::ofstream& fout, + const cmLocalGenerator& lg, + const cmGccDepfileContent& content) { const auto& binDir = lg.GetBinaryDirectory(); std::function formatPath = @@ -65,6 +66,18 @@ void WriteGccDepfile(cmsys::ofstream& fout, const cmLocalGenerator& lg, } fout << '\n'; } + + if (format == cmDepfileFormat::MakeDepfile) { + // In this case, phony targets must be added for all dependencies + fout << "\n"; + for (auto const& dep : content) { + for (auto const& path : dep.paths) { + fout << "\n"; + WriteFilenameGcc(fout, formatPath(path)); + fout << ":\n"; + } + } + } } // tlog format : always windows paths on Windows regardless the generator @@ -122,7 +135,8 @@ bool cmTransformDepfile(cmDepfileFormat format, const cmLocalGenerator& lg, } switch (format) { case cmDepfileFormat::GccDepfile: - WriteGccDepfile(fout, lg, content); + case cmDepfileFormat::MakeDepfile: + WriteDepfile(format, fout, lg, content); break; case cmDepfileFormat::VsTlog: WriteVsTlog(fout, lg, content); diff --git a/Source/cmTransformDepfile.h b/Source/cmTransformDepfile.h index c43a45f..c31e4ab 100644 --- a/Source/cmTransformDepfile.h +++ b/Source/cmTransformDepfile.h @@ -8,6 +8,7 @@ enum class cmDepfileFormat { GccDepfile, VsTlog, + MakeDepfile }; class cmLocalGenerator; diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 928435e..2c2ae4d 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -1527,6 +1527,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args, format = cmDepfileFormat::GccDepfile; } else if (args[3] == "vstlog") { format = cmDepfileFormat::VsTlog; + } else if (args[3] == "makedepfile") { + format = cmDepfileFormat::MakeDepfile; } else { return 1; } diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index a6e08da..72faddb 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -155,8 +155,7 @@ if (RunCMake_GENERATOR MATCHES "Makefiles") run_cmake(CustomCommandDependencies-BadArgs) endif() -if(RunCMake_GENERATOR MATCHES "Make|Ninja" OR - (RunCMake_GENERATOR STREQUAL "Xcode" AND CMAKE_XCODE_BUILD_SYSTEM GREATER_EQUAL "12")) +if(RunCMake_GENERATOR MATCHES "Make|Ninja|Xcode") unset(run_BuildDepends_skip_step_3) run_BuildDepends(CustomCommandDepfile) set(run_BuildDepends_skip_step_3 1) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index be59a55..5f23c05 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -222,7 +222,6 @@ endif() add_RunCMake_test(BuildDepends -DMSVC_VERSION=${MSVC_VERSION} - -DCMAKE_XCODE_BUILD_SYSTEM=${CMAKE_XCODE_BUILD_SYSTEM} -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMake_TEST_BuildDepends_GNU_AS=${CMake_TEST_BuildDepends_GNU_AS} ) -- cgit v0.12 From 388c347a4bfc99bace477f83af4faa949f7f0951 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 17 Apr 2021 22:53:28 +0200 Subject: Help: Fix typo in CMAKE_TOOLCHAIN_FILE docs --- Help/variable/CMAKE_TOOLCHAIN_FILE.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst index 423da9c..e462c5e 100644 --- a/Help/variable/CMAKE_TOOLCHAIN_FILE.rst +++ b/Help/variable/CMAKE_TOOLCHAIN_FILE.rst @@ -9,4 +9,4 @@ specifies locations for compilers and toolchain utilities, and other target platform and compiler related information. Relative paths are allowed and are interpreted first as relative to the -build directory, and if not found, relative to the soruce directory. +build directory, and if not found, relative to the source directory. -- cgit v0.12 From d46170970b0626cda9a420189bd0d904c25a7e93 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 18 Apr 2021 00:01:04 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 49e9326..9cf8972 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210417) +set(CMake_VERSION_PATCH 20210418) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 42bede8385c1a9d729498d50cbe2aaf2602213fd Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 19 Apr 2021 00:01:15 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9cf8972..2b11de7 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210418) +set(CMake_VERSION_PATCH 20210419) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From d98342d868a51f2c777f0424d2ea04f2fb1fd3ca Mon Sep 17 00:00:00 2001 From: KWSys Upstream Date: Mon, 19 Apr 2021 09:26:45 -0400 Subject: KWSys 2021-04-19 (d6139c66) Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit d6139c66c8760552ab6bc4a08401ae8105217469 (master). Upstream Shortlog ----------------- Orgad Shaneh (3): 17f4af9b SystemTools: Use octal base for error messages in permission test f00dd83e SystemTools: Avoid unnecessary assumption of working directory in test case 5b941f33 SystemTools: Adapt permissions test to MSYS --- testSystemTools.cxx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/testSystemTools.cxx b/testSystemTools.cxx index cfa420d..04f66ff 100644 --- a/testSystemTools.cxx +++ b/testSystemTools.cxx @@ -290,15 +290,17 @@ static bool CheckFileOperations() res = false; } + std::cerr << std::oct; // Reset umask -#if defined(_WIN32) && !defined(__CYGWIN__) +#ifdef __MSYS__ + mode_t fullMask = S_IWRITE; +#elif defined(_WIN32) && !defined(__CYGWIN__) // NOTE: Windows doesn't support toggling _S_IREAD. mode_t fullMask = _S_IWRITE; #else // On a normal POSIX platform, we can toggle all permissions. mode_t fullMask = S_IRWXU | S_IRWXG | S_IRWXO; #endif - mode_t orig_umask = umask(fullMask); // Test file permissions without umask mode_t origPerm, thisPerm; @@ -370,6 +372,7 @@ static bool CheckFileOperations() res = false; } + mode_t orig_umask = umask(fullMask); // Test setting file permissions while honoring umask if (!kwsys::SystemTools::SetPermissions(testNewFile, fullMask, true)) { std::cerr << "Problem with SetPermissions (3) for: " << testNewFile @@ -496,6 +499,7 @@ static bool CheckFileOperations() } #endif + std::cerr << std::dec; return res; } @@ -1093,7 +1097,7 @@ static bool CheckCopyFileIfDifferent() ret = false; continue; } - std::string bdata = readFile("file_b"); + std::string bdata = readFile(cptarget); if (diff_test_cases[i].a != bdata) { std::cerr << "Incorrect CopyFileIfDifferent file contents in test case " << i + 1 << "." << std::endl; -- cgit v0.12 From e1896d9c544e4afcac6b3744247964f431571a7b Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Tue, 20 Apr 2021 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 2b11de7..3ba0698 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210419) +set(CMake_VERSION_PATCH 20210420) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 408e6d6185427dc57470f5685e9774e579bd6283 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Apr 2021 11:06:04 -0400 Subject: Utilities: Suppress warnings in third-party code with NVHPC --- Source/CursesDialog/form/CMakeLists.txt | 2 +- Utilities/cmbzip2/CMakeLists.txt | 2 +- Utilities/cmcurl/CMakeLists.txt | 2 +- Utilities/cmexpat/CMakeLists.txt | 2 +- Utilities/cmjsoncpp/CMakeLists.txt | 2 +- Utilities/cmlibarchive/CMakeLists.txt | 2 +- Utilities/cmliblzma/CMakeLists.txt | 2 +- Utilities/cmlibrhash/CMakeLists.txt | 2 +- Utilities/cmlibuv/CMakeLists.txt | 2 +- Utilities/cmnghttp2/CMakeLists.txt | 2 +- Utilities/cmzlib/CMakeLists.txt | 2 +- Utilities/cmzstd/CMakeLists.txt | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index 8f26b9a..9202bc1 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -5,7 +5,7 @@ project(CMAKE_FORM) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmbzip2/CMakeLists.txt b/Utilities/cmbzip2/CMakeLists.txt index 9b53b0f..ff90bb6 100644 --- a/Utilities/cmbzip2/CMakeLists.txt +++ b/Utilities/cmbzip2/CMakeLists.txt @@ -2,7 +2,7 @@ project(bzip2) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 4fb9361..57860a9 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -97,7 +97,7 @@ endif(APPLE) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmexpat/CMakeLists.txt b/Utilities/cmexpat/CMakeLists.txt index b8dc4e8..9048096 100644 --- a/Utilities/cmexpat/CMakeLists.txt +++ b/Utilities/cmexpat/CMakeLists.txt @@ -1,6 +1,6 @@ # Disable warnings to avoid changing 3rd party code. IF(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmjsoncpp/CMakeLists.txt b/Utilities/cmjsoncpp/CMakeLists.txt index 74e9988..029ae86 100644 --- a/Utilities/cmjsoncpp/CMakeLists.txt +++ b/Utilities/cmjsoncpp/CMakeLists.txt @@ -2,7 +2,7 @@ project(JsonCpp CXX) # Disable warnings to avoid changing 3rd party code. if(CMAKE_CXX_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "PathScale") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -woffall") diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 689d98a..79452ff 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -94,7 +94,7 @@ SET(CMAKE_REQUIRED_FLAGS) # Disable warnings to avoid changing 3rd party code. IF(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt index 32a14dc..5dd7035 100644 --- a/Utilities/cmliblzma/CMakeLists.txt +++ b/Utilities/cmliblzma/CMakeLists.txt @@ -148,7 +148,7 @@ INCLUDE_DIRECTORIES( # Disable warnings to avoid changing 3rd party code. IF(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmlibrhash/CMakeLists.txt b/Utilities/cmlibrhash/CMakeLists.txt index 37e2399..1a01165 100644 --- a/Utilities/cmlibrhash/CMakeLists.txt +++ b/Utilities/cmlibrhash/CMakeLists.txt @@ -2,7 +2,7 @@ project(librhash C) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt index f8b47af..a4f0148 100644 --- a/Utilities/cmlibuv/CMakeLists.txt +++ b/Utilities/cmlibuv/CMakeLists.txt @@ -2,7 +2,7 @@ project(libuv C) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmnghttp2/CMakeLists.txt b/Utilities/cmnghttp2/CMakeLists.txt index 17cc6dd..3bc2778 100644 --- a/Utilities/cmnghttp2/CMakeLists.txt +++ b/Utilities/cmnghttp2/CMakeLists.txt @@ -1,6 +1,6 @@ # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmzlib/CMakeLists.txt b/Utilities/cmzlib/CMakeLists.txt index d266af9..d57cb29 100644 --- a/Utilities/cmzlib/CMakeLists.txt +++ b/Utilities/cmzlib/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(CMZLIB) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") diff --git a/Utilities/cmzstd/CMakeLists.txt b/Utilities/cmzstd/CMakeLists.txt index 323151c..1997195 100644 --- a/Utilities/cmzstd/CMakeLists.txt +++ b/Utilities/cmzstd/CMakeLists.txt @@ -2,7 +2,7 @@ project(zstd C) # Disable warnings to avoid changing 3rd party code. if(CMAKE_C_COMPILER_ID MATCHES - "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM)$") + "^(GNU|Clang|AppleClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") -- cgit v0.12 From 46d4c8e4df69ebba1d9fa711896e471a5bfbbafa Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 19 Apr 2021 11:12:26 -0400 Subject: CTestCustom: Ignore warning from FD_ZERO macro on NVHPC --- CTestCustom.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 4c8267d..238ca15 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -7,6 +7,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION "warning LNK4221" "warning LNK4204" # Occurs by race condition with objects in small libs "variable .var_args[2]*. is used before its value is set" + "warning: variable .__d[01]. was set but never used" # FD_ZERO on NVHPC "jobserver unavailable" "warning: \\(Long double usage is reported only once for each file" "warning: To disable this warning use" -- cgit v0.12 From e4ff2b51b95d26dcfb70f0351328d1a285c22800 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 20 Apr 2021 13:25:53 -0400 Subject: Help: Demonstrate using set_target_properties with CUDA architectures A common anti-pattern is to copy from the `CUDA_ARCHITECTURES` documentation. If at any point the user tries to simplify by changin `set_property` to `set_target_properties` the code breaks. To better train users, provide and example of how to set multiple CUDA architectures with `set_target_properties`. --- Help/policy/CMP0104.rst | 2 +- Help/prop_tgt/CUDA_ARCHITECTURES.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Help/policy/CMP0104.rst b/Help/policy/CMP0104.rst index 7c7a16e..b125729 100644 --- a/Help/policy/CMP0104.rst +++ b/Help/policy/CMP0104.rst @@ -41,7 +41,7 @@ Examples .. code-block:: cmake - set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72) + set_target_properties(tgt PROPERTIES CUDA_ARCHITECTURES "35;50;72") Generates code for real and virtual architectures ``30``, ``50`` and ``72``. diff --git a/Help/prop_tgt/CUDA_ARCHITECTURES.rst b/Help/prop_tgt/CUDA_ARCHITECTURES.rst index d56b769..a3191e8 100644 --- a/Help/prop_tgt/CUDA_ARCHITECTURES.rst +++ b/Help/prop_tgt/CUDA_ARCHITECTURES.rst @@ -25,7 +25,7 @@ Examples .. code-block:: cmake - set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72) + set_target_properties(tgt PROPERTIES CUDA_ARCHITECTURES "35;50;72") Generates code for real and virtual architectures ``30``, ``50`` and ``72``. -- cgit v0.12 From b94bf12a310717cc548033dd69337c363d0b3e6f Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Tue, 20 Apr 2021 13:50:42 -0400 Subject: Help: cmake_minimum_required specify max is only for policies Make it even clearer that for the signature `...` that the second value is only used for policies, and is not a clamp range of supported CMake versions. --- Help/command/cmake_minimum_required.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Help/command/cmake_minimum_required.rst b/Help/command/cmake_minimum_required.rst index c3b3e73..2cc3cfe 100644 --- a/Help/command/cmake_minimum_required.rst +++ b/Help/command/cmake_minimum_required.rst @@ -5,21 +5,21 @@ Require a minimum version of cmake. .. code-block:: cmake - cmake_minimum_required(VERSION [...] [FATAL_ERROR]) + cmake_minimum_required(VERSION [...] [FATAL_ERROR]) .. versionadded:: 3.12 - The optional ```` version. + The optional ```` version. Sets the minimum required version of cmake for a project. Also updates the policy settings as explained below. -```` and the optional ```` are each CMake versions of the form -``major.minor[.patch[.tweak]]``, and the ``...`` is literal. +```` and the optional ```` are each CMake versions of the +form ``major.minor[.patch[.tweak]]``, and the ``...`` is literal. If the running version of CMake is lower than the ```` required version it will stop processing the project and report an error. -The optional ```` version, if specified, must be at least the -```` version and affects policy settings as described below. +The optional ```` version, if specified, must be at least the +```` version and affects policy settings as described in `Policy Settings`_. If the running version of CMake is older than 3.12, the extra ``...`` dots will be seen as version component separators, resulting in the ``...`` part being ignored and preserving the pre-3.12 behavior @@ -43,6 +43,8 @@ with an error instead of just a warning. limits some effects to the function scope when invoked. Such calls should not be made with the intention of having global effects. +.. _`Policy Settings`: + Policy Settings ^^^^^^^^^^^^^^^ -- cgit v0.12 From dfb47335dafc4be5df67a212b3911f65c35607fa Mon Sep 17 00:00:00 2001 From: Alexander Pivovarov Date: Tue, 20 Apr 2021 13:39:34 -0700 Subject: Tutorial: Step12 install MathFunctionsConfigVersion.cmake --- Help/guide/tutorial/Step12/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Help/guide/tutorial/Step12/CMakeLists.txt b/Help/guide/tutorial/Step12/CMakeLists.txt index eca79d9..1b0c826 100644 --- a/Help/guide/tutorial/Step12/CMakeLists.txt +++ b/Help/guide/tutorial/Step12/CMakeLists.txt @@ -110,6 +110,7 @@ write_basic_package_version_file( # install the configuration file install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake DESTINATION lib/cmake/MathFunctions ) -- cgit v0.12 From 71cbddf83ae552bab98620624573b820a7cb4161 Mon Sep 17 00:00:00 2001 From: friendlyanon Date: Wed, 21 Apr 2021 03:22:01 +0200 Subject: cmake(1): Change wording for fields in presets The placement of the word "optionally" implied that the fields mentioned before are not optional, which is not the case starting from version 3 of the presets. --- Help/manual/cmake.1.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 02828ac..f416f86 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -381,9 +381,9 @@ Options ``--preset ``, ``--preset=`` Reads a :manual:`preset ` from ``/CMakePresets.json`` and - ``/CMakeUserPresets.json``. The preset specifies the - generator and the build directory, and optionally a list of variables and - other arguments to pass to CMake. The current working directory must contain + ``/CMakeUserPresets.json``. The preset may specify the + generator and the build directory, and a list of variables and other + arguments to pass to CMake. The current working directory must contain CMake preset files. The :manual:`CMake GUI ` can also recognize ``CMakePresets.json`` and ``CMakeUserPresets.json`` files. For full details on these files, see :manual:`cmake-presets(7)`. -- cgit v0.12 From 57872e6d44ca4ea639ef5a6a712be4dd0f12710e Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Wed, 21 Apr 2021 00:01:08 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3ba0698..0da463a 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210420) +set(CMake_VERSION_PATCH 20210421) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 11c0bfff89d6a3ff20129db056b6ad656004f897 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Apr 2021 10:18:07 -0400 Subject: VS: Generalize CSharp /langversion flag mapping Map the `/langversion:` flag followed by any value to a `LangVersion` element with the specified value in the `.csproj` file. Fixes: #22089 --- Templates/MSBuild/FlagTables/v10_CSharp.json | 51 ++++----------------------- Templates/MSBuild/FlagTables/v11_CSharp.json | 51 ++++----------------------- Templates/MSBuild/FlagTables/v12_CSharp.json | 51 ++++----------------------- Templates/MSBuild/FlagTables/v140_CSharp.json | 51 ++++----------------------- Templates/MSBuild/FlagTables/v141_CSharp.json | 51 ++++----------------------- Templates/MSBuild/FlagTables/v142_CSharp.json | 51 ++++----------------------- 6 files changed, 36 insertions(+), 270 deletions(-) diff --git a/Templates/MSBuild/FlagTables/v10_CSharp.json b/Templates/MSBuild/FlagTables/v10_CSharp.json index 5989aea..9f21d9a 100644 --- a/Templates/MSBuild/FlagTables/v10_CSharp.json +++ b/Templates/MSBuild/FlagTables/v10_CSharp.json @@ -363,52 +363,13 @@ }, { "name": "LangVersion", - "switch": "langversion:ISO-1", + "switch": "langversion:", "comment": "", - "value": "ISO-1", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:ISO-2", - "comment": "", - "value": "ISO-2", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:3", - "comment": "", - "value": "3", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:4", - "comment": "", - "value": "4", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:5", - "comment": "", - "value": "5", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:6", - "comment": "", - "value": "6", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:default", - "comment": "", - "value": "default", - "flags": [] + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] }, { "name": "DelaySign", diff --git a/Templates/MSBuild/FlagTables/v11_CSharp.json b/Templates/MSBuild/FlagTables/v11_CSharp.json index 5989aea..9f21d9a 100644 --- a/Templates/MSBuild/FlagTables/v11_CSharp.json +++ b/Templates/MSBuild/FlagTables/v11_CSharp.json @@ -363,52 +363,13 @@ }, { "name": "LangVersion", - "switch": "langversion:ISO-1", + "switch": "langversion:", "comment": "", - "value": "ISO-1", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:ISO-2", - "comment": "", - "value": "ISO-2", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:3", - "comment": "", - "value": "3", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:4", - "comment": "", - "value": "4", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:5", - "comment": "", - "value": "5", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:6", - "comment": "", - "value": "6", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:default", - "comment": "", - "value": "default", - "flags": [] + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] }, { "name": "DelaySign", diff --git a/Templates/MSBuild/FlagTables/v12_CSharp.json b/Templates/MSBuild/FlagTables/v12_CSharp.json index 5989aea..9f21d9a 100644 --- a/Templates/MSBuild/FlagTables/v12_CSharp.json +++ b/Templates/MSBuild/FlagTables/v12_CSharp.json @@ -363,52 +363,13 @@ }, { "name": "LangVersion", - "switch": "langversion:ISO-1", + "switch": "langversion:", "comment": "", - "value": "ISO-1", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:ISO-2", - "comment": "", - "value": "ISO-2", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:3", - "comment": "", - "value": "3", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:4", - "comment": "", - "value": "4", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:5", - "comment": "", - "value": "5", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:6", - "comment": "", - "value": "6", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:default", - "comment": "", - "value": "default", - "flags": [] + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] }, { "name": "DelaySign", diff --git a/Templates/MSBuild/FlagTables/v140_CSharp.json b/Templates/MSBuild/FlagTables/v140_CSharp.json index 5989aea..9f21d9a 100644 --- a/Templates/MSBuild/FlagTables/v140_CSharp.json +++ b/Templates/MSBuild/FlagTables/v140_CSharp.json @@ -363,52 +363,13 @@ }, { "name": "LangVersion", - "switch": "langversion:ISO-1", + "switch": "langversion:", "comment": "", - "value": "ISO-1", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:ISO-2", - "comment": "", - "value": "ISO-2", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:3", - "comment": "", - "value": "3", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:4", - "comment": "", - "value": "4", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:5", - "comment": "", - "value": "5", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:6", - "comment": "", - "value": "6", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:default", - "comment": "", - "value": "default", - "flags": [] + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] }, { "name": "DelaySign", diff --git a/Templates/MSBuild/FlagTables/v141_CSharp.json b/Templates/MSBuild/FlagTables/v141_CSharp.json index 5989aea..9f21d9a 100644 --- a/Templates/MSBuild/FlagTables/v141_CSharp.json +++ b/Templates/MSBuild/FlagTables/v141_CSharp.json @@ -363,52 +363,13 @@ }, { "name": "LangVersion", - "switch": "langversion:ISO-1", + "switch": "langversion:", "comment": "", - "value": "ISO-1", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:ISO-2", - "comment": "", - "value": "ISO-2", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:3", - "comment": "", - "value": "3", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:4", - "comment": "", - "value": "4", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:5", - "comment": "", - "value": "5", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:6", - "comment": "", - "value": "6", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:default", - "comment": "", - "value": "default", - "flags": [] + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] }, { "name": "DelaySign", diff --git a/Templates/MSBuild/FlagTables/v142_CSharp.json b/Templates/MSBuild/FlagTables/v142_CSharp.json index 4dcea9d..ae1bd47 100644 --- a/Templates/MSBuild/FlagTables/v142_CSharp.json +++ b/Templates/MSBuild/FlagTables/v142_CSharp.json @@ -381,52 +381,13 @@ }, { "name": "LangVersion", - "switch": "langversion:ISO-1", + "switch": "langversion:", "comment": "", - "value": "ISO-1", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:ISO-2", - "comment": "", - "value": "ISO-2", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:3", - "comment": "", - "value": "3", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:4", - "comment": "", - "value": "4", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:5", - "comment": "", - "value": "5", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:6", - "comment": "", - "value": "6", - "flags": [] - }, - { - "name": "LangVersion", - "switch": "langversion:default", - "comment": "", - "value": "default", - "flags": [] + "value": "", + "flags": [ + "UserValue", + "UserRequired" + ] }, { "name": "DelaySign", -- cgit v0.12 From 835896e985a0333e56623d16761dfa2b37d0a7e2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 20 Apr 2021 12:11:50 -0400 Subject: cmake: Improve error message when failing to update generation timestamp Include the underlying system error description. Issue: #21571, #22086 --- Source/cmake.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index af3a504..d24e268 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3074,12 +3074,16 @@ static bool cmakeCheckStampFile(const std::string& stampName) cmsys::ofstream stamp(stampTemp.c_str()); stamp << "# CMake generation timestamp file for this directory.\n"; } - if (cmSystemTools::RenameFile(stampTemp, stampName)) { + std::string err; + if (cmSystemTools::RenameFile(stampTemp, stampName, + cmSystemTools::Replace::Yes, &err) == + cmSystemTools::RenameResult::Success) { // CMake does not need to re-run because the stamp file is up-to-date. return true; } cmSystemTools::RemoveFile(stampTemp); - cmSystemTools::Error("Cannot restore timestamp " + stampName); + cmSystemTools::Error( + cmStrCat("Cannot restore timestamp \"", stampName, "\": ", err)); return false; } -- cgit v0.12 From 1b37305b0f3bfcf510a47fd38fb226c0364958ea Mon Sep 17 00:00:00 2001 From: oltolm Date: Wed, 21 Apr 2021 15:46:53 +0000 Subject: VS: Add support for ASAN -fsanitize=address flag Map it to the `EnableASAN` element in `.vcxproj` files. Fixes: #21081 --- Templates/MSBuild/FlagTables/v142_CL.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Templates/MSBuild/FlagTables/v142_CL.json b/Templates/MSBuild/FlagTables/v142_CL.json index 7c2d291..9f07961 100644 --- a/Templates/MSBuild/FlagTables/v142_CL.json +++ b/Templates/MSBuild/FlagTables/v142_CL.json @@ -1222,5 +1222,12 @@ "UserValue", "UserRequired" ] + }, + { + "name": "EnableASAN", + "switch": "fsanitize=address", + "comment": "Enable Address Sanitizer", + "value": "true", + "flags": [] } ] -- cgit v0.12 From 2e2db28e2f19ebde06d2bd5248a8828568dbd306 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Apr 2021 14:20:28 -0400 Subject: Find{BLAS,LAPACK}: Simplify check_function_exists state maintenance Now that `CHECK_{BLAS,LAPACK}_LIBRARIES` are functions, we can set `CMAKE_REQUIRED_QUIET` locally without affecting the global state. --- Modules/FindBLAS.cmake | 5 +---- Modules/FindLAPACK.cmake | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index c23e41b..855d079 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -176,10 +176,7 @@ if(CMAKE_Fortran_COMPILER_LOADED) else() include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) endif() -include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -cmake_push_check_state() -set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) if(BLA_PREFER_PKGCONFIG) find_package(PkgConfig) @@ -261,6 +258,7 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib if(_libraries_work) # Test this combination of libraries. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_deps}) + set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() @@ -1086,5 +1084,4 @@ if(NOT BLA_F95) endif() _add_blas_target() -cmake_pop_check_state() set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index d89c40d..3529b12 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -127,7 +127,6 @@ if(CMAKE_Fortran_COMPILER_LOADED) else() include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake) endif() -include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) function(_add_lapack_target) @@ -164,9 +163,6 @@ function(_add_lapack_target) endfunction() macro(_lapack_find_library_setup) - cmake_push_check_state() - set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) - set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) if(BLA_STATIC) if(WIN32) @@ -185,7 +181,6 @@ endmacro() macro(_lapack_find_library_teardown) set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) unset(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - cmake_pop_check_state() endmacro() # TODO: move this stuff to a separate module @@ -243,6 +238,7 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl if(_libraries_work) # Test this combination of libraries. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${_libraries} ${_blas} ${_deps}) + set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY}) if(CMAKE_Fortran_COMPILER_LOADED) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() -- cgit v0.12 From 193714d67ddddee36f7b5245e05d40b96f1de802 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Apr 2021 14:22:35 -0400 Subject: Find{BLAS,LAPACK}: Simplify search for static libraries Now that `CHECK_{BLAS,LAPACK}_LIBRARIES` are functions, we can set `CMAKE_FIND_LIBRARY_SUFFIXES` locally without affecting the global state. This avoids the need for local state switching that was added in commit 9ef82d95d8 (FindBLAS: Fix detection of OpenMP as dependency of BLA_STATIC, 2021-04-07, v3.20.1~3^2), so remove that. --- Modules/FindBLAS.cmake | 32 +++++++++++++------------------- Modules/FindLAPACK.cmake | 38 +++++++++++++------------------------- 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index 855d079..f3a8b74 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -189,20 +189,6 @@ if(BLA_PREFER_PKGCONFIG) endif() endif() -set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) -if(BLA_STATIC) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() -else() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif() -endif() - # TODO: move this stuff to a separate module function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs) @@ -217,6 +203,19 @@ function(CHECK_BLAS_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlib set(_libraries) set(_combined_name) + if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() + else() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() + endif() + set(_extaddlibdir "${_addlibdir}") if(WIN32) list(APPEND _extaddlibdir ENV LIB) @@ -626,8 +625,6 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") endif() set(_threadlibs "${CMAKE_THREAD_LIBS_INIT}") if(BLA_STATIC) - set(_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") - set(CMAKE_FIND_LIBRARY_SUFFIXES "${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") if (CMAKE_C_COMPILER_LOADED) find_package(OpenMP COMPONENTS C) list(PREPEND _threadlibs "${OpenMP_C_LIBRARIES}") @@ -635,8 +632,6 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All") find_package(OpenMP COMPONENTS CXX) list(PREPEND _threadlibs "${OpenMP_CXX_LIBRARIES}") endif() - set(CMAKE_FIND_LIBRARY_SUFFIXES "${_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES}") - unset(_blas_STATIC_CMAKE_FIND_LIBRARY_SUFFIXES) endif() check_blas_libraries( BLAS_LIBRARIES @@ -1084,4 +1079,3 @@ if(NOT BLA_F95) endif() _add_blas_target() -set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 3529b12..37ea156 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -162,27 +162,6 @@ function(_add_lapack_target) endif() endfunction() -macro(_lapack_find_library_setup) - set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - if(BLA_STATIC) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - endif() - else() - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - # for ubuntu's libblas3gf and liblapack3gf packages - set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) - endif() - endif() -endmacro() - -macro(_lapack_find_library_teardown) - set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - unset(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) -endmacro() - # TODO: move this stuff to a separate module function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addlibdir _subdirs _blas) @@ -197,6 +176,19 @@ function(CHECK_LAPACK_LIBRARIES LIBRARIES _prefix _name _flags _list _deps _addl set(_libraries) set(_combined_name) + if(BLA_STATIC) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() + else() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif() + endif() + set(_extaddlibdir "${_addlibdir}") if(WIN32) list(APPEND _extaddlibdir ENV LIB) @@ -281,8 +273,6 @@ macro(_lapack_find_dependency dep) set(_lapack_quiet_arg) endmacro() -_lapack_find_library_setup() - set(LAPACK_LINKER_FLAGS) set(LAPACK_LIBRARIES) set(LAPACK95_LIBRARIES) @@ -667,5 +657,3 @@ if(LAPACK_LIBRARIES STREQUAL "LAPACK_LIBRARIES-PLACEHOLDER-FOR-EMPTY-LIBRARIES") endif() _add_lapack_target() - -_lapack_find_library_teardown() -- cgit v0.12 From cb6889a09c8cd538a0856942e429fddc78dbd24e Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Apr 2021 14:26:18 -0400 Subject: FindLAPACK: Fix finding generic LAPACK with BLA_STATIC Fixes: #21071 --- Modules/FindLAPACK.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 37ea156..ab6214b 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -620,17 +620,25 @@ if(NOT LAPACK_NOT_FOUND_MESSAGE) AND (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")) + if(BLA_STATIC) + # We do not know for sure how the LAPACK reference implementation + # is built on this host. Guess typical dependencies. + set(_lapack_generic_deps "-lgfortran;-lm") + else() + set(_lapack_generic_deps "") + endif() check_lapack_libraries( LAPACK_LIBRARIES LAPACK cheev "" "lapack" - "" + "${_lapack_generic_deps}" "" "" "${BLAS_LIBRARIES}" ) + unset(_lapack_generic_deps) endif() endif() -- cgit v0.12 From f3f715688fb2b73652aee97b478d14d9c7689322 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Apr 2021 14:30:17 -0400 Subject: Find{BLAS,LAPACK}: Add test case covering BLA_STATIC with Generic vendor --- .gitlab/ci/configure_debian10_aarch64_ninja.cmake | 2 ++ .gitlab/ci/configure_debian10_ninja.cmake | 2 ++ .gitlab/ci/configure_fedora33_makefiles.cmake | 2 ++ Tests/FindBLAS/CMakeLists.txt | 13 +++++++++++++ Tests/FindLAPACK/CMakeLists.txt | 13 +++++++++++++ 5 files changed, 32 insertions(+) diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake index f665f7d..8fc850c 100644 --- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake +++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake @@ -1,5 +1,6 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All" CACHE STRING "") +set(CMake_TEST_FindBLAS_STATIC "Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -24,6 +25,7 @@ set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") set(CMake_TEST_FindLAPACK "All" CACHE STRING "") +set(CMake_TEST_FindLAPACK_STATIC "Generic" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake index 9de3013..94cf6c1 100644 --- a/.gitlab/ci/configure_debian10_ninja.cmake +++ b/.gitlab/ci/configure_debian10_ninja.cmake @@ -1,5 +1,6 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All" CACHE STRING "") +set(CMake_TEST_FindBLAS_STATIC "Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -24,6 +25,7 @@ set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") set(CMake_TEST_FindLAPACK "All" CACHE STRING "") +set(CMake_TEST_FindLAPACK_STATIC "Generic" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/.gitlab/ci/configure_fedora33_makefiles.cmake b/.gitlab/ci/configure_fedora33_makefiles.cmake index 4143134..7519d95 100644 --- a/.gitlab/ci/configure_fedora33_makefiles.cmake +++ b/.gitlab/ci/configure_fedora33_makefiles.cmake @@ -1,5 +1,6 @@ set(CMake_TEST_FindALSA "ON" CACHE BOOL "") set(CMake_TEST_FindBLAS "All" CACHE STRING "") +set(CMake_TEST_FindBLAS_STATIC "Generic" CACHE STRING "") set(CMake_TEST_FindBoost "ON" CACHE BOOL "") set(CMake_TEST_FindBoost_Python "ON" CACHE BOOL "") set(CMake_TEST_FindBZip2 "ON" CACHE BOOL "") @@ -24,6 +25,7 @@ set(CMake_TEST_FindIntl "ON" CACHE BOOL "") set(CMake_TEST_FindJPEG "ON" CACHE BOOL "") set(CMake_TEST_FindJsonCpp "ON" CACHE BOOL "") set(CMake_TEST_FindLAPACK "All" CACHE STRING "") +set(CMake_TEST_FindLAPACK_STATIC "Generic" CACHE STRING "") set(CMake_TEST_FindLibArchive "ON" CACHE BOOL "") set(CMake_TEST_FindLibinput "ON" CACHE BOOL "") set(CMake_TEST_FindLibLZMA "ON" CACHE BOOL "") diff --git a/Tests/FindBLAS/CMakeLists.txt b/Tests/FindBLAS/CMakeLists.txt index 47ec568..63ef1dd 100644 --- a/Tests/FindBLAS/CMakeLists.txt +++ b/Tests/FindBLAS/CMakeLists.txt @@ -10,3 +10,16 @@ foreach(vendor IN LISTS CMake_TEST_FindBLAS) --test-command ${CMAKE_CTEST_COMMAND} -V -C $ ) endforeach() + +foreach(vendor IN LISTS CMake_TEST_FindBLAS_STATIC) + add_test(NAME FindBLAS.Test_${vendor}_Static COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindBLAS/Test" + "${CMake_BINARY_DIR}/Tests/FindBLAS/Test_${vendor}_Static" + ${build_generator_args} + --build-project TestFindBLAS + --build-options ${build_options} -DBLA_VENDOR=${vendor} -DBLA_STATIC=ON + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +endforeach() diff --git a/Tests/FindLAPACK/CMakeLists.txt b/Tests/FindLAPACK/CMakeLists.txt index 5e2ea7a..eab5bb4 100644 --- a/Tests/FindLAPACK/CMakeLists.txt +++ b/Tests/FindLAPACK/CMakeLists.txt @@ -10,3 +10,16 @@ foreach(vendor IN LISTS CMake_TEST_FindLAPACK) --test-command ${CMAKE_CTEST_COMMAND} -V -C $ ) endforeach() + +foreach(vendor IN LISTS CMake_TEST_FindLAPACK_STATIC) + add_test(NAME FindLAPACK.Test_${vendor}_Static COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindLAPACK/Test" + "${CMake_BINARY_DIR}/Tests/FindLAPACK/Test_${vendor}_Static" + ${build_generator_args} + --build-project TestFindLAPACK + --build-options ${build_options} -DBLA_VENDOR=${vendor} -DBLA_STATIC=ON + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) +endforeach() -- cgit v0.12 From 051c3a04498f89483edc43b468ae25748a7032a4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Apr 2021 14:36:13 -0400 Subject: Find{BLAS,LAPACK}: Add test case covering BLA_STATIC with Intel MKL --- .gitlab/ci/configure_intelcompiler_common.cmake | 2 ++ Tests/FindBLAS/Test/CMakeLists.txt | 2 +- Tests/FindLAPACK/Test/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/configure_intelcompiler_common.cmake b/.gitlab/ci/configure_intelcompiler_common.cmake index be3d15b..79f657b 100644 --- a/.gitlab/ci/configure_intelcompiler_common.cmake +++ b/.gitlab/ci/configure_intelcompiler_common.cmake @@ -1,4 +1,6 @@ set(CMake_TEST_FindBLAS "Intel10_64lp" CACHE STRING "") +set(CMake_TEST_FindBLAS_STATIC "Intel10_64lp" CACHE STRING "") set(CMake_TEST_FindLAPACK "Intel10_64lp" CACHE STRING "") +set(CMake_TEST_FindLAPACK_STATIC "Intel10_64lp" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/Tests/FindBLAS/Test/CMakeLists.txt b/Tests/FindBLAS/Test/CMakeLists.txt index 1bebf8e..98e12d5 100644 --- a/Tests/FindBLAS/Test/CMakeLists.txt +++ b/Tests/FindBLAS/Test/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(test_var PRIVATE ${BLAS_LIBRARIES}) add_test(NAME test_var COMMAND test_var) if(BLA_VENDOR STREQUAL "Intel10_64lp") - if(NOT BLAS_LIBRARIES MATCHES "^[^;]*mkl_intel_lp64") + if(NOT BLAS_LIBRARIES MATCHES "^(-Wl,--start-group;)?[^;]*mkl_intel_lp64") message(FATAL_ERROR "BLAS_LIBRARIES does not start in mkl_intel_lp64:\n ${BLAS_LIBRARIES}") endif() endif() diff --git a/Tests/FindLAPACK/Test/CMakeLists.txt b/Tests/FindLAPACK/Test/CMakeLists.txt index 67fb9bd..bb33482 100644 --- a/Tests/FindLAPACK/Test/CMakeLists.txt +++ b/Tests/FindLAPACK/Test/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(test_var PRIVATE ${LAPACK_LIBRARIES}) add_test(NAME test_var COMMAND test_var) if(BLA_VENDOR STREQUAL "Intel10_64lp") - if(NOT LAPACK_LIBRARIES MATCHES "^[^;]*mkl_intel_lp64") + if(NOT LAPACK_LIBRARIES MATCHES "^(-Wl,--start-group;)?[^;]*mkl_intel_lp64") message(FATAL_ERROR "LAPACK_LIBRARIES does not start in mkl_intel_lp64:\n ${LAPACK_LIBRARIES}") endif() endif() -- cgit v0.12 From e4b793c614f2a499d4d235ec2267ad6bff56a697 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 20 Apr 2021 18:46:26 +0200 Subject: file(REAL_PATH): add option EXPAND_TILDE This option enables the replacement of any leading tilde with the path to the user's home directory. --- Help/command/cmake_path.rst | 3 +- Help/command/file.rst | 20 +++++++++--- Help/release/dev/file-REAL_PATH-EXPAND_TILDE.rst | 5 +++ Source/cmFileCommand.cxx | 23 ++++++++++++-- Tests/RunCMake/file/REAL_PATH.cmake | 40 ++++++++++++++++++------ Tests/RunCMake/file/RunCMakeTest.cmake | 7 +++-- 6 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 Help/release/dev/file-REAL_PATH-EXPAND_TILDE.rst diff --git a/Help/command/cmake_path.rst b/Help/command/cmake_path.rst index a8999f3..193180d 100644 --- a/Help/command/cmake_path.rst +++ b/Help/command/cmake_path.rst @@ -687,7 +687,8 @@ When the ``NORMALIZE`` option is specified, the path is :ref:`normalized ` after the path computation. Because ``cmake_path()`` does not access the filesystem, symbolic links are -not resolved. To compute a real path with symbolic links resolved, use the +not resolved and any leading tilde is not expanded. To compute a real path +with symbolic links resolved and leading tildes expanded, use the :command:`file(REAL_PATH)` command instead. Native Conversion diff --git a/Help/command/file.rst b/Help/command/file.rst index 62642cf..e170526 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -50,7 +50,7 @@ Synopsis file(`CHMOD_RECURSE`_ ... ... PERMISSIONS ... [...]) `Path Conversion`_ - file(`REAL_PATH`_ [BASE_DIRECTORY ]) + file(`REAL_PATH`_ [BASE_DIRECTORY ] [EXPAND_TILDE]) file(`RELATIVE_PATH`_ ) file({`TO_CMAKE_PATH`_ | `TO_NATIVE_PATH`_} ) @@ -924,16 +924,26 @@ Path Conversion .. code-block:: cmake - file(REAL_PATH [BASE_DIRECTORY ]) + file(REAL_PATH [BASE_DIRECTORY ] [EXPAND_TILDE]) .. versionadded:: 3.19 Compute the absolute path to an existing file or directory with symlinks resolved. -If the provided ```` is a relative path, it is evaluated relative to the -given base directory ````. If no base directory is provided, the default -base directory will be :variable:`CMAKE_CURRENT_SOURCE_DIR`. +``BASE_DIRECTORY `` + If the provided ```` is a relative path, it is evaluated relative to the + given base directory ````. If no base directory is provided, the default + base directory will be :variable:`CMAKE_CURRENT_SOURCE_DIR`. + +``EXPAND_TILDE`` + .. versionadded:: 3.21 + + If the ```` is ``~`` or starts with ``~/``, the ``~`` is replaced by + the user's home directory. The path to the home directory is obtained from + environment variables. On Windows, the ``USERPROFILE`` environment variable + is used, falling back to the ``HOME`` environment variable if ``USERPROFILE`` + is not defined. On all other platforms, only ``HOME`` is used. .. _RELATIVE_PATH: diff --git a/Help/release/dev/file-REAL_PATH-EXPAND_TILDE.rst b/Help/release/dev/file-REAL_PATH-EXPAND_TILDE.rst new file mode 100644 index 0000000..cdf1efa --- /dev/null +++ b/Help/release/dev/file-REAL_PATH-EXPAND_TILDE.rst @@ -0,0 +1,5 @@ +file-REAL_PATH-EXPAND_TILDE +--------------------------- + +* The :command:`file(REAL_PATH)` command gained the option ``EXPAND_TILDE`` to + replace any leading tilde with the path to the user's home directory. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 05ebcca..a943258 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1246,9 +1246,12 @@ bool HandleRealPathCommand(std::vector const& args, struct Arguments { std::string BaseDirectory; + bool ExpandTilde = false; }; - static auto const parser = cmArgumentParser{}.Bind( - "BASE_DIRECTORY"_s, &Arguments::BaseDirectory); + static auto const parser = + cmArgumentParser{} + .Bind("BASE_DIRECTORY"_s, &Arguments::BaseDirectory) + .Bind("EXPAND_TILDE"_s, &Arguments::ExpandTilde); std::vector unparsedArguments; std::vector keywordsMissingValue; @@ -1270,7 +1273,21 @@ bool HandleRealPathCommand(std::vector const& args, arguments.BaseDirectory = status.GetMakefile().GetCurrentSourceDirectory(); } - cmCMakePath path(args[1]); + auto input = args[1]; + if (arguments.ExpandTilde && !input.empty()) { + if (input[0] == '~' && (input.length() == 1 || input[1] == '/')) { + std::string home; + if ( +#if defined(_WIN32) && !defined(__CYGWIN__) + cmSystemTools::GetEnv("USERPROFILE", home) || +#endif + cmSystemTools::GetEnv("HOME", home)) { + input.replace(0, 1, home); + } + } + } + + cmCMakePath path(input, cmCMakePath::auto_format); path = path.Absolute(arguments.BaseDirectory).Normal(); auto realPath = cmSystemTools::GetRealPath(path.GenericString()); diff --git a/Tests/RunCMake/file/REAL_PATH.cmake b/Tests/RunCMake/file/REAL_PATH.cmake index be25706..0b5d3c0 100644 --- a/Tests/RunCMake/file/REAL_PATH.cmake +++ b/Tests/RunCMake/file/REAL_PATH.cmake @@ -1,14 +1,36 @@ -file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/test.txt") -file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.sym") -file(CREATE_LINK "test.txt" "${CMAKE_CURRENT_BINARY_DIR}/test.sym" SYMBOLIC) +if (NOT WIN32 OR CYGWIN) + file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/test.txt") + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/test.sym") + file(CREATE_LINK "test.txt" "${CMAKE_CURRENT_BINARY_DIR}/test.sym" SYMBOLIC) -file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/test.sym" real_path) -if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + file(REAL_PATH "${CMAKE_CURRENT_BINARY_DIR}/test.sym" real_path) + if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + endif() + + file(REAL_PATH "test.sym" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") + endif() +endif() + + +If (WIN32) + cmake_path(SET HOME_DIR "$ENV{USERPROFILE}") + if (NOT HOME_DIR) + cmake_path(SET HOME_DIR "$ENV{HOME}") + endif() +else() + set(HOME_DIR "$ENV{HOME}") +endif() + +file(REAL_PATH "~" real_path EXPAND_TILDE) +if (NOT real_path STREQUAL "${HOME_DIR}") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}\"") endif() -file(REAL_PATH "test.sym" real_path BASE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -if (NOT real_path STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/test.txt") - message(SEND_ERROR "real path is \"${real_path}\", should be \"${CMAKE_CURRENT_BINARY_DIR}/test.txt\"") +file(REAL_PATH "~/test.txt" real_path EXPAND_TILDE) +if (NOT real_path STREQUAL "${HOME_DIR}/test.txt") + message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}/test.txt\"") endif() diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index b4ea9ba..6d1109a 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -96,11 +96,12 @@ if(NOT WIN32 OR CYGWIN) run_cmake(READ_SYMLINK-noexist) run_cmake(READ_SYMLINK-notsymlink) run_cmake(INSTALL-FOLLOW_SYMLINK_CHAIN) - run_cmake(REAL_PATH-unexpected-arg) - run_cmake(REAL_PATH-no-base-dir) - run_cmake(REAL_PATH) endif() +run_cmake(REAL_PATH-unexpected-arg) +run_cmake(REAL_PATH-no-base-dir) +run_cmake(REAL_PATH) + if(RunCMake_GENERATOR MATCHES "Ninja") # Detect ninja version so we know what tests can be supported. execute_process( -- cgit v0.12 From 86b2457e922810a7648f0ab2c4104124ef73e5f0 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Thu, 22 Apr 2021 00:01:07 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0da463a..970dfaa 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210421) +set(CMake_VERSION_PATCH 20210422) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From eb5e33ba474e061b302cd0b3b1ecb62625489532 Mon Sep 17 00:00:00 2001 From: Alexander Akhundzhanov Date: Sun, 11 Apr 2021 18:08:15 +1000 Subject: Xcode: Add support for embedding app extensions Co-Authored-By: Craig Scott --- Help/manual/cmake-properties.7.rst | 2 + .../XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst | 5 ++ ...ODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst | 6 ++ Help/prop_tgt/XCODE_EMBED_type.rst | 20 ++++-- .../XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst | 18 ++++++ Help/prop_tgt/XCODE_EMBED_type_PATH.rst | 13 +++- .../XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst | 20 ++++++ Help/release/dev/xcode_app_extensions.rst | 11 ++++ Source/cmGlobalXCodeGenerator.cxx | 71 ++++++++++++++++------ Source/cmGlobalXCodeGenerator.h | 13 ++++ Tests/RunCMake/CMakeLists.txt | 2 +- .../EmbedAppExtensions-iOS-check.cmake | 4 ++ .../EmbedAppExtensions-iOS.cmake | 1 + .../EmbedAppExtensions-macOS-check.cmake | 4 ++ .../EmbedAppExtensions-macOS.cmake | 1 + .../XcodeProject-Embed/EmbedAppExtensions.cmake | 21 +++++++ Tests/RunCMake/XcodeProject-Embed/Empty.txt | 0 Tests/RunCMake/XcodeProject-Embed/Info.plist.in | 31 ++++++++++ .../RunCMake/XcodeProject-Embed/RunCMakeTest.cmake | 31 ++++++++++ 19 files changed, 246 insertions(+), 28 deletions(-) create mode 100644 Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst create mode 100644 Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst create mode 100644 Help/release/dev/xcode_app_extensions.rst create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake create mode 100644 Tests/RunCMake/XcodeProject-Embed/Empty.txt create mode 100644 Tests/RunCMake/XcodeProject-Embed/Info.plist.in diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index af170da..d5600dd 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -402,7 +402,9 @@ Properties on Targets /prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY /prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY /prop_tgt/XCODE_EMBED_type + /prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY /prop_tgt/XCODE_EMBED_type_PATH + /prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY /prop_tgt/XCODE_EXPLICIT_FILE_TYPE /prop_tgt/XCODE_GENERATE_SCHEME /prop_tgt/XCODE_LINK_BUILD_PHASE_MODE diff --git a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst index 7b68126..2a4d666 100644 --- a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst +++ b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY.rst @@ -6,3 +6,8 @@ XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY Tell the :generator:`Xcode` generator to perform code signing for all the frameworks and libraries that are embedded using the :prop_tgt:`XCODE_EMBED_FRAMEWORKS >` property. + +.. versionadded:: 3.21 + +This property was generalized to other types of embedded items. See +:prop_tgt:`XCODE_EMBED__CODE_SIGN_ON_COPY` for the more general form. diff --git a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst index 29f8c5c..04daa85 100644 --- a/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst +++ b/Help/prop_tgt/XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY.rst @@ -6,3 +6,9 @@ XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY Tell the :generator:`Xcode` generator to remove headers from all the frameworks that are embedded using the :prop_tgt:`XCODE_EMBED_FRAMEWORKS >` property. + +.. versionadded:: 3.21 + +This property was generalized to other types of embedded items. See +:prop_tgt:`XCODE_EMBED__REMOVE_HEADERS_ON_COPY` for the more +general form. diff --git a/Help/prop_tgt/XCODE_EMBED_type.rst b/Help/prop_tgt/XCODE_EMBED_type.rst index 90c5bc7..a1af56f 100644 --- a/Help/prop_tgt/XCODE_EMBED_type.rst +++ b/Help/prop_tgt/XCODE_EMBED_type.rst @@ -5,10 +5,20 @@ XCODE_EMBED_ Tell the :generator:`Xcode` generator to embed the specified list of items into the target bundle. ```` specifies the embed build phase to use. +See the Xcode documentation for the base location of each ````. + +The supported values for ```` are: + +``FRAMEWORKS`` + The specified items will be added to the ``Embed Frameworks`` build phase. + The items can be CMake target names or paths to frameworks or libraries. + +``APP_EXTENSIONS`` + .. versionadded:: 3.21 + + The specified items will be added to the ``Embed App Extensions`` build phase. + They must be CMake target names. -Currently, the only supported value for ```` is ``FRAMEWORKS``. -The specified items will be added to the ``Embed Frameworks`` build phase. -The items can be CMake target names or paths to frameworks or libraries. See also :prop_tgt:`XCODE_EMBED__PATH`, -:prop_tgt:`XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY` and -:prop_tgt:`XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY`. +:prop_tgt:`XCODE_EMBED__REMOVE_HEADERS_ON_COPY` and +:prop_tgt:`XCODE_EMBED__CODE_SIGN_ON_COPY`. diff --git a/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst new file mode 100644 index 0000000..7ec0385 --- /dev/null +++ b/Help/prop_tgt/XCODE_EMBED_type_CODE_SIGN_ON_COPY.rst @@ -0,0 +1,18 @@ +XCODE_EMBED__CODE_SIGN_ON_COPY +------------------------------------ + +.. versionadded:: 3.20 + +Boolean property used only by the :generator:`Xcode` generator. It specifies +whether to perform code signing for the items that are embedded using the +:prop_tgt:`XCODE_EMBED_` property. + +The supported values for ```` are: + +``FRAMEWORKS`` + +``APP_EXTENSIONS`` + .. versionadded:: 3.21 + +If a ``XCODE_EMBED__CODE_SIGN_ON_COPY`` property is not defined on the +target, no code signing on copy will be performed for that ````. diff --git a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst index 887cf57..a6f980d 100644 --- a/Help/prop_tgt/XCODE_EMBED_type_PATH.rst +++ b/Help/prop_tgt/XCODE_EMBED_type_PATH.rst @@ -3,7 +3,16 @@ XCODE_EMBED__PATH .. versionadded:: 3.20 -Tell the :generator:`Xcode` generator the relative path to use when embedding -the items specified by :prop_tgt:`XCODE_EMBED_`. The path is relative +This property is used only by the :generator:`Xcode` generator. When defined, +it specifies the relative path to use when embedding the items specified by +:prop_tgt:`XCODE_EMBED_`. The path is relative to the base location of the ``Embed XXX`` build phase associated with +````. See the Xcode documentation for the base location of each ````. + +The supported values for ```` are: + +``FRAMEWORKS`` + +``APP_EXTENSIONS`` + .. versionadded:: 3.21 diff --git a/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst b/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst new file mode 100644 index 0000000..75c8eae --- /dev/null +++ b/Help/prop_tgt/XCODE_EMBED_type_REMOVE_HEADERS_ON_COPY.rst @@ -0,0 +1,20 @@ +XCODE_EMBED__REMOVE_HEADERS_ON_COPY +----------------------------------------- + +.. versionadded:: 3.20 + +Boolean property used only by the :generator:`Xcode` generator. It specifies +whether to remove headers from all the frameworks that are embedded using the +:prop_tgt:`XCODE_EMBED_` property. + +The supported values for ```` are: + +``FRAMEWORKS`` + If the ``XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY`` property is not + defined, headers will not be removed on copy by default. + +``APP_EXTENSIONS`` + .. versionadded:: 3.21 + + If the ``XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY`` property is not + defined, headers WILL be removed on copy by default. diff --git a/Help/release/dev/xcode_app_extensions.rst b/Help/release/dev/xcode_app_extensions.rst new file mode 100644 index 0000000..7be7d82 --- /dev/null +++ b/Help/release/dev/xcode_app_extensions.rst @@ -0,0 +1,11 @@ +xcode_app_extensions +-------------------- + +* The :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS >` target property + was added to tell the :generator:`Xcode` generator to embed app extensions + such as iMessage sticker packs. + Aspects of the embedding can be customized with the + :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_PATH >`, + :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_CODE_SIGN_ON_COPY _CODE_SIGN_ON_COPY>` and + :prop_tgt:`XCODE_EMBED_APP_EXTENSIONS_REMOVE_HEADERS_ON_COPY _REMOVE_HEADERS_ON_COPY>` + properties. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dd1704..e31cf01 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3728,7 +3728,10 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) } } -void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) +void cmGlobalXCodeGenerator::AddEmbeddedObjects( + cmXCodeObject* target, const std::string& copyFilesBuildPhaseName, + const std::string& embedPropertyName, const std::string& dstSubfolderSpec, + int actionsOnByDefault) { cmGeneratorTarget* gt = target->GetTarget(); if (!gt) { @@ -3744,7 +3747,7 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) if (!(isFrameworkTarget || isBundleTarget || isCFBundleTarget)) { return; } - cmProp files = gt->GetProperty("XCODE_EMBED_FRAMEWORKS"); + cmProp files = gt->GetProperty(embedPropertyName); if (!files) { return; } @@ -3752,16 +3755,15 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) // Create an "Embedded Frameworks" build phase auto* copyFilesBuildPhase = this->CreateObject(cmXCodeObject::PBXCopyFilesBuildPhase); - std::string copyFilesBuildPhaseName = "Embed Frameworks"; - std::string destinationFrameworks = "10"; copyFilesBuildPhase->SetComment(copyFilesBuildPhaseName); copyFilesBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); copyFilesBuildPhase->AddAttribute("dstSubfolderSpec", - this->CreateString(destinationFrameworks)); + this->CreateString(dstSubfolderSpec)); copyFilesBuildPhase->AddAttribute( "name", this->CreateString(copyFilesBuildPhaseName)); - if (cmProp fwEmbedPath = gt->GetProperty("XCODE_EMBED_FRAMEWORKS_PATH")) { + if (cmProp fwEmbedPath = + gt->GetProperty(cmStrCat(embedPropertyName, "_PATH"))) { copyFilesBuildPhase->AddAttribute("dstPath", this->CreateString(*fwEmbedPath)); } else { @@ -3775,10 +3777,10 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) for (std::string const& relFile : relFiles) { cmXCodeObject* buildFile{ nullptr }; std::string filePath = relFile; - auto* genTarget = FindGeneratorTarget(relFile); + auto* genTarget = this->FindGeneratorTarget(relFile); if (genTarget) { // This is a target - get it's product path reference - auto* xcTarget = FindXCodeTarget(genTarget); + auto* xcTarget = this->FindXCodeTarget(genTarget); if (!xcTarget) { cmSystemTools::Error("Can not find a target for " + genTarget->GetName()); @@ -3792,18 +3794,18 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) " is missing product reference"); continue; } - auto it = FileRefToEmbedBuildFileMap.find(fileRefObject); - if (it == FileRefToEmbedBuildFileMap.end()) { + auto it = this->FileRefToEmbedBuildFileMap.find(fileRefObject); + if (it == this->FileRefToEmbedBuildFileMap.end()) { buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile); buildFile->AddAttribute("fileRef", fileRefObject); - FileRefToEmbedBuildFileMap[fileRefObject] = buildFile; + this->FileRefToEmbedBuildFileMap[fileRefObject] = buildFile; } else { buildFile = it->second; } } else if (cmSystemTools::IsPathToFramework(relFile)) { // This is a regular string path - create file reference - auto it = EmbeddedLibRefs.find(relFile); - if (it == EmbeddedLibRefs.end()) { + auto it = this->EmbeddedLibRefs.find(relFile); + if (it == this->EmbeddedLibRefs.end()) { cmXCodeObject* fileRef = this->CreateXCodeFileReferenceFromPath(relFile, gt, "", nullptr); if (fileRef) { @@ -3829,16 +3831,25 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST); - const auto& rmHeadersProp = - gt->GetSafeProperty("XCODE_EMBED_FRAMEWORKS_REMOVE_HEADERS_ON_COPY"); - if (cmIsOn(rmHeadersProp)) { + + bool removeHeaders = actionsOnByDefault & RemoveHeadersOnCopyByDefault; + if (auto prop = gt->GetProperty( + cmStrCat(embedPropertyName, "_REMOVE_HEADERS_ON_COPY"))) { + removeHeaders = cmIsOn(*prop); + } + if (removeHeaders) { attrs->AddObject(this->CreateString("RemoveHeadersOnCopy")); } - const auto& codeSignProp = - gt->GetSafeProperty("XCODE_EMBED_FRAMEWORKS_CODE_SIGN_ON_COPY"); - if (cmIsOn(codeSignProp)) { + + bool codeSign = actionsOnByDefault & CodeSignOnCopyByDefault; + if (auto prop = + gt->GetProperty(cmStrCat(embedPropertyName, "_CODE_SIGN_ON_COPY"))) { + codeSign = cmIsOn(*prop); + } + if (codeSign) { attrs->AddObject(this->CreateString("CodeSignOnCopy")); } + settings->AddAttributeIfNotEmpty("ATTRIBUTES", attrs); buildFile->AddAttributeIfNotEmpty("settings", settings); if (!buildFiles->HasObject(buildFile)) { @@ -3847,11 +3858,30 @@ void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) } copyFilesBuildPhase->AddAttribute("files", buildFiles); auto* buildPhases = target->GetAttribute("buildPhases"); - // Insert embed build phase right before the post-build command + // Embed-something build phases must be inserted before the post-build + // command because that command is expected to be last buildPhases->InsertObject(buildPhases->GetObjectCount() - 1, copyFilesBuildPhase); } +void cmGlobalXCodeGenerator::AddEmbeddedFrameworks(cmXCodeObject* target) +{ + static const auto dstSubfolderSpec = "10"; + + this->AddEmbeddedObjects(target, "Embed Frameworks", + "XCODE_EMBED_FRAMEWORKS", dstSubfolderSpec, + NoActionOnCopyByDefault); +} + +void cmGlobalXCodeGenerator::AddEmbeddedAppExtensions(cmXCodeObject* target) +{ + static const auto dstSubfolderSpec = "13"; + + this->AddEmbeddedObjects(target, "Embed App Extensions", + "XCODE_EMBED_APP_EXTENSIONS", dstSubfolderSpec, + RemoveHeadersOnCopyByDefault); +} + bool cmGlobalXCodeGenerator::CreateGroups( std::vector& generators) { @@ -4231,6 +4261,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( for (auto t : targets) { this->AddDependAndLinkInformation(t); this->AddEmbeddedFrameworks(t); + this->AddEmbeddedAppExtensions(t); // Inherit project-wide values for any target-specific search paths. this->InheritBuildSettingAttribute(t, "HEADER_SEARCH_PATHS"); this->InheritBuildSettingAttribute(t, "SYSTEM_HEADER_SEARCH_PATHS"); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 1ab56e2..f182584 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -132,6 +132,13 @@ protected: } private: + enum EmbedActionFlags + { + NoActionOnCopyByDefault = 0, + CodeSignOnCopyByDefault = 1, + RemoveHeadersOnCopyByDefault = 2, + }; + bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf); bool ProcessGeneratorToolsetField(std::string const& key, std::string const& value, cmMakefile* mf); @@ -196,7 +203,13 @@ private: const char* attribute); cmXCodeObject* CreateUtilityTarget(cmGeneratorTarget* gtgt); void AddDependAndLinkInformation(cmXCodeObject* target); + void AddEmbeddedObjects(cmXCodeObject* target, + const std::string& copyFilesBuildPhaseName, + const std::string& embedPropertyName, + const std::string& dstSubfolderSpec, + int actionsOnByDefault); void AddEmbeddedFrameworks(cmXCodeObject* target); + void AddEmbeddedAppExtensions(cmXCodeObject* target); void AddPositionIndependentLinkAttribute(cmGeneratorTarget* target, cmXCodeObject* buildSettings, const std::string& configName); diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 354a04e..68db0f2 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -545,7 +545,7 @@ endif() if(XCODE_VERSION) add_RunCMake_test(XcodeProject -DXCODE_VERSION=${XCODE_VERSION}) - add_RunCMake_test(XcodeProject-Embed) + add_RunCMake_test(XcodeProject-Embed -DXCODE_VERSION=${XCODE_VERSION}) # This test can take a very long time due to lots of combinations. # Use a long default timeout and provide an option to customize it. diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake new file mode 100644 index 0000000..576be11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS-check.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake new file mode 100644 index 0000000..839f842 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-iOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedAppExtensions.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake new file mode 100644 index 0000000..576be11 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS-check.cmake @@ -0,0 +1,4 @@ +include(${CMAKE_CURRENT_LIST_DIR}/findAttribute.cmake) + +findAttribute(${test} "RemoveHeadersOnCopy" TRUE) +findAttribute(${test} "CodeSignOnCopy" FALSE) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake new file mode 100644 index 0000000..839f842 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions-macOS.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/EmbedAppExtensions.cmake) diff --git a/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake new file mode 100644 index 0000000..d7494ea --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/EmbedAppExtensions.cmake @@ -0,0 +1,21 @@ +add_library(app_extension MODULE Empty.txt) +set_target_properties(app_extension PROPERTIES + LINKER_LANGUAGE CXX + BUNDLE YES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_ATTRIBUTE_ENABLE_BITCODE "NO" + MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app.app_extension" + XCODE_PRODUCT_TYPE "com.apple.product-type.app-extension" + XCODE_EXPLICIT_FILE_TYPE "wrapper.app-extension" +) + +add_executable(app MACOSX_BUNDLE main.m) +add_dependencies(app app_extension) +set_target_properties(app PROPERTIES + XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED "NO" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "" + XCODE_EMBED_APP_EXTENSIONS app_extension + MACOSX_BUNDLE_GUI_IDENTIFIER "com.example.app" +) diff --git a/Tests/RunCMake/XcodeProject-Embed/Empty.txt b/Tests/RunCMake/XcodeProject-Embed/Empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/XcodeProject-Embed/Info.plist.in b/Tests/RunCMake/XcodeProject-Embed/Info.plist.in new file mode 100644 index 0000000..a26f316 --- /dev/null +++ b/Tests/RunCMake/XcodeProject-Embed/Info.plist.in @@ -0,0 +1,31 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + SomeExtension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.example.app.app_extension + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + app + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0.0 + CFBundleVersion + 1.0.0 + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + NSExtensionPrincipalClass + SomeExtensionBrowserViewController + + + diff --git a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake index 0dc1cf3..e94d084 100644 --- a/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject-Embed/RunCMakeTest.cmake @@ -41,3 +41,34 @@ endfunction() TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir) TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir) + + +function(TestAppExtension platform) + set(testName EmbedAppExtensions-${platform}) + if(NOT platform STREQUAL "macOS") + set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=${platform}) + endif() + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build) + + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + + run_cmake(${testName}) + run_cmake_command(${testName}-build + ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR} + --config Debug + --target app + ) +endfunction() + +# Isolate device tests from host architecture selection. +unset(ENV{CMAKE_OSX_ARCHITECTURES}) + +if(XCODE_VERSION VERSION_GREATER_EQUAL 8) + # The various flag on/off combinations are tested by the EmbedFrameworks... + # tests, so we don't duplicate all the combinations here. We only verify the + # defaults, which is to remove headers on copy, but not code sign. + TestAppExtension(macOS) + TestAppExtension(iOS) +endif() -- cgit v0.12 From 625ef88a92d6632e3efd5ee4d6578bfc77928679 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Apr 2021 09:51:31 -0400 Subject: CUDA: Add CMAKE_CUDA_HOST_COMPILER support on Windows non-VS generators --- Help/envvar/CUDAHOSTCXX.rst | 4 ++++ Help/variable/CMAKE_CUDA_HOST_COMPILER.rst | 4 ++++ Modules/CMakeCUDAInformation.cmake | 7 ------- Modules/CMakeDetermineCUDACompiler.cmake | 15 +++++++++------ Modules/Compiler/NVIDIA-CUDA.cmake | 14 +++++--------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Help/envvar/CUDAHOSTCXX.rst b/Help/envvar/CUDAHOSTCXX.rst index 963f9d1..cf65927 100644 --- a/Help/envvar/CUDAHOSTCXX.rst +++ b/Help/envvar/CUDAHOSTCXX.rst @@ -15,6 +15,10 @@ ignored if the :variable:`CMAKE_CUDA_HOST_COMPILER` variable is defined. This environment variable is primarily meant for use with projects that enable ``CUDA`` as a first-class language. +.. note:: + + Ignored when using :ref:`Visual Studio Generators`. + .. versionadded:: 3.13 The :module:`FindCUDA` module will use this variable to initialize its ``CUDA_HOST_COMPILER`` setting. diff --git a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst index d5fcb7d..9817b1a 100644 --- a/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst +++ b/Help/variable/CMAKE_CUDA_HOST_COMPILER.rst @@ -23,3 +23,7 @@ is read-only and changes to it are undefined behavior. :variable:`CMAKE_CUDA_COMPILER_ID _COMPILER_ID>` is ``NVIDIA``, it does not make sense to set ``CMAKE_CUDA_HOST_COMPILER`` without also setting ``CMAKE_CUDA_COMPILER`` to NVCC. + +.. note:: + + Ignored when using :ref:`Visual Studio Generators`. diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index 44e2c2c..541d207 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -110,13 +110,6 @@ include(CMakeCommonLanguageInclude) # CMAKE_CUDA_COMPILE_SEPARABLE_COMPILATION # CMAKE_CUDA_LINK_EXECUTABLE -if(CMAKE_CUDA_HOST_COMPILER AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") - # FIXME: This is too late for the Platform/Windows-NVIDIA-CUDA module to - # see it, so we do not support CMAKE_CUDA_HOST_COMPILER on Windows. - # Move this to Compiler/NVIDIA-CUDA and update the VS generator too. - string(APPEND _CMAKE_CUDA_EXTRA_FLAGS " -ccbin=") -endif() - # create a shared library if(NOT CMAKE_CUDA_CREATE_SHARED_LIBRARY) set(CMAKE_CUDA_CREATE_SHARED_LIBRARY diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 0f507ea..38c5e9c 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -11,6 +11,9 @@ if( NOT ( ("${CMAKE_GENERATOR}" MATCHES "Make") OR endif() if(${CMAKE_GENERATOR} MATCHES "Visual Studio") + if(DEFINED ENV{CUDAHOSTCXX} OR DEFINED CMAKE_CUDA_HOST_COMPILER) + message(WARNING "Visual Studio does not support specifying CUDAHOSTCXX or CMAKE_CUDA_HOST_COMPILER. Using the C++ compiler provided by Visual Studio.") + endif() else() if(NOT CMAKE_CUDA_COMPILER) set(CMAKE_CUDA_COMPILER_INIT NOTFOUND) @@ -39,13 +42,13 @@ else() endif() mark_as_advanced(CMAKE_CUDA_COMPILER) -endif() -#Allow the user to specify a host compiler -if(NOT $ENV{CUDAHOSTCXX} STREQUAL "") - get_filename_component(CMAKE_CUDA_HOST_COMPILER $ENV{CUDAHOSTCXX} PROGRAM) - if(NOT EXISTS ${CMAKE_CUDA_HOST_COMPILER}) - message(FATAL_ERROR "Could not find compiler set in environment variable CUDAHOSTCXX:\n$ENV{CUDAHOSTCXX}.\n${CMAKE_CUDA_HOST_COMPILER}") + #Allow the user to specify a host compiler except for Visual Studio + if(NOT $ENV{CUDAHOSTCXX} STREQUAL "") + get_filename_component(CMAKE_CUDA_HOST_COMPILER $ENV{CUDAHOSTCXX} PROGRAM) + if(NOT EXISTS ${CMAKE_CUDA_HOST_COMPILER}) + message(FATAL_ERROR "Could not find compiler set in environment variable CUDAHOSTCXX:\n$ENV{CUDAHOSTCXX}.\n${CMAKE_CUDA_HOST_COMPILER}") + endif() endif() endif() diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index a0f7c05..c2fe42d 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -24,21 +24,17 @@ else() set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "") endif() +if(CMAKE_CUDA_HOST_COMPILER AND NOT CMAKE_GENERATOR MATCHES "Visual Studio") + string(APPEND _CMAKE_CUDA_EXTRA_FLAGS " -ccbin=") +endif() + if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89) # The -MD flag was only added to nvcc in 10.2 so # before that we had to invoke the compiler twice # to get header dependency information set(CMAKE_DEPFILE_FLAGS_CUDA "-MD -MT -MF ") else() - if(CMAKE_CUDA_HOST_COMPILER AND NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") - # FIXME: Move the main -ccbin= flag from CMakeCUDAInformation to - # a block above, remove this copy, and update the VS generator too. - set(_CMAKE_CUDA_EXTRA_FLAGS_LOCAL " -ccbin=") - else() - set(_CMAKE_CUDA_EXTRA_FLAGS_LOCAL "") - endif() - set(CMAKE_CUDA_DEPENDS_EXTRA_COMMANDS " ${_CMAKE_CUDA_EXTRA_FLAGS}${_CMAKE_CUDA_EXTRA_FLAGS_LOCAL} ${_CMAKE_COMPILE_AS_CUDA_FLAG} -M -MT -o ") - unset(_CMAKE_CUDA_EXTRA_FLAGS_LOCAL) + set(CMAKE_CUDA_DEPENDS_EXTRA_COMMANDS " ${_CMAKE_CUDA_EXTRA_FLAGS} ${_CMAKE_COMPILE_AS_CUDA_FLAG} -M -MT -o ") endif() set(CMAKE_CUDA_DEPFILE_FORMAT gcc) if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER) -- cgit v0.12 From 741b85b42b4c8d826634b3f968d7de21df5f6c85 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Fri, 16 Apr 2021 18:00:46 +0200 Subject: liblzma: Revise update script to get version 5.2.5 Keep files related to multi threaded stream encoding. --- Utilities/Scripts/update-liblzma.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Utilities/Scripts/update-liblzma.bash b/Utilities/Scripts/update-liblzma.bash index fdf66b3..a5a7175 100755 --- a/Utilities/Scripts/update-liblzma.bash +++ b/Utilities/Scripts/update-liblzma.bash @@ -8,12 +8,17 @@ readonly name="liblzma" readonly ownership="liblzma upstream " readonly subtree="Utilities/cmliblzma" readonly repo="https://git.tukaani.org/xz.git" -readonly tag="v5.2.4" +readonly tag="v5.2.5" readonly shortlog=false readonly paths=" COPYING src/common/common_w32res.rc + src/common/mythread.h src/common/sysdefs.h + src/common/tuklib_common.h + src/common/tuklib_config.h + src/common/tuklib_cpucores.c + src/common/tuklib_cpucores.h src/common/tuklib_integer.h src/liblzma/ " -- cgit v0.12 From 298760661f30faf2014f609506f15ff2d3489ddf Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Apr 2021 13:06:11 -0400 Subject: ExternalData: Improve error message when we fail to create a file Report the underlying system error. --- Modules/ExternalData.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake index 1850e74..189374b 100644 --- a/Modules/ExternalData.cmake +++ b/Modules/ExternalData.cmake @@ -949,7 +949,7 @@ function(_ExternalData_link_or_copy src dst) endif() if(result) file(REMOVE "${tmp}") - message(FATAL_ERROR "Failed to create\n ${tmp}\nfrom\n ${obj}") + message(FATAL_ERROR "Failed to create:\n \"${tmp}\"\nfrom:\n \"${obj}\"\nwith error:\n ${result}") endif() # Atomically create/replace the real destination. -- cgit v0.12 From c54c284de7bab8fcc88bf8cb58fb79f2e3b47f72 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Apr 2021 13:43:04 -0400 Subject: Tests: Improve RunCMake.CPack* test error formatting Format message content for `message(FATAL_ERROR)`. --- Tests/RunCMake/CPack/VerifyResult.cmake | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 0ab545a..294b9e8 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -29,8 +29,16 @@ file(READ "${bin_dir}/test_output.txt" output) file(READ "${bin_dir}/test_error.txt" error) file(READ "${config_file}" config_file_content) -set(output_error_message - "\nCPack output: '${output}'\nCPack error: '${error}';\nCPack result: '${PACKAGING_RESULT}';\nconfig file: '${config_file_content}'") +string(REPLACE "\n" "\n cpack-out> " cpack_out "\n${output}") +string(REPLACE "\n" "\n cpack-err> " cpack_err "\n${error}") +string(REPLACE "\n" "\n cpack-res> " cpack_res "\n${PACKAGING_RESULT}") +string(REPLACE "\n" "\n cpack-cfg> " cpack_cfg "\n${config_file_content}") +string(CONCAT output_error_message + "CPack output:${cpack_out}\n" + "CPack error:${cpack_err}\n" + "CPack result:${cpack_res}\n" + "CPack config file:${cpack_cfg}" + ) # generate default expected files data include("${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/ExpectedFiles.cmake") @@ -74,22 +82,22 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) string(REPLACE "\n" "\n actual> " msg_actual "\n${PACKAGE_CONTENT}") string(REPLACE "\n" "\n expect> " msg_expected "\n${EXPECTED_FILE_CONTENT_${file_no_}}") message(FATAL_ERROR - "Unexpected file content for file No. '${file_no_}'!\n" + "Unexpected file content for file ${file_no_}!\n" "The content was:${msg_actual}\n" "which does not match:${msg_expected}\n" "${output_error_message}") endif() elseif(foundFilescount_ EQUAL 0) message(FATAL_ERROR - "Found no files for file No. '${file_no_}'!" - " Globbing expression: '${EXPECTED_FILE_${file_no_}}'" + "Found no files for file ${file_no_}!\n" + "Globbing expression:\n '${EXPECTED_FILE_${file_no_}}'\n" "${output_error_message}") else() message(FATAL_ERROR - "Found more than one file for file No. '${file_no_}'!" - " Found files count '${foundFilesCount_}'." - " Files: '${FOUND_FILE_${file_no_}}'" - " Globbing expression: '${EXPECTED_FILE_${file_no_}}'" + "Found more than one file for file ${file_no_}!\n" + "Found files count '${foundFilesCount_}'.\n" + "Files:\n '${FOUND_FILE_${file_no_}}'\n" + "Globbing expression:\n '${EXPECTED_FILE_${file_no_}}'\n" "${output_error_message}") endif() endforeach() @@ -105,7 +113,8 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) if(NOT foundFilesCount_ EQUAL allFoundFilesCount_) message(FATAL_ERROR - "Found more files than expected! Found files: '${allFoundFiles_}'" + "Found more files than expected!\n" + "Found files:\n '${allFoundFiles_}'\n" "${output_error_message}") endif() @@ -116,8 +125,9 @@ if(NOT EXPECTED_FILES_COUNT EQUAL 0) if(found_ EQUAL -1) message(FATAL_ERROR - "Expected files don't match found files! Found files:" - " '${allFoundFiles_}'" + "Expected files don't match found files!\n" + "Found files:\n" + " '${allFoundFiles_}'\n" "${output_error_message}") endif() endforeach() @@ -127,7 +137,7 @@ else() file(GLOB checkMissingFiles_ RELATIVE "${bin_dir}" "${missing_file_glob_}") if(checkMissingFiles_) - message(FATAL_ERROR "Unexpected files found: '${checkMissingFiles_}'" + message(FATAL_ERROR "Unexpected files found:\n '${checkMissingFiles_}'\n" "${output_error_message}") endif() endforeach() -- cgit v0.12 From ee909a8e8b785b68c6a14fd52cc12b1841051a7d Mon Sep 17 00:00:00 2001 From: liblzma upstream Date: Tue, 17 Mar 2020 16:27:42 +0200 Subject: liblzma 2020-03-17 (2327a461) Code extracted from: https://git.tukaani.org/xz.git at commit 2327a461e1afce862c22269b80d3517801103c1b (v5.2.5). --- common/mythread.h | 521 +++++++++++++++++++++++++++++ common/sysdefs.h | 11 +- common/tuklib_common.h | 71 ++++ common/tuklib_config.h | 7 + common/tuklib_cpucores.c | 100 ++++++ common/tuklib_cpucores.h | 23 ++ common/tuklib_integer.h | 520 +++++++++++++++++++--------- liblzma/api/lzma.h | 5 +- liblzma/api/lzma/block.h | 2 +- liblzma/api/lzma/filter.h | 7 +- liblzma/api/lzma/hardware.h | 2 +- liblzma/api/lzma/lzma12.h | 2 +- liblzma/api/lzma/version.h | 2 +- liblzma/api/lzma/vli.h | 2 +- liblzma/check/crc32_fast.c | 4 +- liblzma/check/crc32_table.c | 3 + liblzma/check/crc64_fast.c | 4 +- liblzma/check/crc64_table.c | 3 + liblzma/common/alone_decoder.c | 3 +- liblzma/common/alone_encoder.c | 9 +- liblzma/common/block_header_decoder.c | 4 +- liblzma/common/block_header_encoder.c | 2 +- liblzma/common/block_util.c | 2 +- liblzma/common/common.c | 8 +- liblzma/common/filter_common.h | 2 +- liblzma/common/filter_decoder.h | 2 +- liblzma/common/filter_flags_encoder.c | 2 +- liblzma/common/hardware_physmem.c | 2 +- liblzma/common/index.c | 8 +- liblzma/common/memcmplen.h | 19 +- liblzma/common/stream_encoder_mt.c | 4 +- liblzma/common/stream_flags_decoder.c | 6 +- liblzma/common/stream_flags_encoder.c | 8 +- liblzma/common/vli_decoder.c | 2 +- liblzma/delta/delta_decoder.c | 2 +- liblzma/lz/lz_decoder.c | 17 +- liblzma/lz/lz_encoder_hash.h | 2 +- liblzma/lz/lz_encoder_mf.c | 2 +- liblzma/lzma/fastpos.h | 2 +- liblzma/lzma/fastpos_tablegen.c | 1 - liblzma/lzma/lzma2_decoder.c | 8 +- liblzma/lzma/lzma_common.h | 3 +- liblzma/lzma/lzma_decoder.c | 18 +- liblzma/lzma/lzma_encoder.c | 2 +- liblzma/lzma/lzma_encoder_optimum_normal.c | 16 +- liblzma/lzma/lzma_encoder_private.h | 3 +- liblzma/simple/arm.c | 6 +- liblzma/simple/armthumb.c | 8 +- liblzma/simple/ia64.c | 2 +- liblzma/simple/powerpc.c | 9 +- liblzma/simple/simple_coder.c | 10 +- liblzma/simple/simple_decoder.c | 2 +- liblzma/simple/simple_encoder.c | 2 +- liblzma/simple/x86.c | 2 +- 54 files changed, 1216 insertions(+), 273 deletions(-) create mode 100644 common/mythread.h create mode 100644 common/tuklib_common.h create mode 100644 common/tuklib_config.h create mode 100644 common/tuklib_cpucores.c create mode 100644 common/tuklib_cpucores.h diff --git a/common/mythread.h b/common/mythread.h new file mode 100644 index 0000000..be22654 --- /dev/null +++ b/common/mythread.h @@ -0,0 +1,521 @@ +/////////////////////////////////////////////////////////////////////////////// +// +/// \file mythread.h +/// \brief Some threading related helper macros and functions +// +// Author: Lasse Collin +// +// This file has been put into the public domain. +// You can do whatever you want with this file. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef MYTHREAD_H +#define MYTHREAD_H + +#include "sysdefs.h" + +// If any type of threading is enabled, #define MYTHREAD_ENABLED. +#if defined(MYTHREAD_POSIX) || defined(MYTHREAD_WIN95) \ + || defined(MYTHREAD_VISTA) +# define MYTHREAD_ENABLED 1 +#endif + + +#ifdef MYTHREAD_ENABLED + +//////////////////////////////////////// +// Shared between all threading types // +//////////////////////////////////////// + +// Locks a mutex for a duration of a block. +// +// Perform mythread_mutex_lock(&mutex) in the beginning of a block +// and mythread_mutex_unlock(&mutex) at the end of the block. "break" +// may be used to unlock the mutex and jump out of the block. +// mythread_sync blocks may be nested. +// +// Example: +// +// mythread_sync(mutex) { +// foo(); +// if (some_error) +// break; // Skips bar() +// bar(); +// } +// +// At least GCC optimizes the loops completely away so it doesn't slow +// things down at all compared to plain mythread_mutex_lock(&mutex) +// and mythread_mutex_unlock(&mutex) calls. +// +#define mythread_sync(mutex) mythread_sync_helper1(mutex, __LINE__) +#define mythread_sync_helper1(mutex, line) mythread_sync_helper2(mutex, line) +#define mythread_sync_helper2(mutex, line) \ + for (unsigned int mythread_i_ ## line = 0; \ + mythread_i_ ## line \ + ? (mythread_mutex_unlock(&(mutex)), 0) \ + : (mythread_mutex_lock(&(mutex)), 1); \ + mythread_i_ ## line = 1) \ + for (unsigned int mythread_j_ ## line = 0; \ + !mythread_j_ ## line; \ + mythread_j_ ## line = 1) +#endif + + +#if !defined(MYTHREAD_ENABLED) + +////////////////// +// No threading // +////////////////// + +// Calls the given function once. This isn't thread safe. +#define mythread_once(func) \ +do { \ + static bool once_ = false; \ + if (!once_) { \ + func(); \ + once_ = true; \ + } \ +} while (0) + + +#if !(defined(_WIN32) && !defined(__CYGWIN__)) +// Use sigprocmask() to set the signal mask in single-threaded programs. +#include + +static inline void +mythread_sigmask(int how, const sigset_t *restrict set, + sigset_t *restrict oset) +{ + int ret = sigprocmask(how, set, oset); + assert(ret == 0); + (void)ret; +} +#endif + + +#elif defined(MYTHREAD_POSIX) + +//////////////////// +// Using pthreads // +//////////////////// + +#include +#include +#include +#include +#include + +#define MYTHREAD_RET_TYPE void * +#define MYTHREAD_RET_VALUE NULL + +typedef pthread_t mythread; +typedef pthread_mutex_t mythread_mutex; + +typedef struct { + pthread_cond_t cond; +#ifdef HAVE_CLOCK_GETTIME + // Clock ID (CLOCK_REALTIME or CLOCK_MONOTONIC) associated with + // the condition variable. + clockid_t clk_id; +#endif +} mythread_cond; + +typedef struct timespec mythread_condtime; + + +// Calls the given function once in a thread-safe way. +#define mythread_once(func) \ + do { \ + static pthread_once_t once_ = PTHREAD_ONCE_INIT; \ + pthread_once(&once_, &func); \ + } while (0) + + +// Use pthread_sigmask() to set the signal mask in multi-threaded programs. +// Do nothing on OpenVMS since it lacks pthread_sigmask(). +static inline void +mythread_sigmask(int how, const sigset_t *restrict set, + sigset_t *restrict oset) +{ +#ifdef __VMS + (void)how; + (void)set; + (void)oset; +#else + int ret = pthread_sigmask(how, set, oset); + assert(ret == 0); + (void)ret; +#endif +} + + +// Creates a new thread with all signals blocked. Returns zero on success +// and non-zero on error. +static inline int +mythread_create(mythread *thread, void *(*func)(void *arg), void *arg) +{ + sigset_t old; + sigset_t all; + sigfillset(&all); + + mythread_sigmask(SIG_SETMASK, &all, &old); + const int ret = pthread_create(thread, NULL, func, arg); + mythread_sigmask(SIG_SETMASK, &old, NULL); + + return ret; +} + +// Joins a thread. Returns zero on success and non-zero on error. +static inline int +mythread_join(mythread thread) +{ + return pthread_join(thread, NULL); +} + + +// Initiatlizes a mutex. Returns zero on success and non-zero on error. +static inline int +mythread_mutex_init(mythread_mutex *mutex) +{ + return pthread_mutex_init(mutex, NULL); +} + +static inline void +mythread_mutex_destroy(mythread_mutex *mutex) +{ + int ret = pthread_mutex_destroy(mutex); + assert(ret == 0); + (void)ret; +} + +static inline void +mythread_mutex_lock(mythread_mutex *mutex) +{ + int ret = pthread_mutex_lock(mutex); + assert(ret == 0); + (void)ret; +} + +static inline void +mythread_mutex_unlock(mythread_mutex *mutex) +{ + int ret = pthread_mutex_unlock(mutex); + assert(ret == 0); + (void)ret; +} + + +// Initializes a condition variable. +// +// Using CLOCK_MONOTONIC instead of the default CLOCK_REALTIME makes the +// timeout in pthread_cond_timedwait() work correctly also if system time +// is suddenly changed. Unfortunately CLOCK_MONOTONIC isn't available +// everywhere while the default CLOCK_REALTIME is, so the default is +// used if CLOCK_MONOTONIC isn't available. +// +// If clock_gettime() isn't available at all, gettimeofday() will be used. +static inline int +mythread_cond_init(mythread_cond *mycond) +{ +#ifdef HAVE_CLOCK_GETTIME + // NOTE: HAVE_DECL_CLOCK_MONOTONIC is always defined to 0 or 1. +# if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && HAVE_DECL_CLOCK_MONOTONIC + struct timespec ts; + pthread_condattr_t condattr; + + // POSIX doesn't seem to *require* that pthread_condattr_setclock() + // will fail if given an unsupported clock ID. Test that + // CLOCK_MONOTONIC really is supported using clock_gettime(). + if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0 + && pthread_condattr_init(&condattr) == 0) { + int ret = pthread_condattr_setclock( + &condattr, CLOCK_MONOTONIC); + if (ret == 0) + ret = pthread_cond_init(&mycond->cond, &condattr); + + pthread_condattr_destroy(&condattr); + + if (ret == 0) { + mycond->clk_id = CLOCK_MONOTONIC; + return 0; + } + } + + // If anything above fails, fall back to the default CLOCK_REALTIME. + // POSIX requires that all implementations of clock_gettime() must + // support at least CLOCK_REALTIME. +# endif + + mycond->clk_id = CLOCK_REALTIME; +#endif + + return pthread_cond_init(&mycond->cond, NULL); +} + +static inline void +mythread_cond_destroy(mythread_cond *cond) +{ + int ret = pthread_cond_destroy(&cond->cond); + assert(ret == 0); + (void)ret; +} + +static inline void +mythread_cond_signal(mythread_cond *cond) +{ + int ret = pthread_cond_signal(&cond->cond); + assert(ret == 0); + (void)ret; +} + +static inline void +mythread_cond_wait(mythread_cond *cond, mythread_mutex *mutex) +{ + int ret = pthread_cond_wait(&cond->cond, mutex); + assert(ret == 0); + (void)ret; +} + +// Waits on a condition or until a timeout expires. If the timeout expires, +// non-zero is returned, otherwise zero is returned. +static inline int +mythread_cond_timedwait(mythread_cond *cond, mythread_mutex *mutex, + const mythread_condtime *condtime) +{ + int ret = pthread_cond_timedwait(&cond->cond, mutex, condtime); + assert(ret == 0 || ret == ETIMEDOUT); + return ret; +} + +// Sets condtime to the absolute time that is timeout_ms milliseconds +// in the future. The type of the clock to use is taken from cond. +static inline void +mythread_condtime_set(mythread_condtime *condtime, const mythread_cond *cond, + uint32_t timeout_ms) +{ + condtime->tv_sec = timeout_ms / 1000; + condtime->tv_nsec = (timeout_ms % 1000) * 1000000; + +#ifdef HAVE_CLOCK_GETTIME + struct timespec now; + int ret = clock_gettime(cond->clk_id, &now); + assert(ret == 0); + (void)ret; + + condtime->tv_sec += now.tv_sec; + condtime->tv_nsec += now.tv_nsec; +#else + (void)cond; + + struct timeval now; + gettimeofday(&now, NULL); + + condtime->tv_sec += now.tv_sec; + condtime->tv_nsec += now.tv_usec * 1000L; +#endif + + // tv_nsec must stay in the range [0, 999_999_999]. + if (condtime->tv_nsec >= 1000000000L) { + condtime->tv_nsec -= 1000000000L; + ++condtime->tv_sec; + } +} + + +#elif defined(MYTHREAD_WIN95) || defined(MYTHREAD_VISTA) + +///////////////////// +// Windows threads // +///////////////////// + +#define WIN32_LEAN_AND_MEAN +#ifdef MYTHREAD_VISTA +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 +#endif +#include +#include + +#define MYTHREAD_RET_TYPE unsigned int __stdcall +#define MYTHREAD_RET_VALUE 0 + +typedef HANDLE mythread; +typedef CRITICAL_SECTION mythread_mutex; + +#ifdef MYTHREAD_WIN95 +typedef HANDLE mythread_cond; +#else +typedef CONDITION_VARIABLE mythread_cond; +#endif + +typedef struct { + // Tick count (milliseconds) in the beginning of the timeout. + // NOTE: This is 32 bits so it wraps around after 49.7 days. + // Multi-day timeouts may not work as expected. + DWORD start; + + // Length of the timeout in milliseconds. The timeout expires + // when the current tick count minus "start" is equal or greater + // than "timeout". + DWORD timeout; +} mythread_condtime; + + +// mythread_once() is only available with Vista threads. +#ifdef MYTHREAD_VISTA +#define mythread_once(func) \ + do { \ + static INIT_ONCE once_ = INIT_ONCE_STATIC_INIT; \ + BOOL pending_; \ + if (!InitOnceBeginInitialize(&once_, 0, &pending_, NULL)) \ + abort(); \ + if (pending_) \ + func(); \ + if (!InitOnceComplete(&once, 0, NULL)) \ + abort(); \ + } while (0) +#endif + + +// mythread_sigmask() isn't available on Windows. Even a dummy version would +// make no sense because the other POSIX signal functions are missing anyway. + + +static inline int +mythread_create(mythread *thread, + unsigned int (__stdcall *func)(void *arg), void *arg) +{ + uintptr_t ret = _beginthreadex(NULL, 0, func, arg, 0, NULL); + if (ret == 0) + return -1; + + *thread = (HANDLE)ret; + return 0; +} + +static inline int +mythread_join(mythread thread) +{ + int ret = 0; + + if (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0) + ret = -1; + + if (!CloseHandle(thread)) + ret = -1; + + return ret; +} + + +static inline int +mythread_mutex_init(mythread_mutex *mutex) +{ + InitializeCriticalSection(mutex); + return 0; +} + +static inline void +mythread_mutex_destroy(mythread_mutex *mutex) +{ + DeleteCriticalSection(mutex); +} + +static inline void +mythread_mutex_lock(mythread_mutex *mutex) +{ + EnterCriticalSection(mutex); +} + +static inline void +mythread_mutex_unlock(mythread_mutex *mutex) +{ + LeaveCriticalSection(mutex); +} + + +static inline int +mythread_cond_init(mythread_cond *cond) +{ +#ifdef MYTHREAD_WIN95 + *cond = CreateEvent(NULL, FALSE, FALSE, NULL); + return *cond == NULL ? -1 : 0; +#else + InitializeConditionVariable(cond); + return 0; +#endif +} + +static inline void +mythread_cond_destroy(mythread_cond *cond) +{ +#ifdef MYTHREAD_WIN95 + CloseHandle(*cond); +#else + (void)cond; +#endif +} + +static inline void +mythread_cond_signal(mythread_cond *cond) +{ +#ifdef MYTHREAD_WIN95 + SetEvent(*cond); +#else + WakeConditionVariable(cond); +#endif +} + +static inline void +mythread_cond_wait(mythread_cond *cond, mythread_mutex *mutex) +{ +#ifdef MYTHREAD_WIN95 + LeaveCriticalSection(mutex); + WaitForSingleObject(*cond, INFINITE); + EnterCriticalSection(mutex); +#else + BOOL ret = SleepConditionVariableCS(cond, mutex, INFINITE); + assert(ret); + (void)ret; +#endif +} + +static inline int +mythread_cond_timedwait(mythread_cond *cond, mythread_mutex *mutex, + const mythread_condtime *condtime) +{ +#ifdef MYTHREAD_WIN95 + LeaveCriticalSection(mutex); +#endif + + DWORD elapsed = GetTickCount() - condtime->start; + DWORD timeout = elapsed >= condtime->timeout + ? 0 : condtime->timeout - elapsed; + +#ifdef MYTHREAD_WIN95 + DWORD ret = WaitForSingleObject(*cond, timeout); + assert(ret == WAIT_OBJECT_0 || ret == WAIT_TIMEOUT); + + EnterCriticalSection(mutex); + + return ret == WAIT_TIMEOUT; +#else + BOOL ret = SleepConditionVariableCS(cond, mutex, timeout); + assert(ret || GetLastError() == ERROR_TIMEOUT); + return !ret; +#endif +} + +static inline void +mythread_condtime_set(mythread_condtime *condtime, const mythread_cond *cond, + uint32_t timeout) +{ + (void)cond; + condtime->start = GetTickCount(); + condtime->timeout = timeout; +} + +#endif + +#endif diff --git a/common/sysdefs.h b/common/sysdefs.h index e056ca4..df7ecf4 100644 --- a/common/sysdefs.h +++ b/common/sysdefs.h @@ -44,9 +44,7 @@ // Some pre-C99 systems have SIZE_MAX in limits.h instead of stdint.h. The // limits are also used to figure out some macros missing from pre-C99 systems. -#ifdef HAVE_LIMITS_H -# include -#endif +#include // Be more compatible with systems that have non-conforming inttypes.h. // We assume that int is 32-bit and that long is either 32-bit or 64-bit. @@ -153,9 +151,7 @@ typedef unsigned char _Bool; // string.h should be enough but let's include strings.h and memory.h too if // they exists, since that shouldn't do any harm, but may improve portability. -#ifdef HAVE_STRING_H -# include -#endif +#include #ifdef HAVE_STRINGS_H # include @@ -193,7 +189,8 @@ typedef unsigned char _Bool; # define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) #endif -#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4 +#if defined(__GNUC__) \ + && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4) # define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x))) #else # define lzma_attr_alloc_size(x) diff --git a/common/tuklib_common.h b/common/tuklib_common.h new file mode 100644 index 0000000..31fbab5 --- /dev/null +++ b/common/tuklib_common.h @@ -0,0 +1,71 @@ +/////////////////////////////////////////////////////////////////////////////// +// +/// \file tuklib_common.h +/// \brief Common definitions for tuklib modules +// +// Author: Lasse Collin +// +// This file has been put into the public domain. +// You can do whatever you want with this file. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef TUKLIB_COMMON_H +#define TUKLIB_COMMON_H + +// The config file may be replaced by a package-specific file. +// It should include at least stddef.h, inttypes.h, and limits.h. +#include "tuklib_config.h" + +// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by +// the tuklib modules. If you use a tuklib module in a library, +// you should use TUKLIB_SYMBOL_PREFIX to make sure that there +// are no symbol conflicts in case someone links your library +// into application that also uses the same tuklib module. +#ifndef TUKLIB_SYMBOL_PREFIX +# define TUKLIB_SYMBOL_PREFIX +#endif + +#define TUKLIB_CAT_X(a, b) a ## b +#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b) + +#ifndef TUKLIB_SYMBOL +# define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym) +#endif + +#ifndef TUKLIB_DECLS_BEGIN +# ifdef __cplusplus +# define TUKLIB_DECLS_BEGIN extern "C" { +# else +# define TUKLIB_DECLS_BEGIN +# endif +#endif + +#ifndef TUKLIB_DECLS_END +# ifdef __cplusplus +# define TUKLIB_DECLS_END } +# else +# define TUKLIB_DECLS_END +# endif +#endif + +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define TUKLIB_GNUC_REQ(major, minor) \ + ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \ + || __GNUC__ > (major)) +#else +# define TUKLIB_GNUC_REQ(major, minor) 0 +#endif + +#if TUKLIB_GNUC_REQ(2, 5) +# define tuklib_attr_noreturn __attribute__((__noreturn__)) +#else +# define tuklib_attr_noreturn +#endif + +#if (defined(_WIN32) && !defined(__CYGWIN__)) \ + || defined(__OS2__) || defined(__MSDOS__) +# define TUKLIB_DOSLIKE 1 +#endif + +#endif diff --git a/common/tuklib_config.h b/common/tuklib_config.h new file mode 100644 index 0000000..549cb24 --- /dev/null +++ b/common/tuklib_config.h @@ -0,0 +1,7 @@ +#ifdef HAVE_CONFIG_H +# include "sysdefs.h" +#else +# include +# include +# include +#endif diff --git a/common/tuklib_cpucores.c b/common/tuklib_cpucores.c new file mode 100644 index 0000000..cc968dd --- /dev/null +++ b/common/tuklib_cpucores.c @@ -0,0 +1,100 @@ +/////////////////////////////////////////////////////////////////////////////// +// +/// \file tuklib_cpucores.c +/// \brief Get the number of CPU cores online +// +// Author: Lasse Collin +// +// This file has been put into the public domain. +// You can do whatever you want with this file. +// +/////////////////////////////////////////////////////////////////////////////// + +#include "tuklib_cpucores.h" + +#if defined(_WIN32) || defined(__CYGWIN__) +# ifndef _WIN32_WINNT +# define _WIN32_WINNT 0x0500 +# endif +# include + +// glibc >= 2.9 +#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY) +# include + +// FreeBSD +#elif defined(TUKLIB_CPUCORES_CPUSET) +# include +# include + +#elif defined(TUKLIB_CPUCORES_SYSCTL) +# ifdef HAVE_SYS_PARAM_H +# include +# endif +# include + +#elif defined(TUKLIB_CPUCORES_SYSCONF) +# include + +// HP-UX +#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC) +# include +# include +#endif + + +extern uint32_t +tuklib_cpucores(void) +{ + uint32_t ret = 0; + +#if defined(_WIN32) || defined(__CYGWIN__) + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + ret = sysinfo.dwNumberOfProcessors; + +#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY) + cpu_set_t cpu_mask; + if (sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask) == 0) + ret = (uint32_t)CPU_COUNT(&cpu_mask); + +#elif defined(TUKLIB_CPUCORES_CPUSET) + cpuset_t set; + if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, + sizeof(set), &set) == 0) { +# ifdef CPU_COUNT + ret = (uint32_t)CPU_COUNT(&set); +# else + for (unsigned i = 0; i < CPU_SETSIZE; ++i) + if (CPU_ISSET(i, &set)) + ++ret; +# endif + } + +#elif defined(TUKLIB_CPUCORES_SYSCTL) + int name[2] = { CTL_HW, HW_NCPU }; + int cpus; + size_t cpus_size = sizeof(cpus); + if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1 + && cpus_size == sizeof(cpus) && cpus > 0) + ret = (uint32_t)cpus; + +#elif defined(TUKLIB_CPUCORES_SYSCONF) +# ifdef _SC_NPROCESSORS_ONLN + // Most systems + const long cpus = sysconf(_SC_NPROCESSORS_ONLN); +# else + // IRIX + const long cpus = sysconf(_SC_NPROC_ONLN); +# endif + if (cpus > 0) + ret = (uint32_t)cpus; + +#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC) + struct pst_dynamic pst; + if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1) + ret = (uint32_t)pst.psd_proc_cnt; +#endif + + return ret; +} diff --git a/common/tuklib_cpucores.h b/common/tuklib_cpucores.h new file mode 100644 index 0000000..be1ce1c --- /dev/null +++ b/common/tuklib_cpucores.h @@ -0,0 +1,23 @@ +/////////////////////////////////////////////////////////////////////////////// +// +/// \file tuklib_cpucores.h +/// \brief Get the number of CPU cores online +// +// Author: Lasse Collin +// +// This file has been put into the public domain. +// You can do whatever you want with this file. +// +/////////////////////////////////////////////////////////////////////////////// + +#ifndef TUKLIB_CPUCORES_H +#define TUKLIB_CPUCORES_H + +#include "tuklib_common.h" +TUKLIB_DECLS_BEGIN + +#define tuklib_cpucores TUKLIB_SYMBOL(tuklib_cpucores) +extern uint32_t tuklib_cpucores(void); + +TUKLIB_DECLS_END +#endif diff --git a/common/tuklib_integer.h b/common/tuklib_integer.h index b1e84d5..6f44a7a 100644 --- a/common/tuklib_integer.h +++ b/common/tuklib_integer.h @@ -6,22 +6,26 @@ /// This file provides macros or functions to do some basic integer and bit /// operations. /// -/// Endianness related integer operations (XX = 16, 32, or 64; Y = b or l): -/// - Byte swapping: bswapXX(num) -/// - Byte order conversions to/from native: convXXYe(num) -/// - Aligned reads: readXXYe(ptr) -/// - Aligned writes: writeXXYe(ptr, num) -/// - Unaligned reads (16/32-bit only): unaligned_readXXYe(ptr) -/// - Unaligned writes (16/32-bit only): unaligned_writeXXYe(ptr, num) +/// Native endian inline functions (XX = 16, 32, or 64): +/// - Unaligned native endian reads: readXXne(ptr) +/// - Unaligned native endian writes: writeXXne(ptr, num) +/// - Aligned native endian reads: aligned_readXXne(ptr) +/// - Aligned native endian writes: aligned_writeXXne(ptr, num) /// -/// Since they can macros, the arguments should have no side effects since -/// they may be evaluated more than once. +/// Endianness-converting integer operations (these can be macros!) +/// (XX = 16, 32, or 64; Y = b or l): +/// - Byte swapping: bswapXX(num) +/// - Byte order conversions to/from native (byteswaps if Y isn't +/// the native endianness): convXXYe(num) +/// - Unaligned reads (16/32-bit only): readXXYe(ptr) +/// - Unaligned writes (16/32-bit only): writeXXYe(ptr, num) +/// - Aligned reads: aligned_readXXYe(ptr) +/// - Aligned writes: aligned_writeXXYe(ptr, num) /// -/// \todo PowerPC and possibly some other architectures support -/// byte swapping load and store instructions. This file -/// doesn't take advantage of those instructions. +/// Since the above can macros, the arguments should have no side effects +/// because they may be evaluated more than once. /// -/// Bit scan operations for non-zero 32-bit integers: +/// Bit scan operations for non-zero 32-bit integers (inline functions): /// - Bit scan reverse (find highest non-zero bit): bsr32(num) /// - Count leading zeros: clz32(num) /// - Count trailing zeros: ctz32(num) @@ -42,13 +46,26 @@ #define TUKLIB_INTEGER_H #include "tuklib_common.h" +#include + +// Newer Intel C compilers require immintrin.h for _bit_scan_reverse() +// and such functions. +#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500) +# include +#endif -//////////////////////////////////////// -// Operating system specific features // -//////////////////////////////////////// +/////////////////// +// Byte swapping // +/////////////////// -#if defined(HAVE_BYTESWAP_H) +#if defined(HAVE___BUILTIN_BSWAPXX) + // GCC >= 4.8 and Clang +# define bswap16(n) __builtin_bswap16(n) +# define bswap32(n) __builtin_bswap32(n) +# define bswap64(n) __builtin_bswap64(n) + +#elif defined(HAVE_BYTESWAP_H) // glibc, uClibc, dietlibc # include # ifdef HAVE_BSWAP_16 @@ -97,45 +114,33 @@ # endif #endif - -//////////////////////////////// -// Compiler-specific features // -//////////////////////////////// - -// Newer Intel C compilers require immintrin.h for _bit_scan_reverse() -// and such functions. -#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500) -# include -#endif - - -/////////////////// -// Byte swapping // -/////////////////// - #ifndef bswap16 -# define bswap16(num) \ - (((uint16_t)(num) << 8) | ((uint16_t)(num) >> 8)) +# define bswap16(n) (uint16_t)( \ + (((n) & 0x00FFU) << 8) \ + | (((n) & 0xFF00U) >> 8) \ + ) #endif #ifndef bswap32 -# define bswap32(num) \ - ( (((uint32_t)(num) << 24) ) \ - | (((uint32_t)(num) << 8) & UINT32_C(0x00FF0000)) \ - | (((uint32_t)(num) >> 8) & UINT32_C(0x0000FF00)) \ - | (((uint32_t)(num) >> 24) ) ) +# define bswap32(n) (uint32_t)( \ + (((n) & UINT32_C(0x000000FF)) << 24) \ + | (((n) & UINT32_C(0x0000FF00)) << 8) \ + | (((n) & UINT32_C(0x00FF0000)) >> 8) \ + | (((n) & UINT32_C(0xFF000000)) >> 24) \ + ) #endif #ifndef bswap64 -# define bswap64(num) \ - ( (((uint64_t)(num) << 56) ) \ - | (((uint64_t)(num) << 40) & UINT64_C(0x00FF000000000000)) \ - | (((uint64_t)(num) << 24) & UINT64_C(0x0000FF0000000000)) \ - | (((uint64_t)(num) << 8) & UINT64_C(0x000000FF00000000)) \ - | (((uint64_t)(num) >> 8) & UINT64_C(0x00000000FF000000)) \ - | (((uint64_t)(num) >> 24) & UINT64_C(0x0000000000FF0000)) \ - | (((uint64_t)(num) >> 40) & UINT64_C(0x000000000000FF00)) \ - | (((uint64_t)(num) >> 56) ) ) +# define bswap64(n) (uint64_t)( \ + (((n) & UINT64_C(0x00000000000000FF)) << 56) \ + | (((n) & UINT64_C(0x000000000000FF00)) << 40) \ + | (((n) & UINT64_C(0x0000000000FF0000)) << 24) \ + | (((n) & UINT64_C(0x00000000FF000000)) << 8) \ + | (((n) & UINT64_C(0x000000FF00000000)) >> 8) \ + | (((n) & UINT64_C(0x0000FF0000000000)) >> 24) \ + | (((n) & UINT64_C(0x00FF000000000000)) >> 40) \ + | (((n) & UINT64_C(0xFF00000000000000)) >> 56) \ + ) #endif // Define conversion macros using the basic byte swapping macros. @@ -180,76 +185,76 @@ #endif -////////////////////////////// -// Aligned reads and writes // -////////////////////////////// - -static inline uint16_t -read16be(const uint8_t *buf) -{ - uint16_t num = *(const uint16_t *)buf; - return conv16be(num); -} +//////////////////////////////// +// Unaligned reads and writes // +//////////////////////////////// +// The traditional way of casting e.g. *(const uint16_t *)uint8_pointer +// is bad even if the uint8_pointer is properly aligned because this kind +// of casts break strict aliasing rules and result in undefined behavior. +// With unaligned pointers it's even worse: compilers may emit vector +// instructions that require aligned pointers even if non-vector +// instructions work with unaligned pointers. +// +// Using memcpy() is the standard compliant way to do unaligned access. +// Many modern compilers inline it so there is no function call overhead. +// For those compilers that don't handle the memcpy() method well, the +// old casting method (that violates strict aliasing) can be requested at +// build time. A third method, casting to a packed struct, would also be +// an option but isn't provided to keep things simpler (it's already a mess). +// Hopefully this is flexible enough in practice. static inline uint16_t -read16le(const uint8_t *buf) +read16ne(const uint8_t *buf) { - uint16_t num = *(const uint16_t *)buf; - return conv16le(num); -} - - -static inline uint32_t -read32be(const uint8_t *buf) -{ - uint32_t num = *(const uint32_t *)buf; - return conv32be(num); +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) + return *(const uint16_t *)buf; +#else + uint16_t num; + memcpy(&num, buf, sizeof(num)); + return num; +#endif } static inline uint32_t -read32le(const uint8_t *buf) -{ - uint32_t num = *(const uint32_t *)buf; - return conv32le(num); -} - - -static inline uint64_t -read64be(const uint8_t *buf) +read32ne(const uint8_t *buf) { - uint64_t num = *(const uint64_t *)buf; - return conv64be(num); +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) + return *(const uint32_t *)buf; +#else + uint32_t num; + memcpy(&num, buf, sizeof(num)); + return num; +#endif } static inline uint64_t -read64le(const uint8_t *buf) +read64ne(const uint8_t *buf) { - uint64_t num = *(const uint64_t *)buf; - return conv64le(num); +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) + return *(const uint64_t *)buf; +#else + uint64_t num; + memcpy(&num, buf, sizeof(num)); + return num; +#endif } -// NOTE: Possible byte swapping must be done in a macro to allow GCC -// to optimize byte swapping of constants when using glibc's or *BSD's -// byte swapping macros. The actual write is done in an inline function -// to make type checking of the buf pointer possible similarly to readXXYe() -// functions. - -#define write16be(buf, num) write16ne((buf), conv16be(num)) -#define write16le(buf, num) write16ne((buf), conv16le(num)) -#define write32be(buf, num) write32ne((buf), conv32be(num)) -#define write32le(buf, num) write32ne((buf), conv32le(num)) -#define write64be(buf, num) write64ne((buf), conv64be(num)) -#define write64le(buf, num) write64ne((buf), conv64le(num)) - - static inline void write16ne(uint8_t *buf, uint16_t num) { +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) *(uint16_t *)buf = num; +#else + memcpy(buf, &num, sizeof(num)); +#endif return; } @@ -257,7 +262,12 @@ write16ne(uint8_t *buf, uint16_t num) static inline void write32ne(uint8_t *buf, uint32_t num) { +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) *(uint32_t *)buf = num; +#else + memcpy(buf, &num, sizeof(num)); +#endif return; } @@ -265,90 +275,114 @@ write32ne(uint8_t *buf, uint32_t num) static inline void write64ne(uint8_t *buf, uint64_t num) { +#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \ + && defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) *(uint64_t *)buf = num; +#else + memcpy(buf, &num, sizeof(num)); +#endif return; } -//////////////////////////////// -// Unaligned reads and writes // -//////////////////////////////// - -// NOTE: TUKLIB_FAST_UNALIGNED_ACCESS indicates only support for 16-bit and -// 32-bit unaligned integer loads and stores. It's possible that 64-bit -// unaligned access doesn't work or is slower than byte-by-byte access. -// Since unaligned 64-bit is probably not needed as often as 16-bit or -// 32-bit, we simply don't support 64-bit unaligned access for now. -#ifdef TUKLIB_FAST_UNALIGNED_ACCESS -# define unaligned_read16be read16be -# define unaligned_read16le read16le -# define unaligned_read32be read32be -# define unaligned_read32le read32le -# define unaligned_write16be write16be -# define unaligned_write16le write16le -# define unaligned_write32be write32be -# define unaligned_write32le write32le - -#else - static inline uint16_t -unaligned_read16be(const uint8_t *buf) +read16be(const uint8_t *buf) { +#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) + uint16_t num = read16ne(buf); + return conv16be(num); +#else uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1]; return num; +#endif } static inline uint16_t -unaligned_read16le(const uint8_t *buf) +read16le(const uint8_t *buf) { +#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) + uint16_t num = read16ne(buf); + return conv16le(num); +#else uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8); return num; +#endif } static inline uint32_t -unaligned_read32be(const uint8_t *buf) +read32be(const uint8_t *buf) { +#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) + uint32_t num = read32ne(buf); + return conv32be(num); +#else uint32_t num = (uint32_t)buf[0] << 24; num |= (uint32_t)buf[1] << 16; num |= (uint32_t)buf[2] << 8; num |= (uint32_t)buf[3]; return num; +#endif } static inline uint32_t -unaligned_read32le(const uint8_t *buf) +read32le(const uint8_t *buf) { +#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) + uint32_t num = read32ne(buf); + return conv32le(num); +#else uint32_t num = (uint32_t)buf[0]; num |= (uint32_t)buf[1] << 8; num |= (uint32_t)buf[2] << 16; num |= (uint32_t)buf[3] << 24; return num; +#endif } +// NOTE: Possible byte swapping must be done in a macro to allow the compiler +// to optimize byte swapping of constants when using glibc's or *BSD's +// byte swapping macros. The actual write is done in an inline function +// to make type checking of the buf pointer possible. +#if defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) +# define write16be(buf, num) write16ne(buf, conv16be(num)) +# define write32be(buf, num) write32ne(buf, conv32be(num)) +#endif + +#if !defined(WORDS_BIGENDIAN) || defined(TUKLIB_FAST_UNALIGNED_ACCESS) +# define write16le(buf, num) write16ne(buf, conv16le(num)) +# define write32le(buf, num) write32ne(buf, conv32le(num)) +#endif + + +#ifndef write16be static inline void -unaligned_write16be(uint8_t *buf, uint16_t num) +write16be(uint8_t *buf, uint16_t num) { buf[0] = (uint8_t)(num >> 8); buf[1] = (uint8_t)num; return; } +#endif +#ifndef write16le static inline void -unaligned_write16le(uint8_t *buf, uint16_t num) +write16le(uint8_t *buf, uint16_t num) { buf[0] = (uint8_t)num; buf[1] = (uint8_t)(num >> 8); return; } +#endif +#ifndef write32be static inline void -unaligned_write32be(uint8_t *buf, uint32_t num) +write32be(uint8_t *buf, uint32_t num) { buf[0] = (uint8_t)(num >> 24); buf[1] = (uint8_t)(num >> 16); @@ -356,10 +390,12 @@ unaligned_write32be(uint8_t *buf, uint32_t num) buf[3] = (uint8_t)num; return; } +#endif +#ifndef write32le static inline void -unaligned_write32le(uint8_t *buf, uint32_t num) +write32le(uint8_t *buf, uint32_t num) { buf[0] = (uint8_t)num; buf[1] = (uint8_t)(num >> 8); @@ -367,10 +403,184 @@ unaligned_write32le(uint8_t *buf, uint32_t num) buf[3] = (uint8_t)(num >> 24); return; } +#endif + + +////////////////////////////// +// Aligned reads and writes // +////////////////////////////// +// Separate functions for aligned reads and writes are provided since on +// strict-align archs aligned access is much faster than unaligned access. +// +// Just like in the unaligned case, memcpy() is needed to avoid +// strict aliasing violations. However, on archs that don't support +// unaligned access the compiler cannot know that the pointers given +// to memcpy() are aligned which results in slow code. As of C11 there is +// no standard way to tell the compiler that we know that the address is +// aligned but some compilers have language extensions to do that. With +// such language extensions the memcpy() method gives excellent results. +// +// What to do on a strict-align system when no known language extentensions +// are available? Falling back to byte-by-byte access would be safe but ruin +// optimizations that have been made specifically with aligned access in mind. +// As a compromise, aligned reads will fall back to non-compliant type punning +// but aligned writes will be byte-by-byte, that is, fast reads are preferred +// over fast writes. This obviously isn't great but hopefully it's a working +// compromise for now. +// +// __builtin_assume_aligned is support by GCC >= 4.7 and clang >= 3.6. +#ifdef HAVE___BUILTIN_ASSUME_ALIGNED +# define tuklib_memcpy_aligned(dest, src, size) \ + memcpy(dest, __builtin_assume_aligned(src, size), size) +#else +# define tuklib_memcpy_aligned(dest, src, size) \ + memcpy(dest, src, size) +# ifndef TUKLIB_FAST_UNALIGNED_ACCESS +# define TUKLIB_USE_UNSAFE_ALIGNED_READS 1 +# endif #endif +static inline uint16_t +aligned_read16ne(const uint8_t *buf) +{ +#if defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) \ + || defined(TUKLIB_USE_UNSAFE_ALIGNED_READS) + return *(const uint16_t *)buf; +#else + uint16_t num; + tuklib_memcpy_aligned(&num, buf, sizeof(num)); + return num; +#endif +} + + +static inline uint32_t +aligned_read32ne(const uint8_t *buf) +{ +#if defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) \ + || defined(TUKLIB_USE_UNSAFE_ALIGNED_READS) + return *(const uint32_t *)buf; +#else + uint32_t num; + tuklib_memcpy_aligned(&num, buf, sizeof(num)); + return num; +#endif +} + + +static inline uint64_t +aligned_read64ne(const uint8_t *buf) +{ +#if defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) \ + || defined(TUKLIB_USE_UNSAFE_ALIGNED_READS) + return *(const uint64_t *)buf; +#else + uint64_t num; + tuklib_memcpy_aligned(&num, buf, sizeof(num)); + return num; +#endif +} + + +static inline void +aligned_write16ne(uint8_t *buf, uint16_t num) +{ +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING + *(uint16_t *)buf = num; +#else + tuklib_memcpy_aligned(buf, &num, sizeof(num)); +#endif + return; +} + + +static inline void +aligned_write32ne(uint8_t *buf, uint32_t num) +{ +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING + *(uint32_t *)buf = num; +#else + tuklib_memcpy_aligned(buf, &num, sizeof(num)); +#endif + return; +} + + +static inline void +aligned_write64ne(uint8_t *buf, uint64_t num) +{ +#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING + *(uint64_t *)buf = num; +#else + tuklib_memcpy_aligned(buf, &num, sizeof(num)); +#endif + return; +} + + +static inline uint16_t +aligned_read16be(const uint8_t *buf) +{ + uint16_t num = aligned_read16ne(buf); + return conv16be(num); +} + + +static inline uint16_t +aligned_read16le(const uint8_t *buf) +{ + uint16_t num = aligned_read16ne(buf); + return conv16le(num); +} + + +static inline uint32_t +aligned_read32be(const uint8_t *buf) +{ + uint32_t num = aligned_read32ne(buf); + return conv32be(num); +} + + +static inline uint32_t +aligned_read32le(const uint8_t *buf) +{ + uint32_t num = aligned_read32ne(buf); + return conv32le(num); +} + + +static inline uint64_t +aligned_read64be(const uint8_t *buf) +{ + uint64_t num = aligned_read64ne(buf); + return conv64be(num); +} + + +static inline uint64_t +aligned_read64le(const uint8_t *buf) +{ + uint64_t num = aligned_read64ne(buf); + return conv64le(num); +} + + +// These need to be macros like in the unaligned case. +#define aligned_write16be(buf, num) aligned_write16ne((buf), conv16be(num)) +#define aligned_write16le(buf, num) aligned_write16ne((buf), conv16le(num)) +#define aligned_write32be(buf, num) aligned_write32ne((buf), conv32be(num)) +#define aligned_write32le(buf, num) aligned_write32ne((buf), conv32le(num)) +#define aligned_write64be(buf, num) aligned_write64ne((buf), conv64be(num)) +#define aligned_write64le(buf, num) aligned_write64ne((buf), conv64le(num)) + + +//////////////////// +// Bit operations // +//////////////////// + static inline uint32_t bsr32(uint32_t n) { @@ -383,44 +593,42 @@ bsr32(uint32_t n) // multiple architectures. On x86, __builtin_clz() ^ 31U becomes // either plain BSR (so the XOR gets optimized away) or LZCNT and // XOR (if -march indicates that SSE4a instructions are supported). - return __builtin_clz(n) ^ 31U; + return (uint32_t)__builtin_clz(n) ^ 31U; #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) uint32_t i; __asm__("bsrl %1, %0" : "=r" (i) : "rm" (n)); return i; -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - // MSVC isn't supported by tuklib, but since this code exists, - // it doesn't hurt to have it here anyway. - uint32_t i; - _BitScanReverse((DWORD *)&i, n); +#elif defined(_MSC_VER) + unsigned long i; + _BitScanReverse(&i, n); return i; #else uint32_t i = 31; - if ((n & UINT32_C(0xFFFF0000)) == 0) { + if ((n & 0xFFFF0000) == 0) { n <<= 16; i = 15; } - if ((n & UINT32_C(0xFF000000)) == 0) { + if ((n & 0xFF000000) == 0) { n <<= 8; i -= 8; } - if ((n & UINT32_C(0xF0000000)) == 0) { + if ((n & 0xF0000000) == 0) { n <<= 4; i -= 4; } - if ((n & UINT32_C(0xC0000000)) == 0) { + if ((n & 0xC0000000) == 0) { n <<= 2; i -= 2; } - if ((n & UINT32_C(0x80000000)) == 0) + if ((n & 0x80000000) == 0) --i; return i; @@ -435,7 +643,7 @@ clz32(uint32_t n) return _bit_scan_reverse(n) ^ 31U; #elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX == UINT32_MAX - return __builtin_clz(n); + return (uint32_t)__builtin_clz(n); #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) uint32_t i; @@ -444,35 +652,35 @@ clz32(uint32_t n) : "=r" (i) : "rm" (n)); return i; -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - uint32_t i; - _BitScanReverse((DWORD *)&i, n); +#elif defined(_MSC_VER) + unsigned long i; + _BitScanReverse(&i, n); return i ^ 31U; #else uint32_t i = 0; - if ((n & UINT32_C(0xFFFF0000)) == 0) { + if ((n & 0xFFFF0000) == 0) { n <<= 16; i = 16; } - if ((n & UINT32_C(0xFF000000)) == 0) { + if ((n & 0xFF000000) == 0) { n <<= 8; i += 8; } - if ((n & UINT32_C(0xF0000000)) == 0) { + if ((n & 0xF0000000) == 0) { n <<= 4; i += 4; } - if ((n & UINT32_C(0xC0000000)) == 0) { + if ((n & 0xC0000000) == 0) { n <<= 2; i += 2; } - if ((n & UINT32_C(0x80000000)) == 0) + if ((n & 0x80000000) == 0) ++i; return i; @@ -487,42 +695,42 @@ ctz32(uint32_t n) return _bit_scan_forward(n); #elif TUKLIB_GNUC_REQ(3, 4) && UINT_MAX >= UINT32_MAX - return __builtin_ctz(n); + return (uint32_t)__builtin_ctz(n); #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) uint32_t i; __asm__("bsfl %1, %0" : "=r" (i) : "rm" (n)); return i; -#elif defined(_MSC_VER) && _MSC_VER >= 1400 - uint32_t i; - _BitScanForward((DWORD *)&i, n); +#elif defined(_MSC_VER) + unsigned long i; + _BitScanForward(&i, n); return i; #else uint32_t i = 0; - if ((n & UINT32_C(0x0000FFFF)) == 0) { + if ((n & 0x0000FFFF) == 0) { n >>= 16; i = 16; } - if ((n & UINT32_C(0x000000FF)) == 0) { + if ((n & 0x000000FF) == 0) { n >>= 8; i += 8; } - if ((n & UINT32_C(0x0000000F)) == 0) { + if ((n & 0x0000000F) == 0) { n >>= 4; i += 4; } - if ((n & UINT32_C(0x00000003)) == 0) { + if ((n & 0x00000003) == 0) { n >>= 2; i += 2; } - if ((n & UINT32_C(0x00000001)) == 0) + if ((n & 0x00000001) == 0) ++i; return i; diff --git a/liblzma/api/lzma.h b/liblzma/api/lzma.h index aa88e42..122dab8 100644 --- a/liblzma/api/lzma.h +++ b/liblzma/api/lzma.h @@ -224,7 +224,8 @@ # else # define lzma_nothrow throw() # endif -# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) +# elif defined(__GNUC__) && (__GNUC__ > 3 \ + || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) # define lzma_nothrow __attribute__((__nothrow__)) # else # define lzma_nothrow @@ -241,7 +242,7 @@ * break anything if these are sometimes enabled and sometimes not, only * affects warnings and optimizations. */ -#if __GNUC__ >= 3 +#if defined(__GNUC__) && __GNUC__ >= 3 # ifndef lzma_attribute # define lzma_attribute(attr) __attribute__(attr) # endif diff --git a/liblzma/api/lzma/block.h b/liblzma/api/lzma/block.h index 7bdcfd7..962f387 100644 --- a/liblzma/api/lzma/block.h +++ b/liblzma/api/lzma/block.h @@ -448,7 +448,7 @@ extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) * - LZMA_MEM_ERROR * - LZMA_OPTIONS_ERROR * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID - * that is not supported by this buid of liblzma. Initializing + * that is not supported by this build of liblzma. Initializing * the encoder failed. * - LZMA_PROG_ERROR */ diff --git a/liblzma/api/lzma/filter.h b/liblzma/api/lzma/filter.h index 4e78752..8c85931 100644 --- a/liblzma/api/lzma/filter.h +++ b/liblzma/api/lzma/filter.h @@ -341,9 +341,10 @@ extern LZMA_API(lzma_ret) lzma_properties_encode( * \param filter filter->id must have been set to the correct * Filter ID. filter->options doesn't need to be * initialized (it's not freed by this function). The - * decoded options will be stored to filter->options. - * filter->options is set to NULL if there are no - * properties or if an error occurs. + * decoded options will be stored in filter->options; + * it's application's responsibility to free it when + * appropriate. filter->options is set to NULL if + * there are no properties or if an error occurs. * \param allocator Custom memory allocator used to allocate the * options. Set to NULL to use the default malloc(), * and in case of an error, also free(). diff --git a/liblzma/api/lzma/hardware.h b/liblzma/api/lzma/hardware.h index 5321d9a..47481f2 100644 --- a/liblzma/api/lzma/hardware.h +++ b/liblzma/api/lzma/hardware.h @@ -6,7 +6,7 @@ * ways to limit the resource usage. Applications linking against liblzma * need to do the actual decisions how much resources to let liblzma to use. * To ease making these decisions, liblzma provides functions to find out - * the relevant capabilities of the underlaying hardware. Currently there + * the relevant capabilities of the underlying hardware. Currently there * is only a function to find out the amount of RAM, but in the future there * will be also a function to detect how many concurrent threads the system * can run. diff --git a/liblzma/api/lzma/lzma12.h b/liblzma/api/lzma/lzma12.h index 4e32fa3..df5f23b 100644 --- a/liblzma/api/lzma/lzma12.h +++ b/liblzma/api/lzma/lzma12.h @@ -301,7 +301,7 @@ typedef struct { * (2^ pb =2^2=4), which is often a good choice when there's * no better guess. * - * When the aligment is known, setting pb accordingly may reduce + * When the alignment is known, setting pb accordingly may reduce * the file size a little. E.g. with text files having one-byte * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can * improve compression slightly. For UTF-16 text, pb=1 is a good diff --git a/liblzma/api/lzma/version.h b/liblzma/api/lzma/version.h index 143c7de..2bf3eae 100644 --- a/liblzma/api/lzma/version.h +++ b/liblzma/api/lzma/version.h @@ -22,7 +22,7 @@ */ #define LZMA_VERSION_MAJOR 5 #define LZMA_VERSION_MINOR 2 -#define LZMA_VERSION_PATCH 4 +#define LZMA_VERSION_PATCH 5 #define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE #ifndef LZMA_VERSION_COMMIT diff --git a/liblzma/api/lzma/vli.h b/liblzma/api/lzma/vli.h index 9ad13f2..1b7a952 100644 --- a/liblzma/api/lzma/vli.h +++ b/liblzma/api/lzma/vli.h @@ -54,7 +54,7 @@ * * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the - * underlaying integer type. + * underlying integer type. * * lzma_vli will be uint64_t for the foreseeable future. If a bigger size * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will diff --git a/liblzma/check/crc32_fast.c b/liblzma/check/crc32_fast.c index 3de0263..eed7350 100644 --- a/liblzma/check/crc32_fast.c +++ b/liblzma/check/crc32_fast.c @@ -49,7 +49,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) // Calculate the CRC32 using the slice-by-eight algorithm. while (buf < limit) { - crc ^= *(const uint32_t *)(buf); + crc ^= aligned_read32ne(buf); buf += 4; crc = lzma_crc32_table[7][A(crc)] @@ -57,7 +57,7 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) ^ lzma_crc32_table[5][C(crc)] ^ lzma_crc32_table[4][D(crc)]; - const uint32_t tmp = *(const uint32_t *)(buf); + const uint32_t tmp = aligned_read32ne(buf); buf += 4; // At least with some compilers, it is critical for diff --git a/liblzma/check/crc32_table.c b/liblzma/check/crc32_table.c index 368874e..b11762a 100644 --- a/liblzma/check/crc32_table.c +++ b/liblzma/check/crc32_table.c @@ -12,6 +12,9 @@ #include "common.h" +// Having the declaration here silences clang -Wmissing-variable-declarations. +extern const uint32_t lzma_crc32_table[8][256]; + #ifdef WORDS_BIGENDIAN # include "crc32_table_be.h" #else diff --git a/liblzma/check/crc64_fast.c b/liblzma/check/crc64_fast.c index 52af29e..8af54cd 100644 --- a/liblzma/check/crc64_fast.c +++ b/liblzma/check/crc64_fast.c @@ -47,9 +47,9 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) while (buf < limit) { #ifdef WORDS_BIGENDIAN const uint32_t tmp = (crc >> 32) - ^ *(const uint32_t *)(buf); + ^ aligned_read32ne(buf); #else - const uint32_t tmp = crc ^ *(const uint32_t *)(buf); + const uint32_t tmp = crc ^ aligned_read32ne(buf); #endif buf += 4; diff --git a/liblzma/check/crc64_table.c b/liblzma/check/crc64_table.c index 1fbcd94..7560eb0 100644 --- a/liblzma/check/crc64_table.c +++ b/liblzma/check/crc64_table.c @@ -12,6 +12,9 @@ #include "common.h" +// Having the declaration here silences clang -Wmissing-variable-declarations. +extern const uint64_t lzma_crc64_table[4][256]; + #ifdef WORDS_BIGENDIAN # include "crc64_table_be.h" #else diff --git a/liblzma/common/alone_decoder.c b/liblzma/common/alone_decoder.c index 77d0a9b..239b230 100644 --- a/liblzma/common/alone_decoder.c +++ b/liblzma/common/alone_decoder.c @@ -50,8 +50,7 @@ typedef struct { static lzma_ret -alone_decode(void *coder_ptr, - const lzma_allocator *allocator lzma_attribute((__unused__)), +alone_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, diff --git a/liblzma/common/alone_encoder.c b/liblzma/common/alone_encoder.c index 4853cfd..96c1db7 100644 --- a/liblzma/common/alone_encoder.c +++ b/liblzma/common/alone_encoder.c @@ -1,7 +1,7 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file alone_decoder.c -/// \brief Decoder for LZMA_Alone files +/// \file alone_encoder.c +/// \brief Encoder for LZMA_Alone files // // Author: Lasse Collin // @@ -31,8 +31,7 @@ typedef struct { static lzma_ret -alone_encode(void *coder_ptr, - const lzma_allocator *allocator lzma_attribute((__unused__)), +alone_encode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, @@ -122,7 +121,7 @@ alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (d != UINT32_MAX) ++d; - unaligned_write32le(coder->header + 1, d); + write32le(coder->header + 1, d); // - Uncompressed size (always unknown and using EOPM) memset(coder->header + 1 + 4, 0xFF, 8); diff --git a/liblzma/common/block_header_decoder.c b/liblzma/common/block_header_decoder.c index 1dd982f..2e1135d 100644 --- a/liblzma/common/block_header_decoder.c +++ b/liblzma/common/block_header_decoder.c @@ -67,7 +67,7 @@ lzma_block_header_decode(lzma_block *block, const size_t in_size = block->header_size - 4; // Verify CRC32 - if (lzma_crc32(in, in_size, 0) != unaligned_read32le(in + in_size)) + if (lzma_crc32(in, in_size, 0) != read32le(in + in_size)) return LZMA_DATA_ERROR; // Check for unsupported flags. @@ -98,7 +98,7 @@ lzma_block_header_decode(lzma_block *block, block->uncompressed_size = LZMA_VLI_UNKNOWN; // Filter Flags - const size_t filter_count = (in[1] & 3) + 1; + const size_t filter_count = (in[1] & 3U) + 1; for (size_t i = 0; i < filter_count; ++i) { const lzma_ret ret = lzma_filter_flags_decode( &block->filters[i], allocator, diff --git a/liblzma/common/block_header_encoder.c b/liblzma/common/block_header_encoder.c index 5c5f542..160425d 100644 --- a/liblzma/common/block_header_encoder.c +++ b/liblzma/common/block_header_encoder.c @@ -126,7 +126,7 @@ lzma_block_header_encode(const lzma_block *block, uint8_t *out) memzero(out + out_pos, out_size - out_pos); // CRC32 - unaligned_write32le(out + out_size, lzma_crc32(out, out_size, 0)); + write32le(out + out_size, lzma_crc32(out, out_size, 0)); return LZMA_OK; } diff --git a/liblzma/common/block_util.c b/liblzma/common/block_util.c index 00c7fe8..acb3111 100644 --- a/liblzma/common/block_util.c +++ b/liblzma/common/block_util.c @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file block_header.c +/// \file block_util.c /// \brief Utility functions to handle lzma_block // // Author: Lasse Collin diff --git a/liblzma/common/common.c b/liblzma/common/common.c index 57e3f8e..cf714e5 100644 --- a/liblzma/common/common.c +++ b/liblzma/common/common.c @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file common.h +/// \file common.c /// \brief Common functions needed in many places in liblzma // // Author: Lasse Collin @@ -99,7 +99,11 @@ lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos, const size_t out_avail = out_size - *out_pos; const size_t copy_size = my_min(in_avail, out_avail); - memcpy(out + *out_pos, in + *in_pos, copy_size); + // Call memcpy() only if there is something to copy. If there is + // nothing to copy, in or out might be NULL and then the memcpy() + // call would trigger undefined behavior. + if (copy_size > 0) + memcpy(out + *out_pos, in + *in_pos, copy_size); *in_pos += copy_size; *out_pos += copy_size; diff --git a/liblzma/common/filter_common.h b/liblzma/common/filter_common.h index 42a26a2..9390305 100644 --- a/liblzma/common/filter_common.h +++ b/liblzma/common/filter_common.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file filter_common.c +/// \file filter_common.h /// \brief Filter-specific stuff common for both encoder and decoder // // Author: Lasse Collin diff --git a/liblzma/common/filter_decoder.h b/liblzma/common/filter_decoder.h index a2e255f..2dac602 100644 --- a/liblzma/common/filter_decoder.h +++ b/liblzma/common/filter_decoder.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file filter_decoder.c +/// \file filter_decoder.h /// \brief Filter ID mapping to filter-specific functions // // Author: Lasse Collin diff --git a/liblzma/common/filter_flags_encoder.c b/liblzma/common/filter_flags_encoder.c index d110566..b57b9fd 100644 --- a/liblzma/common/filter_flags_encoder.c +++ b/liblzma/common/filter_flags_encoder.c @@ -1,7 +1,7 @@ /////////////////////////////////////////////////////////////////////////////// // /// \file filter_flags_encoder.c -/// \brief Decodes a Filter Flags field +/// \brief Encodes a Filter Flags field // // Author: Lasse Collin // diff --git a/liblzma/common/hardware_physmem.c b/liblzma/common/hardware_physmem.c index 7405b65..a2bbbe2 100644 --- a/liblzma/common/hardware_physmem.c +++ b/liblzma/common/hardware_physmem.c @@ -19,7 +19,7 @@ extern LZMA_API(uint64_t) lzma_physmem(void) { // It is simpler to make lzma_physmem() a wrapper for - // tuklib_physmem() than to hack appropriate symbol visiblity + // tuklib_physmem() than to hack appropriate symbol visibility // support for the tuklib modules. return tuklib_physmem(); } diff --git a/liblzma/common/index.c b/liblzma/common/index.c index 26e4e51..a41e8f3 100644 --- a/liblzma/common/index.c +++ b/liblzma/common/index.c @@ -105,7 +105,7 @@ typedef struct { typedef struct { - /// Every index_stream is a node in the tree of Sreams. + /// Every index_stream is a node in the tree of Streams. index_tree_node node; /// Number of this Stream (first one is 1) @@ -166,7 +166,7 @@ struct lzma_index_s { lzma_vli index_list_size; /// How many Records to allocate at once in lzma_index_append(). - /// This defaults to INDEX_GROUP_SIZE but can be overriden with + /// This defaults to INDEX_GROUP_SIZE but can be overridden with /// lzma_index_prealloc(). size_t prealloc; @@ -825,8 +825,8 @@ lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src, s->groups.root = &newg->node; } - if (s->groups.rightmost == &g->node) - s->groups.rightmost = &newg->node; + assert(s->groups.rightmost == &g->node); + s->groups.rightmost = &newg->node; lzma_free(g, allocator); diff --git a/liblzma/common/memcmplen.h b/liblzma/common/memcmplen.h index c1efc9e..dcfd8d6 100644 --- a/liblzma/common/memcmplen.h +++ b/liblzma/common/memcmplen.h @@ -61,8 +61,7 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // to __builtin_clzll(). #define LZMA_MEMCMPLEN_EXTRA 8 while (len < limit) { - const uint64_t x = *(const uint64_t *)(buf1 + len) - - *(const uint64_t *)(buf2 + len); + const uint64_t x = read64ne(buf1 + len) - read64ne(buf2 + len); if (x != 0) { # if defined(_M_X64) // MSVC or Intel C compiler on Windows unsigned long tmp; @@ -99,15 +98,7 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, _mm_loadu_si128((const __m128i *)(buf2 + len)))); if (x != 0) { -# if defined(__INTEL_COMPILER) - len += _bit_scan_forward(x); -# elif defined(_MSC_VER) - unsigned long tmp; - _BitScanForward(&tmp, x); - len += tmp; -# else - len += __builtin_ctz(x); -# endif + len += ctz32(x); return my_min(len, limit); } @@ -120,8 +111,7 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // Generic 32-bit little endian method # define LZMA_MEMCMPLEN_EXTRA 4 while (len < limit) { - uint32_t x = *(const uint32_t *)(buf1 + len) - - *(const uint32_t *)(buf2 + len); + uint32_t x = read32ne(buf1 + len) - read32ne(buf2 + len); if (x != 0) { if ((x & 0xFFFF) == 0) { len += 2; @@ -143,8 +133,7 @@ lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2, // Generic 32-bit big endian method # define LZMA_MEMCMPLEN_EXTRA 4 while (len < limit) { - uint32_t x = *(const uint32_t *)(buf1 + len) - ^ *(const uint32_t *)(buf2 + len); + uint32_t x = read32ne(buf1 + len) ^ read32ne(buf2 + len); if (x != 0) { if ((x & 0xFFFF0000) == 0) { len += 2; diff --git a/liblzma/common/stream_encoder_mt.c b/liblzma/common/stream_encoder_mt.c index 2efe44c..01e4033 100644 --- a/liblzma/common/stream_encoder_mt.c +++ b/liblzma/common/stream_encoder_mt.c @@ -700,7 +700,7 @@ stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator, ret = coder->thread_error; if (ret != LZMA_OK) { assert(ret != LZMA_STREAM_END); - break; + break; // Break out of mythread_sync. } // Try to read compressed data to out[]. @@ -958,7 +958,7 @@ stream_encoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator, // Validate the filter chain so that we can give an error in this // function instead of delaying it to the first call to lzma_code(). // The memory usage calculation verifies the filter chain as - // a side effect so we take advatange of that. + // a side effect so we take advantage of that. if (lzma_raw_encoder_memusage(filters) == UINT64_MAX) return LZMA_OPTIONS_ERROR; diff --git a/liblzma/common/stream_flags_decoder.c b/liblzma/common/stream_flags_decoder.c index 1bc2f97..4e43e35 100644 --- a/liblzma/common/stream_flags_decoder.c +++ b/liblzma/common/stream_flags_decoder.c @@ -38,7 +38,7 @@ lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in) // and unsupported files. const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic), LZMA_STREAM_FLAGS_SIZE, 0); - if (crc != unaligned_read32le(in + sizeof(lzma_header_magic) + if (crc != read32le(in + sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE)) return LZMA_DATA_ERROR; @@ -67,7 +67,7 @@ lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in) // CRC32 const uint32_t crc = lzma_crc32(in + sizeof(uint32_t), sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0); - if (crc != unaligned_read32le(in)) + if (crc != read32le(in)) return LZMA_DATA_ERROR; // Stream Flags @@ -75,7 +75,7 @@ lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in) return LZMA_OPTIONS_ERROR; // Backward Size - options->backward_size = unaligned_read32le(in + sizeof(uint32_t)); + options->backward_size = read32le(in + sizeof(uint32_t)); options->backward_size = (options->backward_size + 1) * 4; return LZMA_OK; diff --git a/liblzma/common/stream_flags_encoder.c b/liblzma/common/stream_flags_encoder.c index 4e71715..b98ab17 100644 --- a/liblzma/common/stream_flags_encoder.c +++ b/liblzma/common/stream_flags_encoder.c @@ -46,8 +46,8 @@ lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out) const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic), LZMA_STREAM_FLAGS_SIZE, 0); - unaligned_write32le(out + sizeof(lzma_header_magic) - + LZMA_STREAM_FLAGS_SIZE, crc); + write32le(out + sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE, + crc); return LZMA_OK; } @@ -66,7 +66,7 @@ lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out) if (!is_backward_size_valid(options)) return LZMA_PROG_ERROR; - unaligned_write32le(out + 4, options->backward_size / 4 - 1); + write32le(out + 4, options->backward_size / 4 - 1); // Stream Flags if (stream_flags_encode(options, out + 2 * 4)) @@ -76,7 +76,7 @@ lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out) const uint32_t crc = lzma_crc32( out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0); - unaligned_write32le(out, crc); + write32le(out, crc); // Magic memcpy(out + 2 * 4 + LZMA_STREAM_FLAGS_SIZE, diff --git a/liblzma/common/vli_decoder.c b/liblzma/common/vli_decoder.c index c181828..af2799d 100644 --- a/liblzma/common/vli_decoder.c +++ b/liblzma/common/vli_decoder.c @@ -72,7 +72,7 @@ lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos, // corrupt. // // If we need bigger integers in future, old versions liblzma - // will confusingly indicate the file being corrupt istead of + // will confusingly indicate the file being corrupt instead of // unsupported. I suppose it's still better this way, because // in the foreseeable future (writing this in 2008) the only // reason why files would appear having over 63-bit integers diff --git a/liblzma/delta/delta_decoder.c b/liblzma/delta/delta_decoder.c index 6859afa..13d8a28 100644 --- a/liblzma/delta/delta_decoder.c +++ b/liblzma/delta/delta_decoder.c @@ -70,7 +70,7 @@ lzma_delta_props_decode(void **options, const lzma_allocator *allocator, return LZMA_MEM_ERROR; opt->type = LZMA_DELTA_TYPE_BYTE; - opt->dist = props[0] + 1; + opt->dist = props[0] + 1U; *options = opt; diff --git a/liblzma/lz/lz_decoder.c b/liblzma/lz/lz_decoder.c index c708644..09b5743 100644 --- a/liblzma/lz/lz_decoder.c +++ b/liblzma/lz/lz_decoder.c @@ -91,11 +91,17 @@ decode_buffer(lzma_coder *coder, in, in_pos, in_size); // Copy the decoded data from the dictionary to the out[] - // buffer. + // buffer. Do it conditionally because out can be NULL + // (in which case copy_size is always 0). Calling memcpy() + // with a null-pointer is undefined even if the third + // argument is 0. const size_t copy_size = coder->dict.pos - dict_start; assert(copy_size <= out_size - *out_pos); - memcpy(out + *out_pos, coder->dict.buf + dict_start, - copy_size); + + if (copy_size > 0) + memcpy(out + *out_pos, coder->dict.buf + dict_start, + copy_size); + *out_pos += copy_size; // Reset the dictionary if so requested by coder->lz.code(). @@ -125,8 +131,7 @@ decode_buffer(lzma_coder *coder, static lzma_ret -lz_decode(void *coder_ptr, - const lzma_allocator *allocator lzma_attribute((__unused__)), +lz_decode(void *coder_ptr, const lzma_allocator *allocator, const uint8_t *restrict in, size_t *restrict in_pos, size_t in_size, uint8_t *restrict out, size_t *restrict out_pos, size_t out_size, @@ -241,7 +246,7 @@ lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, if (lz_options.dict_size < 4096) lz_options.dict_size = 4096; - // Make dictionary size a multipe of 16. Some LZ-based decoders like + // Make dictionary size a multiple of 16. Some LZ-based decoders like // LZMA use the lowest bits lzma_dict.pos to know the alignment of the // data. Aligned buffer is also good when memcpying from the // dictionary to the output buffer, since applications are diff --git a/liblzma/lz/lz_encoder_hash.h b/liblzma/lz/lz_encoder_hash.h index 342a333..fb15c58 100644 --- a/liblzma/lz/lz_encoder_hash.h +++ b/liblzma/lz/lz_encoder_hash.h @@ -39,7 +39,7 @@ // Endianness doesn't matter in hash_2_calc() (no effect on the output). #ifdef TUKLIB_FAST_UNALIGNED_ACCESS # define hash_2_calc() \ - const uint32_t hash_value = *(const uint16_t *)(cur) + const uint32_t hash_value = read16ne(cur) #else # define hash_2_calc() \ const uint32_t hash_value \ diff --git a/liblzma/lz/lz_encoder_mf.c b/liblzma/lz/lz_encoder_mf.c index 7852077..d03657a 100644 --- a/liblzma/lz/lz_encoder_mf.c +++ b/liblzma/lz/lz_encoder_mf.c @@ -113,7 +113,7 @@ normalize(lzma_mf *mf) // may be match finders that use larger resolution than one byte. const uint32_t subvalue = (MUST_NORMALIZE_POS - mf->cyclic_size); - // & (~(UINT32_C(1) << 10) - 1); + // & ~((UINT32_C(1) << 10) - 1); for (uint32_t i = 0; i < mf->hash_count; ++i) { // If the distance is greater than the dictionary size, diff --git a/liblzma/lzma/fastpos.h b/liblzma/lzma/fastpos.h index a3feea5..cba442c 100644 --- a/liblzma/lzma/fastpos.h +++ b/liblzma/lzma/fastpos.h @@ -101,7 +101,7 @@ extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS]; (UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n))) #define fastpos_result(dist, extra, n) \ - lzma_fastpos[(dist) >> fastpos_shift(extra, n)] \ + (uint32_t)(lzma_fastpos[(dist) >> fastpos_shift(extra, n)]) \ + 2 * fastpos_shift(extra, n) diff --git a/liblzma/lzma/fastpos_tablegen.c b/liblzma/lzma/fastpos_tablegen.c index c97e6f4..d4484c8 100644 --- a/liblzma/lzma/fastpos_tablegen.c +++ b/liblzma/lzma/fastpos_tablegen.c @@ -11,7 +11,6 @@ // /////////////////////////////////////////////////////////////////////////////// -#include #include #include #include "fastpos.h" diff --git a/liblzma/lzma/lzma2_decoder.c b/liblzma/lzma/lzma2_decoder.c index 878c870..cf1b511 100644 --- a/liblzma/lzma/lzma2_decoder.c +++ b/liblzma/lzma/lzma2_decoder.c @@ -136,7 +136,7 @@ lzma2_decode(void *coder_ptr, lzma_dict *restrict dict, break; case SEQ_UNCOMPRESSED_2: - coder->uncompressed_size += in[(*in_pos)++] + 1; + coder->uncompressed_size += in[(*in_pos)++] + 1U; coder->sequence = SEQ_COMPRESSED_0; coder->lzma.set_uncompressed(coder->lzma.coder, coder->uncompressed_size); @@ -148,7 +148,7 @@ lzma2_decode(void *coder_ptr, lzma_dict *restrict dict, break; case SEQ_COMPRESSED_1: - coder->compressed_size += in[(*in_pos)++] + 1; + coder->compressed_size += in[(*in_pos)++] + 1U; coder->sequence = coder->next_sequence; break; @@ -297,8 +297,8 @@ lzma_lzma2_props_decode(void **options, const lzma_allocator *allocator, if (props[0] == 40) { opt->dict_size = UINT32_MAX; } else { - opt->dict_size = 2 | (props[0] & 1); - opt->dict_size <<= props[0] / 2 + 11; + opt->dict_size = 2 | (props[0] & 1U); + opt->dict_size <<= props[0] / 2U + 11; } opt->preset_dict = NULL; diff --git a/liblzma/lzma/lzma_common.h b/liblzma/lzma/lzma_common.h index 09efd38..9d040d9 100644 --- a/liblzma/lzma/lzma_common.h +++ b/liblzma/lzma/lzma_common.h @@ -122,7 +122,8 @@ typedef enum { /// byte; and /// - the highest literal_context_bits bits of the previous byte. #define literal_subcoder(probs, lc, lp_mask, pos, prev_byte) \ - ((probs)[(((pos) & lp_mask) << lc) + ((prev_byte) >> (8 - lc))]) + ((probs)[(((pos) & (lp_mask)) << (lc)) \ + + ((uint32_t)(prev_byte) >> (8U - (lc)))]) static inline void diff --git a/liblzma/lzma/lzma_decoder.c b/liblzma/lzma/lzma_decoder.c index d0f29b7..e605a0a 100644 --- a/liblzma/lzma/lzma_decoder.c +++ b/liblzma/lzma/lzma_decoder.c @@ -398,7 +398,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr, // ("match byte") to "len" to minimize the // number of variables we need to store // between decoder calls. - len = dict_get(&dict, rep0) << 1; + len = (uint32_t)(dict_get(&dict, rep0)) << 1; // The usage of "offset" allows omitting some // branches, which should give tiny speed @@ -569,7 +569,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr, #ifdef HAVE_SMALL do { rc_bit(probs[symbol], , - rep0 += 1 << offset, + rep0 += 1U << offset, SEQ_DIST_MODEL); } while (++offset < limit); #else @@ -577,25 +577,25 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr, case 5: assert(offset == 0); rc_bit(probs[symbol], , - rep0 += 1, + rep0 += 1U, SEQ_DIST_MODEL); ++offset; --limit; case 4: rc_bit(probs[symbol], , - rep0 += 1 << offset, + rep0 += 1U << offset, SEQ_DIST_MODEL); ++offset; --limit; case 3: rc_bit(probs[symbol], , - rep0 += 1 << offset, + rep0 += 1U << offset, SEQ_DIST_MODEL); ++offset; --limit; case 2: rc_bit(probs[symbol], , - rep0 += 1 << offset, + rep0 += 1U << offset, SEQ_DIST_MODEL); ++offset; --limit; @@ -607,7 +607,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr, // the unneeded updating of // "symbol". rc_bit_last(probs[symbol], , - rep0 += 1 << offset, + rep0 += 1U << offset, SEQ_DIST_MODEL); } #endif @@ -635,7 +635,7 @@ lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr, do { rc_bit(coder->pos_align[ symbol], , - rep0 += 1 << offset, + rep0 += 1U << offset, SEQ_ALIGN); } while (++offset < ALIGN_BITS); #else @@ -1049,7 +1049,7 @@ lzma_lzma_props_decode(void **options, const lzma_allocator *allocator, // All dictionary sizes are accepted, including zero. LZ decoder // will automatically use a dictionary at least a few KiB even if // a smaller dictionary is requested. - opt->dict_size = unaligned_read32le(props + 1); + opt->dict_size = read32le(props + 1); opt->preset_dict = NULL; opt->preset_dict_size = 0; diff --git a/liblzma/lzma/lzma_encoder.c b/liblzma/lzma/lzma_encoder.c index ba9ce69..07d2b87 100644 --- a/liblzma/lzma/lzma_encoder.c +++ b/liblzma/lzma/lzma_encoder.c @@ -663,7 +663,7 @@ lzma_lzma_props_encode(const void *options, uint8_t *out) if (lzma_lzma_lclppb_encode(opt, out)) return LZMA_PROG_ERROR; - unaligned_write32le(out + 1, opt->dict_size); + write32le(out + 1, opt->dict_size); return LZMA_OK; } diff --git a/liblzma/lzma/lzma_encoder_optimum_normal.c b/liblzma/lzma/lzma_encoder_optimum_normal.c index 59f7734..101c8d4 100644 --- a/liblzma/lzma/lzma_encoder_optimum_normal.c +++ b/liblzma/lzma/lzma_encoder_optimum_normal.c @@ -636,9 +636,10 @@ helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf, uint32_t len_test_2 = len_test + 1; const uint32_t limit = my_min(buf_avail_full, len_test_2 + nice_len); - for (; len_test_2 < limit - && buf[len_test_2] == buf_back[len_test_2]; - ++len_test_2) ; + // NOTE: len_test_2 may be greater than limit so the call to + // lzma_memcmplen() must be done conditionally. + if (len_test_2 < limit) + len_test_2 = lzma_memcmplen(buf, buf_back, len_test_2, limit); len_test_2 -= len_test + 1; @@ -732,9 +733,12 @@ helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf, const uint32_t limit = my_min(buf_avail_full, len_test_2 + nice_len); - for (; len_test_2 < limit && - buf[len_test_2] == buf_back[len_test_2]; - ++len_test_2) ; + // NOTE: len_test_2 may be greater than limit + // so the call to lzma_memcmplen() must be + // done conditionally. + if (len_test_2 < limit) + len_test_2 = lzma_memcmplen(buf, buf_back, + len_test_2, limit); len_test_2 -= len_test + 1; diff --git a/liblzma/lzma/lzma_encoder_private.h b/liblzma/lzma/lzma_encoder_private.h index a2da969..2e34aac 100644 --- a/liblzma/lzma/lzma_encoder_private.h +++ b/liblzma/lzma/lzma_encoder_private.h @@ -25,8 +25,7 @@ // MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no // reason to not use it when it is supported. #ifdef TUKLIB_FAST_UNALIGNED_ACCESS -# define not_equal_16(a, b) \ - (*(const uint16_t *)(a) != *(const uint16_t *)(b)) +# define not_equal_16(a, b) (read16ne(a) != read16ne(b)) #else # define not_equal_16(a, b) \ ((a)[0] != (b)[0] || (a)[1] != (b)[1]) diff --git a/liblzma/simple/arm.c b/liblzma/simple/arm.c index 181d0e3..ff5073a 100644 --- a/liblzma/simple/arm.c +++ b/liblzma/simple/arm.c @@ -22,9 +22,9 @@ arm_code(void *simple lzma_attribute((__unused__)), size_t i; for (i = 0; i + 4 <= size; i += 4) { if (buffer[i + 3] == 0xEB) { - uint32_t src = (buffer[i + 2] << 16) - | (buffer[i + 1] << 8) - | (buffer[i + 0]); + uint32_t src = ((uint32_t)(buffer[i + 2]) << 16) + | ((uint32_t)(buffer[i + 1]) << 8) + | (uint32_t)(buffer[i + 0]); src <<= 2; uint32_t dest; diff --git a/liblzma/simple/armthumb.c b/liblzma/simple/armthumb.c index eab4862..a8da334 100644 --- a/liblzma/simple/armthumb.c +++ b/liblzma/simple/armthumb.c @@ -23,10 +23,10 @@ armthumb_code(void *simple lzma_attribute((__unused__)), for (i = 0; i + 4 <= size; i += 2) { if ((buffer[i + 1] & 0xF8) == 0xF0 && (buffer[i + 3] & 0xF8) == 0xF8) { - uint32_t src = ((buffer[i + 1] & 0x7) << 19) - | (buffer[i + 0] << 11) - | ((buffer[i + 3] & 0x7) << 8) - | (buffer[i + 2]); + uint32_t src = (((uint32_t)(buffer[i + 1]) & 7) << 19) + | ((uint32_t)(buffer[i + 0]) << 11) + | (((uint32_t)(buffer[i + 3]) & 7) << 8) + | (uint32_t)(buffer[i + 2]); src <<= 1; diff --git a/liblzma/simple/ia64.c b/liblzma/simple/ia64.c index 580529e..6492d0a 100644 --- a/liblzma/simple/ia64.c +++ b/liblzma/simple/ia64.c @@ -70,7 +70,7 @@ ia64_code(void *simple lzma_attribute((__unused__)), inst_norm |= (uint64_t)(dest & 0x100000) << (36 - 20); - instruction &= (1 << bit_res) - 1; + instruction &= (1U << bit_res) - 1; instruction |= (inst_norm << bit_res); for (size_t j = 0; j < 6; j++) diff --git a/liblzma/simple/powerpc.c b/liblzma/simple/powerpc.c index 54dfbf1..0b60e9b 100644 --- a/liblzma/simple/powerpc.c +++ b/liblzma/simple/powerpc.c @@ -25,10 +25,11 @@ powerpc_code(void *simple lzma_attribute((__unused__)), if ((buffer[i] >> 2) == 0x12 && ((buffer[i + 3] & 3) == 1)) { - const uint32_t src = ((buffer[i + 0] & 3) << 24) - | (buffer[i + 1] << 16) - | (buffer[i + 2] << 8) - | (buffer[i + 3] & (~3)); + const uint32_t src + = (((uint32_t)(buffer[i + 0]) & 3) << 24) + | ((uint32_t)(buffer[i + 1]) << 16) + | ((uint32_t)(buffer[i + 2]) << 8) + | ((uint32_t)(buffer[i + 3]) & ~UINT32_C(3)); uint32_t dest; if (is_encoder) diff --git a/liblzma/simple/simple_coder.c b/liblzma/simple/simple_coder.c index 13ebabc..4f499be 100644 --- a/liblzma/simple/simple_coder.c +++ b/liblzma/simple/simple_coder.c @@ -118,7 +118,15 @@ simple_code(void *coder_ptr, const lzma_allocator *allocator, // coder->pos and coder->size yet. This way the coder can be // restarted if the next filter in the chain returns e.g. // LZMA_MEM_ERROR. - memcpy(out + *out_pos, coder->buffer + coder->pos, buf_avail); + // + // Do the memcpy() conditionally because out can be NULL + // (in which case buf_avail is always 0). Calling memcpy() + // with a null-pointer is undefined even if the third + // argument is 0. + if (buf_avail > 0) + memcpy(out + *out_pos, coder->buffer + coder->pos, + buf_avail); + *out_pos += buf_avail; // Copy/Encode/Decode more data to out[]. diff --git a/liblzma/simple/simple_decoder.c b/liblzma/simple/simple_decoder.c index 1d864f2..dc4d241 100644 --- a/liblzma/simple/simple_decoder.c +++ b/liblzma/simple/simple_decoder.c @@ -28,7 +28,7 @@ lzma_simple_props_decode(void **options, const lzma_allocator *allocator, if (opt == NULL) return LZMA_MEM_ERROR; - opt->start_offset = unaligned_read32le(props); + opt->start_offset = read32le(props); // Don't leave an options structure allocated if start_offset is zero. if (opt->start_offset == 0) diff --git a/liblzma/simple/simple_encoder.c b/liblzma/simple/simple_encoder.c index 8aa463b..d2cc03e 100644 --- a/liblzma/simple/simple_encoder.c +++ b/liblzma/simple/simple_encoder.c @@ -32,7 +32,7 @@ lzma_simple_props_encode(const void *options, uint8_t *out) if (opt == NULL || opt->start_offset == 0) return LZMA_OK; - unaligned_write32le(out, opt->start_offset); + write32le(out, opt->start_offset); return LZMA_OK; } diff --git a/liblzma/simple/x86.c b/liblzma/simple/x86.c index 0b14807..0e78909 100644 --- a/liblzma/simple/x86.c +++ b/liblzma/simple/x86.c @@ -97,7 +97,7 @@ x86_code(void *simple_ptr, uint32_t now_pos, bool is_encoder, if (!Test86MSByte(b)) break; - src = dest ^ ((1 << (32 - i * 8)) - 1); + src = dest ^ ((1U << (32 - i * 8)) - 1); } buffer[buffer_pos + 4] -- cgit v0.12 From 5380d858ff4cb21ae1a8777a9b721af97f598c37 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Fri, 16 Apr 2021 18:03:22 +0200 Subject: liblzma: Enable multi threaded stream encoding support --- CMakeLists.txt | 1 + Help/cpack_gen/archive.rst | 7 ++++--- Help/release/dev/lzma-threads.rst | 7 +++++++ Modules/CPack.cmake | 7 ++++--- Utilities/cmliblzma/CMakeLists.txt | 12 ++++++++++++ Utilities/cmliblzma/liblzma/common/common.h | 1 + 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/lzma-threads.rst diff --git a/CMakeLists.txt b/CMakeLists.txt index 045a283..4f03c39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -579,6 +579,7 @@ macro (CMAKE_BUILD_UTILITIES) set(LIBLZMA_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api") set(LIBLZMA_LIBRARY cmliblzma) + set(HAVE_LZMA_STREAM_ENCODER_MT 1) endif() endif() diff --git a/Help/cpack_gen/archive.rst b/Help/cpack_gen/archive.rst index b941812..47e8e13 100644 --- a/Help/cpack_gen/archive.rst +++ b/Help/cpack_gen/archive.rst @@ -82,7 +82,8 @@ CPack generators which are essentially archives at their core. These include: See also the :variable:`CPACK_THREADS` variable. -.. note:: + .. versionadded:: 3.21 - Official CMake binaries available on ``cmake.org`` ship with a ``liblzma`` - that does not support parallel compression. + Official CMake binaries available on ``cmake.org`` now ship + with a ``liblzma`` that supports parallel compression. + Older versions did not. diff --git a/Help/release/dev/lzma-threads.rst b/Help/release/dev/lzma-threads.rst new file mode 100644 index 0000000..a481cfa --- /dev/null +++ b/Help/release/dev/lzma-threads.rst @@ -0,0 +1,7 @@ +lzma-threads +------------ + +* The precompiled binaries provided on + `cmake.org `_ now support + ``liblzma`` multi-threading. See the :variable:`CPACK_THREADS` and + :variable:`CPACK_ARCHIVE_THREADS` variables. diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index ef5a7d5..3b29ede 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -299,10 +299,11 @@ installers. The most commonly-used variables are: Currently only ``xz`` compression *may* take advantage of multiple cores. Other compression methods ignore this value and use only one thread. - .. note:: + .. versionadded:: 3.21 - Official CMake binaries available on ``cmake.org`` ship with a ``liblzma`` - that does not support parallel compression. + Official CMake binaries available on ``cmake.org`` now ship + with a ``liblzma`` that supports parallel compression. + Older versions did not. Variables for Source Package Generators ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt index 5dd7035..4820a8f 100644 --- a/Utilities/cmliblzma/CMakeLists.txt +++ b/Utilities/cmliblzma/CMakeLists.txt @@ -6,6 +6,12 @@ include(CheckSymbolExists) include(CheckTypeSize) include(TestBigEndian) +if(WIN32) + add_definitions(-DMYTHREAD_VISTA) +else() + add_definitions(-DMYTHREAD_POSIX) +endif() + CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H) CHECK_INCLUDE_FILE(limits.h HAVE_LIMITS_H) CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) @@ -60,7 +66,10 @@ set(HAVE_MF_HC3 1) set(HAVE_MF_HC4 1) SET(LZMA_SRCS + common/mythread.h common/sysdefs.h + common/tuklib_cpucores.c + common/tuklib_cpucores.h common/tuklib_integer.h liblzma/check/check.c liblzma/check/crc32_fast.c @@ -91,14 +100,17 @@ SET(LZMA_SRCS liblzma/common/filter_encoder.c liblzma/common/filter_flags_decoder.c liblzma/common/filter_flags_encoder.c + liblzma/common/hardware_cputhreads.c liblzma/common/index.c liblzma/common/index_decoder.c liblzma/common/index_encoder.c liblzma/common/index_hash.c + liblzma/common/outqueue.c liblzma/common/stream_buffer_decoder.c liblzma/common/stream_buffer_encoder.c liblzma/common/stream_decoder.c liblzma/common/stream_encoder.c + liblzma/common/stream_encoder_mt.c liblzma/common/stream_flags_common.c liblzma/common/stream_flags_decoder.c liblzma/common/stream_flags_encoder.c diff --git a/Utilities/cmliblzma/liblzma/common/common.h b/Utilities/cmliblzma/liblzma/common/common.h index dde3ae0..b3d3b7a 100644 --- a/Utilities/cmliblzma/liblzma/common/common.h +++ b/Utilities/cmliblzma/liblzma/common/common.h @@ -14,6 +14,7 @@ #define LZMA_COMMON_H #include "sysdefs.h" +#include "mythread.h" #include "tuklib_integer.h" #if defined(_WIN32) || defined(__CYGWIN__) -- cgit v0.12 From c5c130e675624eef03f5bcaf848810659e205ed2 Mon Sep 17 00:00:00 2001 From: Nils Gladitz Date: Mon, 19 Apr 2021 19:37:57 +0200 Subject: cmArchiveWrite: Consolidate multiple ways to set thread count Merge use of SetFilterOption() into more abstract thread count in cmArchiveWrite constructor. libarchive defaulting of threads for threads == 0 seems to be configuration dependent. Preemptively default thread count via std::thread::hardware_concurrency(). Also allow negative values for the thread count in which case the detected hardware concurrency is also used but the given absolute thread count is used as an upper limit. --- Modules/CPack.cmake | 18 +++++--- Source/CPack/cmCPackArchiveGenerator.cxx | 39 +++++------------- Source/CPack/cmCPackArchiveGenerator.h | 2 +- Source/CPack/cmCPackDebGenerator.cxx | 5 --- Source/cmArchiveWrite.cxx | 48 ++++++++++++++-------- Source/cmArchiveWrite.h | 3 -- Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake | 2 +- 7 files changed, 56 insertions(+), 61 deletions(-) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 3b29ede..373a707 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -291,13 +291,21 @@ installers. The most commonly-used variables are: Some compression methods used by CPack generators such as Debian or Archive may take advantage of multiple CPU cores to speed up compression. - ``CPACK_THREADS`` can be set to positive integer to specify how many threads - will be used for compression. If it is set to 0, CPack will set it so that - all available CPU cores are used. + ``CPACK_THREADS`` can be set to specify how many threads will be + used for compression. + + A positive integer can be used to specify an exact desired thread count. + + When given a negative integer CPack will use the absolute value + as the upper limit but may choose a lower value based on + the available hardware concurrency. + + Given 0 CPack will try to use all available CPU cores. + By default ``CPACK_THREADS`` is set to ``1``. - Currently only ``xz`` compression *may* take advantage of multiple cores. Other - compression methods ignore this value and use only one thread. + Currently only ``xz`` compression *may* take advantage of multiple cores. + Other compression methods ignore this value and use only one thread. .. versionadded:: 3.21 diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 7fd12dd..d9234e6 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -2,14 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackArchiveGenerator.h" +#include #include #include #include #include #include -#include - #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" @@ -154,15 +153,9 @@ int cmCPackArchiveGenerator::addOneComponentToArchive( << (filename) << ">." << std::endl); \ return 0; \ } \ - cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat); \ + cmArchiveWrite archive(gf, this->Compress, this->ArchiveFormat, 0, \ + this->GetThreadCount()); \ do { \ - if (!this->SetArchiveOptions(&archive)) { \ - cmCPackLogger(cmCPackLog::LOG_ERROR, \ - "Problem to set archive options <" \ - << (filename) << ">, ERROR = " << (archive).GetError() \ - << std::endl); \ - return 0; \ - } \ if (!archive.Open()) { \ cmCPackLogger(cmCPackLog::LOG_ERROR, \ "Problem to open archive <" \ @@ -346,26 +339,16 @@ bool cmCPackArchiveGenerator::SupportsComponentInstallation() const return this->IsOn("CPACK_ARCHIVE_COMPONENT_INSTALL"); } -bool cmCPackArchiveGenerator::SetArchiveOptions(cmArchiveWrite* archive) +int cmCPackArchiveGenerator::GetThreadCount() const { -#if ARCHIVE_VERSION_NUMBER >= 3004000 - // Upstream fixed an issue with their integer parsing in 3.4.0 which would - // cause spurious errors to be raised from `strtoull`. - if (this->Compress == cmArchiveWrite::CompressXZ) { - const char* threads = "1"; - - // CPACK_ARCHIVE_THREADS overrides CPACK_THREADS - if (this->IsSet("CPACK_ARCHIVE_THREADS")) { - threads = this->GetOption("CPACK_ARCHIVE_THREADS"); - } else if (this->IsSet("CPACK_THREADS")) { - threads = this->GetOption("CPACK_THREADS"); - } + int threads = 1; - if (!archive->SetFilterOption("xz", "threads", threads)) { - return false; - } + // CPACK_ARCHIVE_THREADS overrides CPACK_THREADS + if (this->IsSet("CPACK_ARCHIVE_THREADS")) { + threads = std::atoi(this->GetOption("CPACK_ARCHIVE_THREADS")); + } else if (this->IsSet("CPACK_THREADS")) { + threads = std::atoi(this->GetOption("CPACK_THREADS")); } -#endif - return true; + return threads; } diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 5b40013..8a9bbc6 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -85,7 +85,7 @@ private: return this->OutputExtension.c_str(); } - bool SetArchiveOptions(cmArchiveWrite* archive); + int GetThreadCount() const; private: cmArchiveWrite::Compress Compress; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index e7bcfac..0fafd85 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -130,11 +130,6 @@ DebGenerator::DebGenerator( "Unrecognized number of threads: " << numThreads << std::endl); } - - if (this->NumThreads < 0) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Number of threads cannot be negative" << std::endl); - } } bool DebGenerator::generate() const diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index b685b73..54b2998 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -2,11 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmArchiveWrite.h" -#include +#include #include #include #include +#include #include +#include +#include + +#include #include #include @@ -144,16 +149,36 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, cm_archive_error_string(this->Archive)); return; } + { - char sNumThreads[8]; - snprintf(sNumThreads, sizeof(sNumThreads), "%d", numThreads); - sNumThreads[7] = '\0'; // for safety +#if ARCHIVE_VERSION_NUMBER >= 3004000 + // Upstream fixed an issue with their integer parsing in 3.4.0 + // which would cause spurious errors to be raised from `strtoull`. + + if (numThreads < 1) { + int upperLimit = (numThreads == 0) ? std::numeric_limits::max() + : std::abs(numThreads); + + numThreads = + cm::clamp(std::thread::hardware_concurrency(), 1, upperLimit); + } + +# ifdef _AIX + // FIXME: Using more than 2 threads creates an empty archive. + // Enforce this limit pending further investigation. + numThreads = std::min(numThreads, 2); +# endif + + std::string sNumThreads = std::to_string(numThreads); + if (archive_write_set_filter_option(this->Archive, "xz", "threads", - sNumThreads) != ARCHIVE_OK) { + sNumThreads.c_str()) != + ARCHIVE_OK) { this->Error = cmStrCat("archive_compressor_xz_options: ", cm_archive_error_string(this->Archive)); return; } +#endif } break; @@ -425,16 +450,3 @@ bool cmArchiveWrite::AddData(const char* file, size_t size) } return true; } - -bool cmArchiveWrite::SetFilterOption(const char* module, const char* key, - const char* value) -{ - if (archive_write_set_filter_option(this->Archive, module, key, value) != - ARCHIVE_OK) { - this->Error = "archive_write_set_filter_option: "; - this->Error += cm_archive_error_string(this->Archive); - return false; - } - - return true; -} diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 34aafe9..260bd20 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -141,9 +141,6 @@ public: this->Gname = ""; } - //! Set an option on a filter; - bool SetFilterOption(const char* module, const char* key, const char* value); - private: bool Okay() const { return this->Error.empty(); } bool AddPath(const char* path, size_t skip, const char* prefix, diff --git a/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake b/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake index 6f37201..af39e5f 100644 --- a/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake +++ b/Tests/RunCMake/CPack/tests/THREADED_ALL/test.cmake @@ -1,6 +1,6 @@ install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) -set(CPACK_THREADS 0) +set(CPACK_THREADS "-4") if(PACKAGING_TYPE STREQUAL "COMPONENT") set(CPACK_COMPONENTS_ALL test) -- cgit v0.12 From 15a148dec63d04f302b6c0b951104f8eb470ce1c Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Fri, 23 Apr 2021 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 970dfaa..f9bde6d 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210422) +set(CMake_VERSION_PATCH 20210423) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 5b0ea5874a3322e57156b329b340bf283673c207 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 20 Apr 2021 21:17:50 +0200 Subject: AutoGen: Retrieve Qt version from moc as fallback Consider the case where the find_package call for QtCore is wrapped in a function call. Then AutoGen cannot determine the Qt version, because it only looks at variables and directory properties. The former don't leave the function scope and the latter are not set by default. As a fallback, locate the moc executable via its target and call it with the --version argument to determine the Qt version. Issue: #22028 --- Source/cmQtAutoGenGlobalInitializer.cxx | 3 +- Source/cmQtAutoGenInitializer.cxx | 74 ++++++++++++++++++++++- Source/cmQtAutoGenInitializer.h | 6 +- Tests/QtAutogen/Tests.cmake | 1 + Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt | 16 +++++ Tests/QtAutogen/WrappedFindPackage/main.cpp | 19 ++++++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt create mode 100644 Tests/QtAutogen/WrappedFindPackage/main.cpp diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index f79ffd4..5896bb2 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -114,7 +114,8 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( target->GetSafeProperty(this->kw().AUTORCC_EXECUTABLE); // We support Qt4, Qt5 and Qt6 - auto qtVersion = cmQtAutoGenInitializer::GetQtVersion(target.get()); + auto qtVersion = + cmQtAutoGenInitializer::GetQtVersion(target.get(), mocExec); bool const validQt = (qtVersion.first.Major == 4) || (qtVersion.first.Major == 5) || (qtVersion.first.Major == 6); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 3adeb1a..148591c 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -6,8 +6,8 @@ #include #include #include -#include #include +#include // for basic_ios, istringstream #include #include #include @@ -1833,8 +1833,63 @@ void cmQtAutoGenInitializer::ConfigFileClean(ConfigString& configString) } } +static cmQtAutoGen::IntegerVersion parseMocVersion(std::string str) +{ + cmQtAutoGen::IntegerVersion result; + + static const std::string prelude = "moc "; + size_t pos = str.find(prelude); + if (pos == std::string::npos) { + return result; + } + + str.erase(0, prelude.size() + pos); + std::istringstream iss(str); + std::string major; + std::string minor; + if (!std::getline(iss, major, '.') || !std::getline(iss, minor, '.')) { + return result; + } + + result.Major = static_cast(std::stoi(major)); + result.Minor = static_cast(std::stoi(minor)); + return result; +} + +static cmQtAutoGen::IntegerVersion GetMocVersion( + const std::string& mocExecutablePath) +{ + std::string capturedStdOut; + int exitCode; + if (!cmSystemTools::RunSingleCommand({ mocExecutablePath, "--version" }, + &capturedStdOut, nullptr, &exitCode, + nullptr, cmSystemTools::OUTPUT_NONE)) { + return {}; + } + + if (exitCode != 0) { + return {}; + } + + return parseMocVersion(capturedStdOut); +} + +static std::string FindMocExecutableFromMocTarget(cmMakefile* makefile, + unsigned int qtMajorVersion) +{ + std::string result; + const std::string mocTargetName = + "Qt" + std::to_string(qtMajorVersion) + "::moc"; + cmTarget* mocTarget = makefile->FindTargetToUse(mocTargetName); + if (mocTarget) { + result = mocTarget->GetSafeProperty("IMPORTED_LOCATION"); + } + return result; +} + std::pair -cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) +cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target, + std::string mocExecutable) { // Converts a char ptr to an unsigned int value auto toUInt = [](const char* const input) -> unsigned int { @@ -1909,6 +1964,21 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) } } } + + if (res.first.Major == 0) { + // We could not get the version number from variables or directory + // properties. This might happen if the find_package call for Qt is wrapped + // in a function. Try to find the moc executable path from the available + // targets and call "moc --version" to get the Qt version. + if (mocExecutable.empty()) { + mocExecutable = + FindMocExecutableFromMocTarget(target->Makefile, res.second); + } + if (!mocExecutable.empty()) { + res.first = GetMocVersion(mocExecutable); + } + } + return res; } diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 8a6d8f9..e76817b 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -98,9 +98,11 @@ public: , GenNameUpper(cmQtAutoGen::GeneratorNameUpper(gen)){}; }; - /** @return The detected Qt version and the required Qt major version. */ + /** @param mocExecutable The file path to the moc executable. Will be used as + fallback to query the version + @return The detected Qt version and the required Qt major version. */ static std::pair GetQtVersion( - cmGeneratorTarget const* genTarget); + cmGeneratorTarget const* genTarget, std::string mocExecutable); cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer, cmGeneratorTarget* genTarget, diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index ab5686a..a3c57a5 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -49,6 +49,7 @@ if(QT_TEST_VERSION GREATER 4) ADD_AUTOGEN_TEST(MocMacroName mocMacroName) ADD_AUTOGEN_TEST(MocOsMacros) ADD_AUTOGEN_TEST(RerunMocPlugin) + ADD_AUTOGEN_TEST(WrappedFindPackage) if(APPLE) ADD_AUTOGEN_TEST(MacOsFW) endif() diff --git a/Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt b/Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt new file mode 100644 index 0000000..e8f50d5 --- /dev/null +++ b/Tests/QtAutogen/WrappedFindPackage/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.20) +project(WrappedFindPackage) + +# Wrap the find_package call in a function. +# Test whether AutoMoc can retrieve the Qt version from the moc executable. +function(find_qt_package) + include("../AutogenCoreTest.cmake") + set(QT_LIBRARIES "${QT_LIBRARIES}" PARENT_SCOPE) +endfunction() + +find_qt_package() + +set(CMAKE_AUTOMOC ON) + +add_executable(wrappedFindPackage main.cpp) +target_link_libraries(wrappedFindPackage PRIVATE ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/WrappedFindPackage/main.cpp b/Tests/QtAutogen/WrappedFindPackage/main.cpp new file mode 100644 index 0000000..1e2c63f --- /dev/null +++ b/Tests/QtAutogen/WrappedFindPackage/main.cpp @@ -0,0 +1,19 @@ +#include + +class MyObject : public QObject +{ + Q_OBJECT +public: + MyObject(QObject* parent = 0) + : QObject(parent) + { + } +}; + +int main() +{ + MyObject obj; + return 0; +} + +#include "main.moc" -- cgit v0.12 From e3e005dbd8bcb64b20a0923078c3fed0e58cff2c Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Fri, 23 Apr 2021 17:09:12 +0200 Subject: UseSWIG: use swig dependencies for Xcode generator --- Help/release/dev/UseSWIG-dependencies.rst | 6 ++++++ Modules/UseSWIG.cmake | 23 ++++++++++++++++------- Tests/UseSWIG/CMakeLists.txt | 3 ++- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 Help/release/dev/UseSWIG-dependencies.rst diff --git a/Help/release/dev/UseSWIG-dependencies.rst b/Help/release/dev/UseSWIG-dependencies.rst new file mode 100644 index 0000000..b5a38c3 --- /dev/null +++ b/Help/release/dev/UseSWIG-dependencies.rst @@ -0,0 +1,6 @@ +UseSWIG-dependencies +-------------------- + +* :module:`UseSWIG` module gained the capability, for + :generator:`Xcode` generator, to use `swig` tool to generate implicit + dependencies. diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index 8852df8..269fa98 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -191,8 +191,12 @@ ensure generated files will receive the required settings. If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool itself. This property is only meaningful for - :ref:`Makefile ` and - :ref:`Ninja ` generators. Default value is ``FALSE``. + :ref:`Makefile `, + :ref:`Ninja ` and :generator:`Xcode` generators. Default + value is ``FALSE``. + + .. versionadded:: 3.21 + Added the support of :generator:`Xcode` generator. ``SWIG_MODULE_NAME`` Specify the actual import name of the module in the target language. @@ -336,12 +340,17 @@ as well as ``SWIG``: .. versionadded:: 3.20 If set to ``TRUE``, implicit dependencies are generated by the ``swig`` tool - itself. This property is only meaningful for - :ref:`Makefile ` and - :ref:`Ninja ` generators. Default value is ``FALSE``. + itself. This variable is only meaningful for + :ref:`Makefile `, + :ref:`Ninja ` and :generator:`Xcode` generators. Default + value is ``FALSE``. Source file property ``USE_SWIG_DEPENDENCIES``, if not defined, will be initialized with the value of this variable. + + .. versionadded:: 3.21 + Added the support of :generator:`Xcode` generator. + #]=======================================================================] cmake_policy(PUSH) @@ -506,7 +515,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) endif() set (use_swig_dependencies ${SWIG_USE_SWIG_DEPENDENCIES}) - if (CMAKE_GENERATOR MATCHES "Make|Ninja") + if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") get_property(use_swig_dependencies_set SOURCE "${infile}" PROPERTY USE_SWIG_DEPENDENCIES SET) if (use_swig_dependencies_set) get_property(use_swig_dependencies SOURCE "${infile}" PROPERTY USE_SWIG_DEPENDENCIES) @@ -831,7 +840,7 @@ function(SWIG_ADD_LIBRARY name) set(SWIG_SOURCE_FILE_EXTENSIONS ".i") endif() - if (CMAKE_GENERATOR MATCHES "Make|Ninja") + if (CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") # For Makefiles and Ninja generators, use SWIG generated dependencies if (NOT DEFINED SWIG_USE_SWIG_DEPENDENCIES) set (SWIG_USE_SWIG_DEPENDENCIES OFF) diff --git a/Tests/UseSWIG/CMakeLists.txt b/Tests/UseSWIG/CMakeLists.txt index d08c59c..f1b2f32 100644 --- a/Tests/UseSWIG/CMakeLists.txt +++ b/Tests/UseSWIG/CMakeLists.txt @@ -66,7 +66,8 @@ add_test(NAME UseSWIG.BasicPerl COMMAND --build-options ${build_options} --test-command ${CMAKE_CTEST_COMMAND} -V -C $ ) -if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2") +if(SWIG_FOUND AND NOT SWIG_VERSION VERSION_LESS "4.0.2" + AND CMAKE_GENERATOR MATCHES "Make|Ninja|Xcode") add_test(NAME UseSWIG.Depfile.BasicPython COMMAND ${CMAKE_CTEST_COMMAND} -C $ --build-and-test -- cgit v0.12 From 88f5d4b24ffce8698c45a61b59ab6cde1bc00a15 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sat, 24 Apr 2021 00:01:09 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f9bde6d..c066b4e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210423) +set(CMake_VERSION_PATCH 20210424) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 5f90a93fd71c5951897c7f9acc64cd970e2a06b9 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Sun, 25 Apr 2021 00:01:06 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c066b4e..c7aaefc 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210424) +set(CMake_VERSION_PATCH 20210425) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From eeb771e4d6b9a1127a0818a211cafb722a2dc387 Mon Sep 17 00:00:00 2001 From: Kitware Robot Date: Mon, 26 Apr 2021 00:01:07 -0400 Subject: CMake Nightly Date Stamp --- Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c7aaefc..e7ac9a4 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 20) -set(CMake_VERSION_PATCH 20210425) +set(CMake_VERSION_PATCH 20210426) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -- cgit v0.12 From 25bf514447501963a31934b5b03c65aeb53a351f Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Fri, 23 Apr 2021 09:38:43 +1000 Subject: ctest: Add support for writing test results in JUnit XML format Addresses #18654 --- Help/command/ctest_test.rst | 10 ++ Help/manual/ctest.1.rst | 6 + Help/release/dev/ctest-output-junit.rst | 5 + Source/CTest/cmCTestMemCheckCommand.cxx | 2 +- Source/CTest/cmCTestMemCheckCommand.h | 3 +- Source/CTest/cmCTestTestCommand.cxx | 10 +- Source/CTest/cmCTestTestCommand.h | 4 +- Source/CTest/cmCTestTestHandler.cxx | 130 +++++++++++++++++++++ Source/CTest/cmCTestTestHandler.h | 10 ++ Source/cmCTest.cxx | 11 ++ Source/ctest.cxx | 1 + Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake | 19 +++ .../CTestCommandLine/output-junit-check.cmake | 36 ++++++ .../CTestCommandLine/output-junit-result.txt | 1 + .../CTestCommandLine/output-junit-stderr.txt | 1 + Tests/RunCMake/ctest_test/OutputJUnit-check.cmake | 24 ++++ Tests/RunCMake/ctest_test/RunCMakeTest.cmake | 3 + Utilities/IWYU/mapping.imp | 1 + 18 files changed, 271 insertions(+), 6 deletions(-) create mode 100644 Help/release/dev/ctest-output-junit.rst create mode 100644 Tests/RunCMake/CTestCommandLine/output-junit-check.cmake create mode 100644 Tests/RunCMake/CTestCommandLine/output-junit-result.txt create mode 100644 Tests/RunCMake/CTestCommandLine/output-junit-stderr.txt create mode 100644 Tests/RunCMake/ctest_test/OutputJUnit-check.cmake diff --git a/Help/command/ctest_test.rst b/Help/command/ctest_test.rst index b4493a0..9081b3f 100644 --- a/Help/command/ctest_test.rst +++ b/Help/command/ctest_test.rst @@