Skip to content

Commit

Permalink
Use conanfile.txt instead of conanfile.py
Browse files Browse the repository at this point in the history
The .py file was useful mainly for Conan 1, where the .txt file lacked
features to control test and tool requirements and where the files are
generated. With the "layout.cmake_layout" setting the files are output
to "build/generators" instead of the current "conan" directory.

Fixes #109
  • Loading branch information
friendlyanon committed Mar 8, 2024
1 parent 6432727 commit 3536f8f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cmake-init/cmake_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def should_install_file(name, d):
return not d["cmake_321"]
if name == "vcpkg.json":
return d["vcpkg"]
if name == "conanfile.py":
if name == "conanfile.txt":
return d["conan"]
if name == "install-config.cmake":
return not d["exe"]
Expand Down
3 changes: 1 addition & 2 deletions cmake-init/templates/common/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
.vs/
.vscode/
build/
cmake-build-*/{% if conan %}
conan/{% end %}
cmake-build-*/
prefix/
.clangd
CMakeLists.txt.user
Expand Down
2 changes: 1 addition & 1 deletion cmake-init/templates/common/BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Dependencies

For a list of dependencies, please refer to {% if vcpkg %}[vcpkg.json](vcpkg.json){% else %}[conanfile.py](conanfile.py){% end %}.{% end %}
For a list of dependencies, please refer to {% if vcpkg %}[vcpkg.json](vcpkg.json){% else %}[conanfile.txt](conanfile.txt){% end %}.{% end %}

## Build

Expand Down
2 changes: 1 addition & 1 deletion cmake-init/templates/common/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"name": "conan",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/conan/conan_toolchain.cmake"{% if not cmake_321 %},
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build/generators/conan_toolchain.cmake"{% if not cmake_321 %},
"CMAKE_POLICY_DEFAULT_CMP0091": "NEW"{% end %}
}
},{% end %}
Expand Down
18 changes: 0 additions & 18 deletions cmake-init/templates/common/conanfile.py

This file was deleted.

18 changes: 18 additions & 0 deletions cmake-init/templates/common/conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[requires]{% if c %}{% if exe %}
hedley/15{% end %}
json-c/0.17{% else %}
fmt/10.2.1{% end %}

[test_requires]
catch2/{% if catch3 %}3.5.2{% else %}2.13.10

[options]
catch2/*:with_main=True{% end %}

[generators]
CMakeToolchain
CMakeDeps
VirtualRunEnv

[layout]
cmake_layout

0 comments on commit 3536f8f

Please sign in to comment.