Customize your settings: create your settings_user.yml

Please, first clone the sources to recreate this project. You can find them in the examples2 repository in GitHub:

  1. $ git clone https://github.com/conan-io/examples2.git
  2. $ cd examples2/examples/config_files/settings_user

In this example we are going to see how to customize your settings without overwriting the original settings.yml file.

Note

To understand better this example, it is highly recommended to read previously the reference about settings.yml.

Locate the settings_user.yml

First of all, let’s have a look at the proposed source/settings_user.yml:

settings_user.yml

  1. os:
  2. webOS:
  3. sdk_version: [null, "7.0.0", "6.0.1", "6.0.0"]
  4. arch: ["cortexa15t2hf"]
  5. compiler:
  6. gcc:
  7. version: ["13.0-rc"]

As you can see, we don’t have to rewrite all the settings because they will be merged with the already defined in settings.yml.

Then, what are we adding through that settings_user.yml file?

  • New OS: webOS, and its sub-setting: sdk_version.

  • New arch available: cortexa15t2hf.

  • New gcc version: 13.0-rc.

Now, it’s time to copy the file source/settings_user.yml into your [CONAN_HOME]/ folder:

  1. $ conan config install sources/settings_user.yml
  2. Copying file settings_user.yml to /Users/myuser/.conan2/.

Use your new settings

After having copied the settings_user.yml, you should be able to use them for your recipes. Add this simple one into your local folder:

conanfile.py

  1. from conan import ConanFile
  2. class PkgConan(ConanFile):
  3. name = "pkg"
  4. version = "1.0"
  5. settings = "os", "compiler", "build_type", "arch"

Then, create several Conan packages (not binaries, as it does not have any source file for sure) to see that it’s working correctly:

Using the new OS and its sub-setting

  1. $ conan create . -s os=webOS -s os.sdk_version=7.0.0
  2. ...
  3. Profile host:
  4. [settings]
  5. arch=x86_64
  6. build_type=Release
  7. compiler=apple-clang
  8. compiler.cppstd=gnu98
  9. compiler.libcxx=libc++
  10. compiler.version=12.0
  11. os=webOS
  12. os.sdk_version=7.0.0
  13. Profile build:
  14. [settings]
  15. arch=x86_64
  16. build_type=Release
  17. compiler=apple-clang
  18. compiler.cppstd=gnu98
  19. compiler.libcxx=libc++
  20. compiler.version=12.0
  21. os=Macos
  22. ...
  23. -------- Installing (downloading, building) binaries... --------
  24. pkg/1.0: Copying sources to build folder
  25. pkg/1.0: Building your package in /Users/myuser/.conan2/p/t/pkg929d53a5f06b1/b
  26. pkg/1.0: Generating aggregated env files
  27. pkg/1.0: Package 'a0d37d10fdb83a0414d7f4a1fb73da2c210211c6' built
  28. pkg/1.0: Build folder /Users/myuser/.conan2/p/t/pkg929d53a5f06b1/b
  29. pkg/1.0: Generated conaninfo.txt
  30. pkg/1.0: Generating the package
  31. pkg/1.0: Temporary package folder /Users/myuser/.conan2/p/t/pkg929d53a5f06b1/p
  32. pkg/1.0 package(): WARN: No files in this package!
  33. pkg/1.0: Package 'a0d37d10fdb83a0414d7f4a1fb73da2c210211c6' created
  34. pkg/1.0: Created package revision 6a947a7b5669d6fde1a35ce5ff987fc6
  35. pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:a0d37d10fdb83a0414d7f4a1fb73da2c210211c6#6a947a7b5669d6fde1a35ce5ff987fc6
  36. pkg/1.0: Package folder /Users/myuser/.conan2/p/pkgb3950b1043542/p

Using new gcc compiler version

  1. $ conan create . -s compiler=gcc -s compiler.version=13.0-rc -s compiler.libcxx=libstdc++11
  2. ...
  3. Profile host:
  4. [settings]
  5. arch=x86_64
  6. build_type=Release
  7. compiler=gcc
  8. compiler.libcxx=libstdc++11
  9. compiler.version=13.0-rc
  10. os=Macos
  11. Profile build:
  12. [settings]
  13. arch=x86_64
  14. build_type=Release
  15. compiler=apple-clang
  16. compiler.cppstd=gnu98
  17. compiler.libcxx=libc++
  18. compiler.version=12.0
  19. os=Macos
  20. ...
  21. -------- Installing (downloading, building) binaries... --------
  22. pkg/1.0: Copying sources to build folder
  23. pkg/1.0: Building your package in /Users/myuser/.conan2/p/t/pkg918904bbca9dc/b
  24. pkg/1.0: Generating aggregated env files
  25. pkg/1.0: Package '44a4588d3fe63ccc6e7480565d35be38d405718e' built
  26. pkg/1.0: Build folder /Users/myuser/.conan2/p/t/pkg918904bbca9dc/b
  27. pkg/1.0: Generated conaninfo.txt
  28. pkg/1.0: Generating the package
  29. pkg/1.0: Temporary package folder /Users/myuser/.conan2/p/t/pkg918904bbca9dc/p
  30. pkg/1.0 package(): WARN: No files in this package!
  31. pkg/1.0: Package '44a4588d3fe63ccc6e7480565d35be38d405718e' created
  32. pkg/1.0: Created package revision d913ec060e71cc56b10768afb9620094
  33. pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:44a4588d3fe63ccc6e7480565d35be38d405718e#d913ec060e71cc56b10768afb9620094
  34. pkg/1.0: Package folder /Users/myuser/.conan2/p/pkg789b624c93fc0/p

Using the new OS and the new architecture

  1. $ conan create . -s os=webOS -s arch=cortexa15t2hf
  2. ...
  3. Profile host:
  4. [settings]
  5. arch=cortexa15t2hf
  6. build_type=Release
  7. compiler=apple-clang
  8. compiler.cppstd=gnu98
  9. compiler.libcxx=libc++
  10. compiler.version=12.0
  11. os=webOS
  12. Profile build:
  13. [settings]
  14. arch=x86_64
  15. build_type=Release
  16. compiler=apple-clang
  17. compiler.cppstd=gnu98
  18. compiler.libcxx=libc++
  19. compiler.version=12.0
  20. os=Macos
  21. ...
  22. -------- Installing (downloading, building) binaries... --------
  23. pkg/1.0: Copying sources to build folder
  24. pkg/1.0: Building your package in /Users/myuser/.conan2/p/t/pkgde9b63a6bed0a/b
  25. pkg/1.0: Generating aggregated env files
  26. pkg/1.0: Package '19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc' built
  27. pkg/1.0: Build folder /Users/myuser/.conan2/p/t/pkgde9b63a6bed0a/b
  28. pkg/1.0: Generated conaninfo.txt
  29. pkg/1.0: Generating the package
  30. pkg/1.0: Temporary package folder /Users/myuser/.conan2/p/t/pkgde9b63a6bed0a/p
  31. pkg/1.0 package(): WARN: No files in this package!
  32. pkg/1.0: Package '19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc' created
  33. pkg/1.0: Created package revision f5739d5a25b3757254dead01b30d3af0
  34. pkg/1.0: Full package reference: pkg/1.0#637fc1c7080faaa7e2cdccde1bcde118:19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc#f5739d5a25b3757254dead01b30d3af0
  35. pkg/1.0: Package folder /Users/myuser/.conan2/p/pkgd154182aac59e/p

As you could observe, each command has created a different package. That was completely right because we were using different settings for each one. If you want to see all the packages created, you can use the conan list command:

List all the pkg/1.0’s packages

  1. $ conan list pkg/1.0:*
  2. Local Cache
  3. pkg
  4. pkg/1.0
  5. revisions
  6. 637fc1c7080faaa7e2cdccde1bcde118 (2023-02-16 06:42:10 UTC)
  7. packages
  8. 19cf3cb5842b18dc78e5b0c574c1e71e7b0e17fc
  9. info
  10. settings
  11. arch: cortexa15t2hf
  12. build_type: Release
  13. compiler: apple-clang
  14. compiler.cppstd: gnu98
  15. compiler.libcxx: libc++
  16. compiler.version: 12.0
  17. os: webOS
  18. 44a4588d3fe63ccc6e7480565d35be38d405718e
  19. info
  20. settings
  21. arch: x86_64
  22. build_type: Release
  23. compiler: gcc
  24. compiler.libcxx: libstdc++11
  25. compiler.version: 13.0-rc
  26. os: Macos
  27. a0d37d10fdb83a0414d7f4a1fb73da2c210211c6
  28. info
  29. settings
  30. arch: x86_64
  31. build_type: Release
  32. compiler: apple-clang
  33. compiler.cppstd: gnu98
  34. compiler.libcxx: libc++
  35. compiler.version: 12.0
  36. os: webOS
  37. os.sdk_version: 7.0.0

Try any other custom setting!

See also