Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add msvc check & cmake #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}")

4 changes: 2 additions & 2 deletions base64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
8 changes: 4 additions & 4 deletions base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <string>

#if __cplusplus >= 201703L
#if (__cplusplus >= 201703L) || (_MSC_VER >= 1910)
#include <string_view>
#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);
Expand All @@ -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
Expand All @@ -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 */