From 3baf88ba0ac8ba4c02083af670d80626dcfe4744 Mon Sep 17 00:00:00 2001 From: Simon Hardt Date: Thu, 3 Jun 2021 02:54:44 +0200 Subject: [PATCH] Add: conan support --- .gitignore | 3 +++ CMakeLists.txt | 20 +++++++++++++++----- Modules/Server/CMakeLists.txt | 30 +++++++++++++++++++----------- Modules/Website/src/Files.elm | 5 ++--- conanfile.txt | 19 +++++++++++++++++++ 5 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 conanfile.txt diff --git a/.gitignore b/.gitignore index 3a3fd67..b337b5b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ CMakeSettings.json Modules/Website/elm-stuff/ Modules/Website/.vscode/settings.json + +build/ +.vscode/settings.json diff --git a/CMakeLists.txt b/CMakeLists.txt index c27ec1e..14a6676 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ cmake_minimum_required(VERSION 3.16) +option(USE_VCPKG "Use Vcpkg" OFF) +option(USE_CONAN "use conan" ON) + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{VCPKG_ROOT}) set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake") endif() @@ -7,14 +10,21 @@ message("using vcpkg toolchain: ${CMAKE_TOOLCHAIN_FILE}" ) project(localTube) + set(CMAKE_CXX_STANDARD 20) +if(NOT USE_CONAN) + find_package(fmt CONFIG REQUIRED) + find_package(SOCI CONFIG REQUIRED) + find_package(spdlog CONFIG REQUIRED) + find_package(nlohmann_json CONFIG REQUIRED) + find_package(Boost COMPONENTS system filesystem REQUIRED) + find_package(unofficial-sqlite3 CONFIG REQUIRED) +elseif(USE_CONAN) -find_package(fmt CONFIG REQUIRED) -find_package(soci CONFIG REQUIRED) -find_package(spdlog CONFIG REQUIRED) -find_package(nlohmann_json CONFIG REQUIRED) -find_package(Boost COMPONENTS system filesystem REQUIRED) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup() +endif() add_subdirectory(Modules) \ No newline at end of file diff --git a/Modules/Server/CMakeLists.txt b/Modules/Server/CMakeLists.txt index fc6c341..05c0852 100644 --- a/Modules/Server/CMakeLists.txt +++ b/Modules/Server/CMakeLists.txt @@ -8,16 +8,24 @@ set(src_files src/tables.hpp) -add_executable(. ${src_files}) +add_executable(localTubeServer ${src_files}) -target_link_libraries(. - fmt::fmt - spdlog::spdlog - SOCI::soci_core - SOCI::soci_empty - SOCI::soci_sqlite3 - nlohmann_json::nlohmann_json - Boost::boost - ${Boost_FILESYSTEM_LIBRARY} - ${Boost_SYSTEM_LIBRARY}) +if(USE_CONAN) + set(LIBS ${CONAN_LIBS}) +else() + set(LIBS + fmt::fmt + spdlog::spdlog + SOCI::soci_core + SOCI::soci_empty + SOCI::soci_sqlite3 + nlohmann_json::nlohmann_json + Boost::boost + ${Boost_FILESYSTEM_LIBRARY} + ${Boost_SYSTEM_LIBRARY}) +endif() + + +target_link_libraries(localTubeServer ${LIBS}) + diff --git a/Modules/Website/src/Files.elm b/Modules/Website/src/Files.elm index a6c98ff..f1c6671 100644 --- a/Modules/Website/src/Files.elm +++ b/Modules/Website/src/Files.elm @@ -1,6 +1,5 @@ module Files exposing (..) - -import Debug exposing (toString) +import String import Element exposing (..) import Element.Border as Border import Element.Font as Font @@ -177,7 +176,7 @@ viewFile file = , alignBottom , alignRight ] - { url = String.concat [ "http://127.0.0.1/api/file/", toString file.id ] + { url = String.concat [ "http://127.0.0.1/api/file/", String.fromInt file.id ] , label = text "Download" } ] diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..2a19c79 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,19 @@ +[requires] +boost/1.76.0 +soci/4.0.2 +fmt/7.1.3 +spdlog/1.8.5 +cpp-httplib/0.8.8 +magic_enum/0.7.2 +ctre/3.4.1 +nlohmann_json/3.9.1 + +[generators] +cmake + +[options] +soci:shared=True +soci:with_boost=True +soci:with_sqlite3=True +soci:with_odbc=True +soci:with_postgresql=True