I have a foundry project with files that have multiple solidity versions(0.7.x and 0.8.x). hardhat can relatively easily be configured to compile all files in the project as follows:
https://hardhat.org/hardhat-runner/docs/advanced/multiple-solidity-versions
Does foundry have built-in support for multiple solidity compiler versions? I came across a hacky way to do this which is non-ideal and I don't want to take this approach.
Best Answer
So it doesn't seem like Foundry allows you to manually configure multiple
solc
versions however Foundry does automatically detect and configure the required compilers for your project, you'll need to make sure of the following:Do not explicitly configure a solidity compiler version i.e. do not set the
solc
variable in yourfoundry.toml
config.Ensure that auto_detect_solc is set to
true
or leave it unconfigured(since the default value istrue
).Here's an example of what your
foundry.toml
might look like:Credit to @jaime for pointing me in the right direction.