diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d66c8ee..c4800a7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,7 +12,6 @@ permissions: env: BUILD_TYPE: Release GITHUB_ACTIONS: true - VCPKG_ROOT: ${{github.workspace}}/vcpkg jobs: build: name: ${{ matrix.config.name }} @@ -42,25 +41,26 @@ jobs: sudo apt-get install gettext tzdata locales -y sudo locale-gen en_US.UTF-8 sudo update-locale LANG=en_US.UTF-8 - - name: "Vcpkg" - uses: johnwason/vcpkg-action@v5 - id: vcpkg - with: - pkgs: boost-locale curl gettext gettext-libintl glib gtest jsoncpp libsecret libuuid maddy sqlcipher - triplet: x64-linux - cache-key: ${{ matrix.config.os }} - revision: 64e15f6669480b2d2bff1e5e815c571a8213421e - token: ${{ secrets.GITHUB_TOKEN }} - extra-args: "--allow-unsupported" + - name: "Get Conan" + uses: turtlebrowser/get-conan@main + - name: "Setup Conan Settings" + run: | + mv conan/conansettings.yml settings_user.yml + conan config install settings_user.yml + - name: "Install Conan" + run: | + mv conan/conanfile-linux.txt conanfile.txt + 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 - name: "CMake Build" working-directory: ${{github.workspace}}/build run: | - cmake .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + cmake .. -DCMAKE_TOOLCHAIN_FILE="${{github.workspace}}/build/Release/generators/conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} cmake --build . - name: "CMake Install" working-directory: ${{github.workspace}}/build run: cmake --install . --prefix "${{github.workspace}}/install" - - name: "CMake Test" + - name: "Test" run: ${{github.workspace}}/build/libaura_test - name: Upload uses: actions/upload-artifact@v3 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 81a2913..b9b2614 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -12,7 +12,6 @@ permissions: env: BUILD_TYPE: Release GITHUB_ACTIONS: true - VCPKG_ROOT: ${{github.workspace}}/vcpkg jobs: build: name: ${{ matrix.config.name }} @@ -28,24 +27,22 @@ jobs: uses: actions/checkout@v4 with: submodules: recursive - - name: "Vcpkg" - uses: johnwason/vcpkg-action@v5 - id: vcpkg - with: - pkgs: boost-locale curl gettext gettext-libintl gtest jsoncpp maddy sqlcipher - triplet: x64-windows - cache-key: ${{ matrix.config.os }} - revision: 64e15f6669480b2d2bff1e5e815c571a8213421e - token: ${{ secrets.GITHUB_TOKEN }} + - name: "Get Conan" + uses: turtlebrowser/get-conan@main + - name: "Install Conan" + run: | + move conan/conanfile-windows.txt conanfile.txt + 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 - name: "CMake Build" working-directory: ${{github.workspace}}/build run: | - cmake -G "Visual Studio 17 2022" .. + cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="${{github.workspace}}/build/generators/conan_toolchain.cmake" cmake --build . --config ${{env.BUILD_TYPE}} - name: "CMake Install" working-directory: ${{github.workspace}}/build run: cmake --install . --prefix "${{github.workspace}}/install" - - name: "CMake Test" + - name: "Test" run: ${{github.workspace}}/build/Release/libaura_test.exe - name: Upload uses: actions/upload-artifact@v3 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4812e55..da8301e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") set(SQLITE_HAS_CODEC ON) if(WIN32) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) @@ -55,26 +54,25 @@ set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION}) #libaura Packages -find_package(Boost REQUIRED COMPONENTS locale) +find_package(Boost COMPONENTS locale REQUIRED) find_package(CURL REQUIRED) find_package(jsoncpp REQUIRED) find_package(Intl REQUIRED) -find_package(unofficial-maddy REQUIRED) -find_package(sqlcipher CONFIG REQUIRED) -target_link_libraries(${PROJECT_NAME} PRIVATE Boost::boost Boost::locale CURL::libcurl JsonCpp::JsonCpp Intl::Intl unofficial::maddy::maddy sqlcipher::sqlcipher) +find_package(maddy REQUIRED) +find_package(sqlcipher REQUIRED CONFIG) +target_link_libraries(${PROJECT_NAME} PUBLIC Boost::locale CURL::libcurl JsonCpp::JsonCpp Intl::Intl maddy::maddy sqlcipher::sqlcipher) if(LINUX) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) + find_package(libsecret REQUIRED CONFIG) + find_package(libuuid REQUIRED CONFIG) find_package(PkgConfig REQUIRED) - find_package(unofficial-libuuid CONFIG REQUIRED) - pkg_check_modules(glib REQUIRED IMPORTED_TARGET glib-2.0) - pkg_check_modules(gio REQUIRED IMPORTED_TARGET gio-2.0) - pkg_check_modules(gmodule REQUIRED IMPORTED_TARGET gmodule-2.0) - pkg_check_modules(gobject REQUIRED IMPORTED_TARGET gobject-2.0) - pkg_check_modules(gthread REQUIRED IMPORTED_TARGET gthread-2.0) - pkg_check_modules(libsecret REQUIRED IMPORTED_TARGET libsecret-1) - pkg_check_modules(libuuid REQUIRED IMPORTED_TARGET libuuid-1) - target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads PkgConfig::glib PkgConfig::gio PkgConfig::gmodule PkgConfig::gobject PkgConfig::gthread PkgConfig::libsecret unofficial::libuuid::libuuid) + pkg_check_modules(glib-2.0 REQUIRED IMPORTED_TARGET glib-2.0) + pkg_check_modules(gio-2.0 REQUIRED IMPORTED_TARGET gio-2.0) + pkg_check_modules(gmodule-2.0 REQUIRED IMPORTED_TARGET gmodule-2.0) + pkg_check_modules(gobject-2.0 REQUIRED IMPORTED_TARGET gobject-2.0) + pkg_check_modules(gthread-2.0 REQUIRED IMPORTED_TARGET gthread-2.0) + target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads libsecret::libsecret libuuid::libuuid PkgConfig::glib-2.0 PkgConfig::gio-2.0 PkgConfig::gmodule-2.0 PkgConfig::gobject-2.0 PkgConfig::gthread-2.0) endif() if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4) @@ -105,7 +103,7 @@ if (NOT BUILD_TESTING STREQUAL OFF) #libaura_test Packages find_package(GTest REQUIRED) - target_link_libraries(${PROJECT_NAME}_test PRIVATE GTest::gtest_main GTest::gmock_main JsonCpp::JsonCpp ${PROJECT_NAME}) + target_link_libraries(${PROJECT_NAME}_test PUBLIC libaura GTest::gtest_main GTest::gmock_main) endif() #libaura Install diff --git a/README.md b/README.md index f706e1a..75efd15 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,46 @@ libaura provides Nickvision apps with a common set of cross-platform (Windows an Documentation for this library and its modules can be found [here](/docs). -## Building and Installing -libaura uses `vcpkg` to manage its dependencies and `cmake` as its build system. - -### Configuring vcpkg -Once vcpkg is installed on your system: -1. Set the `VCPKG_ROOT` environment variable to the path of your vcpkg installation's root directory. -#### Windows -1. Set `VCPKG_DEFAULT_TRIPLET` to `x64-windows` -1. Run `vcpkg install boost-locale curl gettext gettext-libintl gtest jsoncpp maddy sqlcipher` -#### Linux -1. Set `VCPKG_DEFAULT_TRIPLET` to `x64-linux` -1. Run `vcpkg install boost-locale curl gettext gettext-libintl glib gtest jsoncpp libsecret libuuid maddy sqlcipher` - -### Building libaura \ No newline at end of file +## Installation with Conan + +TODO + +## Manual Building and Installation +libaura uses Conan package manager for resolving dependencies and CMake as it's build system. + +Ensure both `conan` and `cmake` are installed on your system before building libaura. + +A C++20 compiler is also required to build libaura. + +### Windows +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. 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. 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. +1. From the `build` folder, run ``cmake --build . --config Release`. +1. After these commands, libaura will be successfully built and its binaries can be found in the `Release` folder of the `build` folder. +1. To install libaura to the system, from the `build` folder, run `cmake --install . --prefix "PATH_TO_INSTALL_DIR"`. + - Replace `PATH_TO_INSTALL_DIR` with the path to a folder to install libaura to. This is usually a dependencies folder set up by the programmer, added to the PATH variable, to allow linking to said dependencies. +1. If contributing to upstream, remove `conanfile-windows.txt` and `conanprofile-windows.txt` from the repo's root directory as to not accidentally add and commit them. + +### 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. 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. 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. +1. From the `build` folder, run `cmake --build`. +1. After these commands, libaura will be successfully built and its binaries can be found in the `Release` folder of the `build` folder. +1. To install libaura to the system, from the `build` folder, run `cmake --install . --prefix "PATH_TO_INSTALL_DIR"`. + - Replace `PATH_TO_INSTALL_DIR` with the path to a folder to install libaura to. This is usually a dependencies folder set up by the programmer, added to the PATH variable, to allow linking to said dependencies. + - On linux, `PATH_TO_INSTALL_DIR` would usually be `/usr`. +1. If contributing to upstream, remove `conanfile-windows.txt` and `conanprofile-windows.txt` from the repo's root directory as to not accidentally add and commit them. \ No newline at end of file diff --git a/conan/conanfile-linux.txt b/conan/conanfile-linux.txt new file mode 100644 index 0000000..ce664f0 --- /dev/null +++ b/conan/conanfile-linux.txt @@ -0,0 +1,18 @@ +[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 new file mode 100644 index 0000000..20e3743 --- /dev/null +++ b/conan/conanfile-windows.txt @@ -0,0 +1,15 @@ +[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/conanprofile-linux.txt b/conan/conanprofile-linux.txt new file mode 100644 index 0000000..633fcb7 --- /dev/null +++ b/conan/conanprofile-linux.txt @@ -0,0 +1,10 @@ +[settings] +arch=x86_64 +build_type=Release +compiler=gcc +compiler.cppstd=gnu20 +compiler.libcxx=libstdc++11 +compiler.version=11 +os=Linux +os.libc=glibc +os.libc.version=2.35 \ No newline at end of file diff --git a/conan/conanprofile-windows.txt b/conan/conanprofile-windows.txt new file mode 100644 index 0000000..94c9e6e --- /dev/null +++ b/conan/conanprofile-windows.txt @@ -0,0 +1,9 @@ +[settings] +arch=x86_64 +build_type=Release +compiler=msvc +compiler.cppstd=20 +compiler.runtime=dynamic +compiler.runtime_type=Release +compiler.version=193 +os=Windows diff --git a/conan/conansettings.yml b/conan/conansettings.yml new file mode 100644 index 0000000..cbe9824 --- /dev/null +++ b/conan/conansettings.yml @@ -0,0 +1,6 @@ +os: + Linux: + libc: + null: + glibc: + version: ["2.35", "2.36", "2.37", "2.38"] \ No newline at end of file