本文档翻译自:https://docs.conan.io/en/latest/reference/commands/creator/create.html

    1. $ conan create [-h] [-j JSON] [-k] [-kb] [-ne] [-tbf TEST_BUILD_FOLDER]
    2. [-tf TEST_FOLDER] [--ignore-dirty] [-m [MANIFESTS]]
    3. [-mi [MANIFESTS_INTERACTIVE]] [-v [VERIFY]] [-b [BUILD]]
    4. [-r REMOTE] [-u] [-l [LOCKFILE]] [-e ENV_HOST]
    5. [-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST]
    6. [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
    7. [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD]
    8. [-pr:h PROFILE_HOST] [-s SETTINGS_HOST]
    9. [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST]
    10. path [reference]

    为配方(conanfile.py)构建二进制包。
    在配置文件或-s设置,-o选项等中使用指定的配置。如果找到’test_package’文件夹(名称可以使用-tf进行配置),该命令将运行使用者项目以确保该软件包 已正确创建。 查看“ conan test”命令以了解有关“ test_folder”项目的更多信息。

    1. positional arguments:
    2. path Path to a folder containing a conanfile.py or to a
    3. recipe file e.g., my_folder/conanfile.py
    4. reference user/channel, version@user/channel or
    5. pkg/version@user/channel (if name or version declared
    6. in conanfile.py, they should match)
    7. optional arguments:
    8. -h, --help show this help message and exit
    9. -j JSON, --json JSON json file path where the install information will be
    10. written to
    11. -k, -ks, --keep-source
    12. Do not remove the source folder in the local cache,
    13. even if the recipe changed. Use this for testing
    14. purposes only
    15. -kb, --keep-build Do not remove the build folder in local cache. Implies
    16. --keep-source. Use this for testing purposes only
    17. -ne, --not-export Do not export the conanfile.py
    18. -tbf TEST_BUILD_FOLDER, --test-build-folder TEST_BUILD_FOLDER
    19. Working directory for the build of the test project.
    20. -tf TEST_FOLDER, --test-folder TEST_FOLDER
    21. Alternative test folder name. By default it is
    22. "test_package". Use "None" to skip the test stage
    23. --ignore-dirty When using the "scm" feature with "auto" values,
    24. capture the revision and url even if there are
    25. uncommitted changes
    26. -m [MANIFESTS], --manifests [MANIFESTS]
    27. Install dependencies manifests in folder for later
    28. verify. Default folder is .conan_manifests, but can be
    29. changed
    30. -mi [MANIFESTS_INTERACTIVE], --manifests-interactive [MANIFESTS_INTERACTIVE]
    31. Install dependencies manifests in folder for later
    32. verify, asking user for confirmation. Default folder
    33. is .conan_manifests, but can be changed
    34. -v [VERIFY], --verify [VERIFY]
    35. Verify dependencies manifests against stored ones
    36. -b [BUILD], --build [BUILD]
    37. Optional, specify which packages to build from source.
    38. Combining multiple '--build' options on one command
    39. line is allowed. For dependencies, the optional
    40. 'build_policy' attribute in their conanfile.py takes
    41. precedence over the command line parameter. Possible
    42. parameters: --build Force build for all packages, do
    43. not use binary packages. --build=never Disallow build
    44. for all packages, use binary packages or fail if a
    45. binary package is not found. Cannot be combined with
    46. other '--build' options. --build=missing Build
    47. packages from source whose binary package is not
    48. found. --build=outdated Build packages from source
    49. whose binary package was not generated from the latest
    50. recipe or is not found. --build=cascade Build packages
    51. from source that have at least one dependency being
    52. built from source. --build=[pattern] Build packages
    53. from source whose package reference matches the
    54. pattern. The pattern uses 'fnmatch' style wildcards.
    55. Default behavior: If you omit the '--build' option,
    56. the 'build_policy' attribute in conanfile.py will be
    57. used if it exists, otherwise the behavior is like '--
    58. build=package name'.
    59. -r REMOTE, --remote REMOTE
    60. Look in the specified remote server
    61. -u, --update Check updates exist from upstream remotes
    62. -l [LOCKFILE], --lockfile [LOCKFILE]
    63. Path to a lockfile or folder containing 'conan.lock'
    64. file. Lockfile can be updated if packages change
    65. -e ENV_HOST, --env ENV_HOST
    66. Environment variables that will be set during the
    67. package build (host machine). e.g.: -e
    68. CXX=/usr/bin/clang++
    69. -e:b ENV_BUILD, --env:build ENV_BUILD
    70. Environment variables that will be set during the
    71. package build (build machine). e.g.: -e:b
    72. CXX=/usr/bin/clang++
    73. -e:h ENV_HOST, --env:host ENV_HOST
    74. Environment variables that will be set during the
    75. package build (host machine). e.g.: -e:h
    76. CXX=/usr/bin/clang++
    77. -o OPTIONS_HOST, --options OPTIONS_HOST
    78. Define options values (host machine), e.g.: -o
    79. Pkg:with_qt=true
    80. -o:b OPTIONS_BUILD, --options:build OPTIONS_BUILD
    81. Define options values (build machine), e.g.: -o:b
    82. Pkg:with_qt=true
    83. -o:h OPTIONS_HOST, --options:host OPTIONS_HOST
    84. Define options values (host machine), e.g.: -o:h
    85. Pkg:with_qt=true
    86. -pr PROFILE_HOST, --profile PROFILE_HOST
    87. Apply the specified profile to the host machine
    88. -pr:b PROFILE_BUILD, --profile:build PROFILE_BUILD
    89. Apply the specified profile to the build machine
    90. -pr:h PROFILE_HOST, --profile:host PROFILE_HOST
    91. Apply the specified profile to the host machine
    92. -s SETTINGS_HOST, --settings SETTINGS_HOST
    93. Settings to build the package, overwriting the
    94. defaults (host machine). e.g.: -s compiler=gcc
    95. -s:b SETTINGS_BUILD, --settings:build SETTINGS_BUILD
    96. Settings to build the package, overwriting the
    97. defaults (build machine). e.g.: -s:b compiler=gcc
    98. -s:h SETTINGS_HOST, --settings:host SETTINGS_HOST
    99. Settings to build the package, overwriting the
    100. defaults (host machine). e.g.: -s:h compiler=gcc

    **conan create . demo/testing** is equivalent to:

    1. $ conan export . demo/testing
    2. $ conan install hello/0.1@demo/testing --build=hello
    3. # package is created now, use test to test it
    4. $ cd test_package
    5. $ conan test . hello/0.1@demo/testing

    :::info Tip
    有时您需要跳过/禁用测试阶段,以免在创建软件包时失败,即:当您交叉编译库且目标代码无法在当前主机平台上执行时。 在这种情况下,您可以跳过/禁用测试包阶段:

    1. $ conan create . demo/testing --test-folder=None

    :::

    柯南创建按以下顺序执行conanfile.py的方法:

    1. config_options()
    2. configure()
    3. requirements()
    4. package_id()
    5. build_requirements()
    6. build_id()
    7. system_requirements()
    8. source()
    9. imports()
    10. build()
    11. package()
    12. package_info()

    如果安装了预构建的二进制文件,则将跳过从5到11的步骤。 请注意,deploy()方法仅在柯南安装中使用。 :::info Note
    使用conan.conf中的general.parallel_download实验配置,可以加快二进制文件的安装速度,以设置并行下载。 :::