diff --git a/CMakeLists.txt b/CMakeLists.txt index dd173c58..e4603c81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -193,10 +193,11 @@ elseif(APPLE) create_source_groups(MACOS_SOURCES) -elseif(LINUX) +elseif(UNIX AND NOT APPLE) + # Linux set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_STDLIB -std=c++17") - if (CMAKE_CXX_COMPILER MATCHES "clang") + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index f8015670..1c7fef42 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -7,10 +7,10 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release") set(CMAKE_CXX_STANDARD 17) -if(LINUX) +if(UNIX AND NOT APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - if(CLANG) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() diff --git a/sample_shared/CMakeLists.txt b/sample_shared/CMakeLists.txt index ed1e7821..b0107ac4 100644 --- a/sample_shared/CMakeLists.txt +++ b/sample_shared/CMakeLists.txt @@ -6,10 +6,10 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Release") set(CMAKE_CXX_STANDARD 17) -if(LINUX) +if(UNIX AND NOT APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") - if(CLANG) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() endif() diff --git a/setup.py b/setup.py index bc97e123..b5402a6f 100644 --- a/setup.py +++ b/setup.py @@ -101,6 +101,10 @@ def main(): triplet = f'{arch}-{platform}' + # match CMAKE_MSVC_RUNTIME_LIBRARY: /MD shared, /MT static + if args.platform.startswith('win'): + triplet = f'{arch}-windows-static-md' if args.shared else f'{arch}-windows-static' + if args.platform == 'osx': osx_arch = arch if arch == 'arm64' else 'x86_64' # no official universal triplet for osx vcpkg cmake_command += f' -DVCPKG_HOST_TRIPLET={triplet}' diff --git a/source/gameanalytics/GAState.cpp b/source/gameanalytics/GAState.cpp index f1e8d8de..ae6f694a 100644 --- a/source/gameanalytics/GAState.cpp +++ b/source/gameanalytics/GAState.cpp @@ -637,7 +637,9 @@ namespace gameanalytics } catch (json::exception& e) { - logging::GALogger::e(e.what()); + // discard unparseable cached config + logging::GALogger::w("Discarding incompatible cached sdk config: %s", e.what()); + store::GAStore::setState("sdk_config_cached", ""); } } diff --git a/source/gameanalytics/Platform/GALinux.cpp b/source/gameanalytics/Platform/GALinux.cpp index 417afb80..4862b49d 100644 --- a/source/gameanalytics/Platform/GALinux.cpp +++ b/source/gameanalytics/Platform/GALinux.cpp @@ -78,14 +78,26 @@ std::string gameanalytics::GAPlatformLinux::getOSVersion() struct utsname info; uname(&info); - std::string version; - int const strSize = strlen(info.release); + std::string version = info.release; + size_t const strSize = version.size(); + int dotCount = 0; for (size_t i = 0; i < strSize; ++i) { - if (!isdigit(info.release[i]) && info.release[i] != '.') + char const c = version[i]; + + if (c == '.') + { + ++dotCount; + if (dotCount == 3) + { + version.resize(i); + break; + } + } + else if (!isdigit(static_cast(c))) { - version = std::string(info.release, info.release + i); + version.resize(i); break; } }