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}") + 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) 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 */