From 3237b4dd652f312f54447645270206ea0fc176cf Mon Sep 17 00:00:00 2001 From: Nick Logozzo Date: Wed, 3 Jan 2024 21:51:03 -0500 Subject: [PATCH] Conan - Better Conan File --- .github/workflows/linux.yml | 4 ++-- .github/workflows/windows.yml | 4 ++-- README.md | 8 ++++---- conan/conanfile-linux.txt | 18 ------------------ conan/conanfile-windows.txt | 15 --------------- conan/conanfile.py | 31 +++++++++++++++++++++++++++++++ 6 files changed, 39 insertions(+), 41 deletions(-) delete mode 100644 conan/conanfile-linux.txt delete mode 100644 conan/conanfile-windows.txt create mode 100644 conan/conanfile.py diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c4800a7..ec2d351 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -49,9 +49,9 @@ jobs: conan config install settings_user.yml - name: "Install Conan" run: | - mv conan/conanfile-linux.txt conanfile.txt + mv conan/conanfile.py conanfile.py mv conan/conanprofile-linux.txt conanprofile.txt - conan install conanfile.txt --profile:host=conanprofile.txt --profile:build=conanprofile.txt -s compiler.cppstd=20 --build=missing + conan install conanfile.py --profile:host=conanprofile.txt --profile:build=conanprofile.txt -s compiler.cppstd=20 --build=missing - name: "CMake Build" working-directory: ${{github.workspace}}/build run: | diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b9b2614..852bdf1 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -31,9 +31,9 @@ jobs: uses: turtlebrowser/get-conan@main - name: "Install Conan" run: | - move conan/conanfile-windows.txt conanfile.txt + move conan/conanfile.py conanfile.py move conan/conanprofile-windows.txt conanprofile.txt - conan install conanfile.txt --profile:host=conanprofile.txt --profile:build=conanprofile.txt -s compiler.cppstd=20 --build=missing + conan install conanfile.py --profile:host=conanprofile.txt --profile:build=conanprofile.txt -s compiler.cppstd=20 --build=missing - name: "CMake Build" working-directory: ${{github.workspace}}/build run: | diff --git a/README.md b/README.md index 75efd15..2923697 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ A C++20 compiler is also required to build libaura. Visual Studio 2022 with C++ Desktop workload is required to be installed. 1. First, clone/download the repo. -1. From the `conan` folder within the repo, copy `conanfile-windows.txt` and `conanprofile-windows.txt` to the root directory of the repo. +1. From the `conan` folder within the repo, copy `conanfile.py` and `conanprofile-windows.txt` to the root directory of the repo. 1. Open a terminal and navigate to the repo's root directory. -1. Run `conan install conanfile-windows.txt --profile:host=conanprofile-windows.txt --profile:build=conanprofile-windows.txt -s compiler.cppstd=20 --build=missing`. +1. Run `conan install conanfile.py --profile:host=conanprofile-windows.txt --profile:build=conanprofile-windows.txt -s compiler.cppstd=20 --build=missing`. 1. Once that command finishes, cd into the `build` folder. 1. From the `build` folder, run `cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake"`. - To skip building libaura's test suite, add `-DBUILD_TESTING="Off"` to the end of the command. @@ -37,11 +37,11 @@ Visual Studio 2022 with C++ Desktop workload is required to be installed. ### Linux 1. First, clone/download the repo. -1. From the `conan` folder within the repo, copy `conansettings.yml`, `conanfile-linux.txt`, and `conanprofile-linux.txt` to the root directory of the repo. +1. From the `conan` folder within the repo, copy `conansettings.yml`, `conanfile.py`, and `conanprofile-linux.txt` to the root directory of the repo. 1. Rename `conansettings.yml` to `settings_user.yml`. 1. Open a terminal and navigate to the repo's root directory. 1. Run `conan config install settings_user.yml`. -1. Run `conan install conanfile-linux.txt --profile:host=conanprofile-linux.txt --profile:build=conanprofile-linux.txt -s compiler.cppstd=20 --build=missing`. +1. Run `conan install conanfile.py --profile:host=conanprofile-linux.txt --profile:build=conanprofile-linux.txt -s compiler.cppstd=20 --build=missing`. 1. Once that command finished, cd into the `build` folder. 1. From the `build` folder, run `cmake .. -DCMAKE_TOOLCHAIN_FILE="Release/generators/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=Release`. - To skip building libaura's test suite, add `-DBUILD_TESTING="Off"` to the end of the command. diff --git a/conan/conanfile-linux.txt b/conan/conanfile-linux.txt deleted file mode 100644 index ce664f0..0000000 --- a/conan/conanfile-linux.txt +++ /dev/null @@ -1,18 +0,0 @@ -[requires] -boost/1.83.0 -glib/2.78.1 -gtest/1.14.0 -jsoncpp/1.9.5 -libcurl/8.4.0 -libgettext/0.22 -libsecret/0.20.5 -libuuid/1.0.3 -maddy/1.3.0 -sqlcipher/4.5.1 - -[generators] -CMakeDeps -CMakeToolchain - -[layout] -cmake_layout \ No newline at end of file diff --git a/conan/conanfile-windows.txt b/conan/conanfile-windows.txt deleted file mode 100644 index 20e3743..0000000 --- a/conan/conanfile-windows.txt +++ /dev/null @@ -1,15 +0,0 @@ -[requires] -boost/1.83.0 -gtest/1.14.0 -jsoncpp/1.9.5 -libcurl/8.4.0 -libgettext/0.22 -maddy/1.3.0 -sqlcipher/4.5.1 - -[generators] -CMakeDeps -CMakeToolchain - -[layout] -cmake_layout \ No newline at end of file diff --git a/conan/conanfile.py b/conan/conanfile.py new file mode 100644 index 0000000..e04593e --- /dev/null +++ b/conan/conanfile.py @@ -0,0 +1,31 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import cmake_layout +from conan.tools.build import check_min_cppstd + +class libauraRecipe(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeToolchain", "CMakeDeps" + + def validate(self): + check_min_cppstd(self, "20") + if self.settings.os != "Windows" and self.settings.os != "Linux": + raise ConanInvalidConfiguration("Only Windows and Linux are supported by libaura.") + + def requirements(self): + self.requires("boost/1.83.0") + self.requires("gtest/1.14.0") + self.requires("jsoncpp/1.9.5") + self.requires("libcurl/8.4.0") + self.requires("libgettext/0.22") + self.requires("maddy/1.3.0") + self.requires("sqlcipher/4.5.1") + if self.settings.os == "Linux": + self.requires("glib/2.78.1") + self.requires("libsecret/0.20.5") + self.requires("libuuid/1.0.3") + + def layout(self): + cmake_layout(self) \ No newline at end of file