diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c329a41 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,95 @@ +cmake_minimum_required (VERSION 3.8) + +set(PROJECT_NAME libLicenseClient) +project (${PROJECT_NAME}) + +# Download automatically, you can also just copy the conan.cmake file +if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") + message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") + file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake" + "${CMAKE_BINARY_DIR}/conan.cmake" + EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484 + TLS_VERIFY ON) +endif() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR}) + +include(${CMAKE_BINARY_DIR}/conan.cmake) + +conan_cmake_run(CONANFILE conanfile.txt + BUILD missing + BASIC_SETUP) + +################################################################################ +# Source groups +################################################################################ +set(api + "api/CachedDownloader.h" + "api/CryptoUtils.h" + "api/HTTPClient.h" + "api/IDownloader.h" + "api/IModuleDatabase.h" + "api/JSONModuleDatabase.h" + "api/JSONSerialization.h" + "api/LicenseClient.h" + "api/ModuleManager.h" + "api/ModuleUpdate.h" + "api/ModuleVersion.h" + "api/OSUtils.h" + "api/SystemParams.h" + "api/SystemParamsProvider.h" + "api/SystemParamsProvider_win.h" +) +source_group("api" FILES ${api}) + +set(src + "api/OSUtils.cpp" + "src/CachedDownloader.cpp" + "src/CryptoUtils.cpp" + "src/HashUtils.cpp" + "src/HashUtils.h" + "src/HTTPClient.cpp" + "src/JSONModuleDatabase.cpp" + "src/JSONSerialization.cpp" + "src/LicenseClient.cpp" + "src/ModuleManager.cpp" + "src/ModuleUpdate.cpp" + "src/SafeFileUtils.cpp" + "src/SafeFileUtils.h" + "src/SystemParams.cpp" + "src/SystemParamsProvider_win.cpp" +) +source_group("src" FILES ${src}) + +set(ALL_FILES + ${api} + ${src} +) + +################################################################################ +# Target +################################################################################ +add_library(${PROJECT_NAME} STATIC ${ALL_FILES}) + +# Find the QtWidgets library +message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") +find_package(cryptopp CONFIG) +find_package(curl CONFIG REQUIRED COMPONENTS libcurl) +find_package(libzip CONFIG REQUIRED COMPONENTS zip) +find_package(boost CONFIG REQUIRED COMPONENTS filesystem iostreams) + +# Required on Unix OS family to be able to be linked into shared libraries. +set_target_properties(${PROJECT_NAME} + PROPERTIES POSITION_INDEPENDENT_CODE ON) + +target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/api ) + +target_link_libraries(${PROJECT_NAME} cryptopp::cryptopp-static CURL::libcurl libzip::zip Boost::filesystem Boost::iostreams) + +# Expose public includes (including Boost transitively) to other +# subprojects through cache variable. +set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/api CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE) diff --git a/conanfile.txt b/conanfile.txt index ff3e5a1..205a141 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -5,7 +5,7 @@ boost/1.77.0 cryptopp/8.5.0 [generators] -visual_studio +cmake_find_package_multi [options] libzip:shared=False diff --git a/libLicenseClient.vcxproj b/libLicenseClient.vcxproj deleted file mode 100644 index 1a20dba..0000000 --- a/libLicenseClient.vcxproj +++ /dev/null @@ -1,134 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - 15.0 - {51345E59-83E5-4389-93A9-0131B40522B7} - Win32Proj - libLicenseClient - 8.1 - - - - StaticLibrary - true - v142 - MultiByte - - - StaticLibrary - false - v141 - true - MultiByte - - - - - - - - - - - - - - - - - - true - - - false - - - - NotUsing - Level3 - Disabled - true - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - stdcpplatest - /Zc:strictStrings- %(AdditionalOptions) - - - Windows - true - - - - - NotUsing - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - stdcpplatest - false - None - /Zc:strictStrings- %(AdditionalOptions) - - - Windows - true - true - false - YES - false - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/libLicenseClient.vcxproj.filters b/libLicenseClient.vcxproj.filters deleted file mode 100644 index 6a82fcd..0000000 --- a/libLicenseClient.vcxproj.filters +++ /dev/null @@ -1,111 +0,0 @@ - - - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - api - - - api - - - api - - - api - - - api - - - api - - - api - - - api - - - api - - - api - - - api - - - src - - - api - - - api - - - api - - - src - - - api - - - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - src - - - \ No newline at end of file diff --git a/non-debugable.props b/non-debugable.props deleted file mode 100644 index 2e86c09..0000000 --- a/non-debugable.props +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - false - - - - %(AdditionalIncludeDirectories) - BOOST_EXCEPTION_DISABLE;%(PreprocessorDefinitions) - %(AdditionalOptions) - false - None - - - %(AdditionalDependencies) - %(AdditionalOptions) - true - false - YES - false - - false - UseLinkTimeCodeGeneration - - - - \ No newline at end of file diff --git a/project-common.props b/project-common.props deleted file mode 100644 index 733f478..0000000 --- a/project-common.props +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - $(ProjectDir)api;%(AdditionalIncludeDirectories) - BOOST_EXCEPTION_DISABLE;%(PreprocessorDefinitions) - %(AdditionalOptions) - - - %(AdditionalLibraryDirectories) - %(AdditionalDependencies) - %(AdditionalOptions) - - - - \ No newline at end of file diff --git a/src/CachedDownloader.cpp b/src/CachedDownloader.cpp index bdd6060..7a4a996 100644 --- a/src/CachedDownloader.cpp +++ b/src/CachedDownloader.cpp @@ -1,5 +1,7 @@ #include "CachedDownloader.h" +#include + namespace { static const std::string cacheListFilename = ".downloadCache"; diff --git a/src/HTTPClient.cpp b/src/HTTPClient.cpp index 0d5f131..6d81bdb 100644 --- a/src/HTTPClient.cpp +++ b/src/HTTPClient.cpp @@ -75,7 +75,7 @@ static size_t reader(char *ptr, size_t size, size_t nmemb, std::istream *is) return static_cast(totalRead); } -static int writer(char *data, size_t size, size_t nmemb, std::ostream *os) +static size_t writer(char *data, size_t size, size_t nmemb, std::ostream *os) { if (os == NULL) return 0; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..0975d66 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,51 @@ +cmake_minimum_required (VERSION 3.8) + +set(PROJECT_NAME libLicenseClientTest) +project (${PROJECT_NAME}) + +# Download automatically, you can also just copy the conan.cmake file +if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") + message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") + file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.16.1/conan.cmake" + "${CMAKE_BINARY_DIR}/conan.cmake" + EXPECTED_HASH SHA256=396e16d0f5eabdc6a14afddbcfff62a54a7ee75c6da23f32f7a31bc85db23484 + TLS_VERIFY ON) +endif() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_PREFIX_PATH ${PROJECT_BINARY_DIR}) + +include(${CMAKE_BINARY_DIR}/conan.cmake) + +conan_cmake_run(CONANFILE conanfile.txt + BUILD missing + BASIC_SETUP) + +################################################################################ +# Source groups +################################################################################ +set(src + "libLicenseClientTest.cpp" + "src/JSONSerializationTest.cpp" +) +source_group("src" FILES ${src}) + +set(ALL_FILES + ${src} +) + +################################################################################ +# Target +################################################################################ +include_directories(${libLicenseClient_INCLUDE_DIRS}) + +add_executable(${PROJECT_NAME} ${ALL_FILES}) + +# Find the GTest library +message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") +find_package(GTest CONFIG REQUIRED COMPONENTS gtest gmock) + +target_link_libraries(${PROJECT_NAME} libLicenseClient GTest::gmock_main) diff --git a/test/conanfile.txt b/test/conanfile.txt index 6d1bbcc..7917000 100644 --- a/test/conanfile.txt +++ b/test/conanfile.txt @@ -1,10 +1,8 @@ [requires] -boost/1.69.0@conan/stable -gtest/1.8.1@bincrafters/stable +gtest/1.11.0 [generators] -visual_studio +cmake_find_package_multi [options] -boost:shared=False gtest:build_gmock=True diff --git a/test/libLicenseClientTest.vcxproj b/test/libLicenseClientTest.vcxproj deleted file mode 100644 index 3645ee8..0000000 --- a/test/libLicenseClientTest.vcxproj +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - 15.0 - {E781AE2E-4A02-4D63-9CAC-1AEBACD9CD73} - Win32Proj - libLicenseClientTest - 8.1 - - - - Application - true - v142 - MultiByte - - - Application - false - v142 - true - MultiByte - - - - - - - - - - - - - - - - - true - - - false - - - - NotUsing - Level3 - Disabled - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(ProjectDir)..\api;%(AdditionalIncludeDirectories) - - - - Console - true - gmock_maind.lib;%(AdditionalDependencies) - - - - - NotUsing - Level3 - MaxSpeed - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - $(ProjectDir)..\api;%(AdditionalIncludeDirectories) - - - - Console - true - true - true - gmock_main.lib;%(AdditionalDependencies) - - - - - - - - - {51345e59-83e5-4389-93a9-0131b40522b7} - - - - - - \ No newline at end of file diff --git a/test/libLicenseClientTest.vcxproj.filters b/test/libLicenseClientTest.vcxproj.filters deleted file mode 100644 index c7e8896..0000000 --- a/test/libLicenseClientTest.vcxproj.filters +++ /dev/null @@ -1,25 +0,0 @@ - - - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - - - src - - - src - - - \ No newline at end of file