From 3921ac8ba2c8b1cca4cc949876cb53ac9d668fc6 Mon Sep 17 00:00:00 2001 From: gamefunc <32686647@qq.com> Date: Thu, 19 Nov 2020 05:25:08 +0800 Subject: [PATCH 1/3] Update base64.cpp add msvc check --- base64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base64.cpp b/base64.cpp index 5643135..dd367fe 100644 --- a/base64.cpp +++ b/base64.cpp @@ -228,7 +228,7 @@ std::string base64_encode_mime(std::string const& s) { return encode_mime(s); } -#if __cplusplus >= 201703L +#if (__cplusplus >= 201703L) || (_MSC_VER >= 1910) // // Interface with std::string_view rather than const std::string& // Requires C++17 @@ -251,4 +251,4 @@ std::string base64_decode(std::string_view s, bool remove_linebreaks) { return decode(s, remove_linebreaks); } -#endif // __cplusplus >= 201703L +#endif // (__cplusplus >= 201703L) || (_MSC_VER >= 1910) From b35ea66f998a0161bbe002ef162ed4d9e273fad2 Mon Sep 17 00:00:00 2001 From: gamefunc <32686647@qq.com> Date: Thu, 19 Nov 2020 05:25:37 +0800 Subject: [PATCH 2/3] Update base64.h add msvc check --- base64.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/base64.h b/base64.h index 09f75a8..1af71c1 100644 --- a/base64.h +++ b/base64.h @@ -8,9 +8,9 @@ #include -#if __cplusplus >= 201703L +#if (__cplusplus >= 201703L) || (_MSC_VER >= 1910) #include -#endif // __cplusplus >= 201703L +#endif // (__cplusplus >= 201703L) || (_MSC_VER >= 1910) std::string base64_encode (std::string const& s, bool url = false); std::string base64_encode_pem (std::string const& s); @@ -19,7 +19,7 @@ std::string base64_encode_mime(std::string const& s); std::string base64_decode(std::string const& s, bool remove_linebreaks = false); std::string base64_encode(unsigned char const*, size_t len, bool url = false); -#if __cplusplus >= 201703L +#if (__cplusplus >= 201703L) || (_MSC_VER >= 1910) // // Interface with std::string_view rather than const std::string& // Requires C++17 @@ -30,6 +30,6 @@ std::string base64_encode_pem (std::string_view s); std::string base64_encode_mime(std::string_view s); std::string base64_decode(std::string_view s, bool remove_linebreaks = false); -#endif // __cplusplus >= 201703L +#endif // (__cplusplus >= 201703L) || (_MSC_VER >= 1910) #endif /* BASE64_H_C0CE2A47_D10E_42C9_A27C_C883944E704A */ From 6edd5a17327405189f9138c15245273162554ed1 Mon Sep 17 00:00:00 2001 From: gamefunc <32686647@qq.com> Date: Thu, 19 Nov 2020 05:26:26 +0800 Subject: [PATCH 3/3] Create CMakeLists.txt add cmake --- CMakeLists.txt | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..86cdf53 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,47 @@ +# find your Generators: +# cmd: cmake -G + +# example, system default Generators, linux=gcc, windows=msvc: +# cd L:\0_cpp_plus\base64 +# mkdir L:\0_cpp_plus\base64\build +# cd L:\0_cpp_plus\base64\build +# cmake .. +# cmake --build . --config Release +# lib path: + +# example, minGW: +# cd L:\0_cpp_plus\base64 +# mkdir L:\0_cpp_plus\base64\gcc +# cd L:\0_cpp_plus\base64\gcc +# cmake -G "MinGW Makefiles" .. +# cmake --build . --config Release +# lib path: L:\0_cpp_plus\base64\gcc\libbase64.a + +# example, msvc: +# cd L:\0_cpp_plus\base64 +# mkdir L:\0_cpp_plus\base64\msvc +# cd L:\0_cpp_plus\base64\msvc +# cmake -G "Visual Studio 16 2019" .. +# cmake --build . --config Release +# lib path: L:\0_cpp_plus\base64\msvc\Release\base64.lib + + +cmake_minimum_required(VERSION 3.8) +project(base64 VERSION 0.1.0) +set(CMAKE_VERBOSE_MAKEFILE ON) + +set(CMAKE_CXX_STANDARD_REQUIRED 11) +set(CMAKE_CXX_STANDARD 17) + +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + add_compile_options("/utf-8") + add_compile_options("/O2") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + add_compile_options("-O3") +endif() + +include_directories(${PROJECT_SOURCE_DIR}) +add_library(base64 base64.cpp) + +message("project dir: ${PROJECT_SOURCE_DIR}") +