From 0fe40ec263b1f0a26baf5fcd9268a6b9cfc2f1e0 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Wed, 29 Apr 2026 13:59:43 -0700 Subject: [PATCH 1/8] Apply CMake best practices and remove stale references - Modernize CMakeLists.txt: flatten nesting, deduplicate, use consistent quoting and variable patterns - Remove stale header references from vcxproj and vcxitems files - Simplify test CMakeLists.txt files - Fix CMake conventions in packaging scripts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 66 +++++++------------ Solutions/before.targets | 5 +- Solutions/build.MIP.props | 3 +- examples/cpp/SampleCpp/SampleCpp.vcxproj | 1 - .../cpp/SampleCpp/SampleCpp.vcxproj.filters | 3 - .../cpp/SampleCppMini/SampleCppMini.vcxproj | 1 - .../SampleCppMini.vcxproj.filters | 5 -- lib/CMakeLists.txt | 44 ++++++------- lib/shared/Shared.vcxitems | 1 - lib/shared/Shared.vcxitems.filters | 1 - tests/functests/CMakeLists.txt | 40 +++++------ tests/functests/FuncTests.vcxproj | 1 - tests/functests/FuncTests.vcxproj.filters | 3 - tests/unittests/CMakeLists.txt | 33 +++++----- tests/unittests/UnitTests.vcxproj | 1 - tools/MakeDeb.cmake | 2 +- tools/MakeRpm.cmake | 2 +- tools/MakeTgz.cmake | 3 +- tools/ParseOsRelease.cmake | 4 +- 19 files changed, 85 insertions(+), 134 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9851cf4d9..e7306afe8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.1.0) -project(MSTelemetry) +project(MSTelemetry LANGUAGES C CXX) # Set installation prefix for macOS and Linux if(UNIX AND NOT DEFINED CMAKE_INSTALL_PREFIX) @@ -25,7 +25,7 @@ endif() # Enable ARC for obj-c on Apple if(APPLE) - message("-- BUILD_IOS: ${BUILD_IOS}") + message(STATUS "BUILD_IOS: ${BUILD_IOS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fobjc-arc") # iOS build options @@ -77,9 +77,9 @@ if(APPLE) OUTPUT_VARIABLE CMAKE_OSX_SYSROOT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - message("-- CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}") - message("-- ARCHITECTURE: ${CMAKE_SYSTEM_PROCESSOR}") - message("-- PLATFORM: ${IOS_PLATFORM}") + message(STATUS "CMAKE_OSX_SYSROOT ${CMAKE_OSX_SYSROOT}") + message(STATUS "ARCHITECTURE: ${CMAKE_SYSTEM_PROCESSOR}") + message(STATUS "PLATFORM: ${IOS_PLATFORM}") else() if(${MAC_ARCH} STREQUAL "x86_64") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") @@ -99,18 +99,18 @@ if(APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64 -arch arm64") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -arch arm64") endif() - message("-- MAC_ARCH: ${MAC_ARCH}") + message(STATUS "MAC_ARCH: ${MAC_ARCH}") endif() endif() -message("-- CMAKE_SYSTEM_INFO_FILE: ${CMAKE_SYSTEM_INFO_FILE}") -message("-- CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") -message("-- CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") -message("-- CMAKE_SYSTEM: ${CMAKE_SYSTEM}") -message("-- CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}") -message("-- CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") -message("-- TARGET_ARCH: ${TARGET_ARCH}") -message("-- CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") +message(STATUS "CMAKE_SYSTEM_INFO_FILE: ${CMAKE_SYSTEM_INFO_FILE}") +message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") +message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") +message(STATUS "CMAKE_SYSTEM: ${CMAKE_SYSTEM}") +message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}") +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +message(STATUS "TARGET_ARCH: ${TARGET_ARCH}") +message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") include(tools/ParseOsRelease.cmake) @@ -147,12 +147,12 @@ set(DBG_FLAGS "-ggdb -gdwarf-2 -O0 ${WARN_FLAGS} -fno-builtin-malloc -fno-built if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") #TODO: -fno-rtti - message("Building Release ...") + message(STATUS "Building Release ...") set(CMAKE_C_FLAGS "$ENV{CFLAGS} ${CMAKE_C_FLAGS} -std=c11 ${REL_FLAGS}") set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS} -std=c++11 ${REL_FLAGS}") else() set(USE_TCMALLOC 1) - message("Building Debug ...") + message(STATUS "Building Debug ...") include(tools/FindTcmalloc.cmake) set(CMAKE_C_FLAGS "$ENV{CFLAGS} ${CMAKE_C_FLAGS} -std=c11 ${DBG_FLAGS}") set(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS} -std=c++11 ${DBG_FLAGS}") @@ -167,17 +167,10 @@ if(MSVC) endif() endif() -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # using Clang -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # using GCC - # Prefer to generate position-independent code +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # GCC needs explicit position-independent code set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - # using Intel C++ -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # using Visual Studio C++ endif() include(tools/Utils.cmake) @@ -193,7 +186,7 @@ endif() set(PAL_IMPLEMENTATION ${DEFAULT_PAL_IMPLEMENTATION}) -message(STATUS "-- PAL implementation: ${PAL_IMPLEMENTATION}") +message(STATUS "PAL implementation: ${PAL_IMPLEMENTATION}") string(TOUPPER ${PAL_IMPLEMENTATION} PAL_IMPLEMENTATION_UPPER) add_definitions(-DMATSDK_PAL_${PAL_IMPLEMENTATION_UPPER}=1) @@ -225,7 +218,7 @@ add_definitions(-DNOMINMAX) set(SDK_VERSION_PREFIX "EVT") add_definitions("-DMATSDK_VERSION_PREFIX=\"${SDK_VERSION_PREFIX}\"") -set(MATSDK_API_VERSION "3.4") +set(MATSDK_API_VERSION "3.10") string(TIMESTAMP DAYNUMBER "%j") string(REGEX REPLACE "^00" "" DAYNUMBER ${DAYNUMBER}) string(REGEX REPLACE "^0" "" DAYNUMBER ${DAYNUMBER}) @@ -241,7 +234,7 @@ else() set(MATSDK_BUILD_VERSION ${MATSDK_API_VERSION}.${DAYNUMBER}.0) endif() -message(STATUS "-- SDK version: ${SDK_VERSION_PREFIX}-${MATSDK_BUILD_VERSION}") +message(STATUS "SDK version: ${SDK_VERSION_PREFIX}-${MATSDK_BUILD_VERSION}") ################################################################################################ # HTTP stack section @@ -289,9 +282,9 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() if(BUILD_UNIT_TESTS OR BUILD_FUNC_TESTS) - message("Adding gtest") + message(STATUS "Adding gtest") add_library(gtest STATIC IMPORTED GLOBAL) - message("Adding gmock") + message(STATUS "Adding gmock") add_library(gmock STATIC IMPORTED GLOBAL) endif() @@ -299,17 +292,10 @@ if(BUILD_APPLE_HTTP) add_definitions(-DAPPLE_HTTP=1) endif() -# Bond Lite subdirectories include_directories(bondlite/include) include_directories(lib/pal) -#if(BUILD_UNIT_TESTS) -# message("Adding bondlite tests") -# enable_testing() -# add_subdirectory(bondlite/tests) -#endif() - # Include repo root to allow includes of sqlite, zlib, and nlohmann include_directories(${CMAKE_SOURCE_DIR}) @@ -323,7 +309,7 @@ if(BUILD_LIBRARY) endif() if(BUILD_UNIT_TESTS OR BUILD_FUNC_TESTS) - message("Building tests") + message(STATUS "Building tests") enable_testing() add_subdirectory(tests) endif() @@ -334,18 +320,14 @@ endif() if (BUILD_PACKAGE) if ("${CMAKE_PACKAGE_TYPE}" STREQUAL "deb") - # FIXME: hardcode it for 64-bit Linux for now set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/${CPACK_DEBIAN_ARCHITECTURE}-linux-gnu) include(tools/MakeDeb.cmake) endif() if ("${CMAKE_PACKAGE_TYPE}" STREQUAL "rpm") - # TODO: [MG] - fix path set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) include(tools/MakeRpm.cmake) endif() if ("${CMAKE_PACKAGE_TYPE}" STREQUAL "tgz") - # TODO: [MG] - fix path... should we simply use /usr/local/lib without CPU? - # TODO: [MG] - Windows path is not ideal -- C:/Program Files (x86)/MSTelemetry/* - what should we use instead? include(tools/MakeTgz.cmake) endif() endif() diff --git a/Solutions/before.targets b/Solutions/before.targets index 63a526c90..a31ed4e93 100644 --- a/Solutions/before.targets +++ b/Solutions/before.targets @@ -6,8 +6,9 @@ v141 v142 v143 - - v141 + v145 + + $(DefaultPlatformToolset) $(PlatformToolset) $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) diff --git a/Solutions/build.MIP.props b/Solutions/build.MIP.props index 9bd6e6d91..14ed449b9 100644 --- a/Solutions/build.MIP.props +++ b/Solutions/build.MIP.props @@ -10,8 +10,7 @@ true - v141 - 14.1 + $(DefaultPlatformToolset) mip_ClientTelemetry diff --git a/examples/cpp/SampleCpp/SampleCpp.vcxproj b/examples/cpp/SampleCpp/SampleCpp.vcxproj index 500d966f6..ffa49633a 100644 --- a/examples/cpp/SampleCpp/SampleCpp.vcxproj +++ b/examples/cpp/SampleCpp/SampleCpp.vcxproj @@ -1080,7 +1080,6 @@ - diff --git a/examples/cpp/SampleCpp/SampleCpp.vcxproj.filters b/examples/cpp/SampleCpp/SampleCpp.vcxproj.filters index 9a605a027..ae87cc1f8 100644 --- a/examples/cpp/SampleCpp/SampleCpp.vcxproj.filters +++ b/examples/cpp/SampleCpp/SampleCpp.vcxproj.filters @@ -15,9 +15,6 @@ - - Header Files - Source Files diff --git a/examples/cpp/SampleCppMini/SampleCppMini.vcxproj b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj index 88bca8d6d..424394f7e 100644 --- a/examples/cpp/SampleCppMini/SampleCppMini.vcxproj +++ b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj @@ -1542,7 +1542,6 @@ - diff --git a/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters index ad3de7523..2df19ab39 100644 --- a/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters +++ b/examples/cpp/SampleCppMini/SampleCppMini.vcxproj.filters @@ -14,11 +14,6 @@ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - Header Files - - Source Files diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 4ebe7ddb0..8824427b4 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,7 +1,7 @@ # Honor visibility properties for all target types cmake_policy(SET CMP0063 NEW) -include_directories( . ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/public ${CMAKE_CURRENT_SOURCE_DIR}/include/public ${CMAKE_CURRENT_SOURCE_DIR}/include/mat ${CMAKE_CURRENT_SOURCE_DIR}/pal ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/Reachability ${CMAKE_CURRENT_SOURCE_DIR}/modules/cds ${CMAKE_CURRENT_SOURCE_DIR}/modules/signals ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer /usr/local/include ) +include_directories( . ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include/public ${CMAKE_CURRENT_SOURCE_DIR}/include/mat ${CMAKE_CURRENT_SOURCE_DIR}/pal ${CMAKE_CURRENT_SOURCE_DIR}/utils ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/Reachability ${CMAKE_CURRENT_SOURCE_DIR}/modules/cds ${CMAKE_CURRENT_SOURCE_DIR}/modules/signals ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer /usr/local/include ) set(SRCS decorators/BaseDecorator.cpp packager/BondSplicer.cpp @@ -60,7 +60,7 @@ if(BUILD_AZMON) include(modules/azmon/CMakeLists.txt OPTIONAL) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp/) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/exp/") list(APPEND SRCS modules/exp/afd/afdclient/AFDClientUtils.cpp modules/exp/afd/afdclient/AFDClient.cpp @@ -74,14 +74,14 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp/) ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/") list(APPEND SRCS modules/dataviewer/DefaultDataViewer.cpp modules/dataviewer/OnDisableNotificationCollection.cpp ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYGUARD) list(APPEND SRCS modules/privacyguard/PrivacyGuard.cpp modules/privacyguard/RegisteredFileTypes.cpp @@ -89,14 +89,14 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUA ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/ AND BUILD_LIVEEVENTINSPECTOR) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/" AND BUILD_LIVEEVENTINSPECTOR) list(APPEND SRCS modules/liveeventinspector/LiveEventInspector.cpp modules/liveeventinspector/LiveEventInspector.hpp ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/cds/ AND BUILD_CDS) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/cds/" AND BUILD_CDS) add_definitions(-DHAVE_MAT_CDS) list(APPEND SRCS modules/cds/CdsFactory.hpp @@ -104,14 +104,14 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/cds/ AND BUILD_CDS) ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/signals/ AND BUILD_SIGNALS) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/signals/" AND BUILD_SIGNALS) list(APPEND SRCS modules/signals/Signals.cpp modules/signals/SignalsEncoder.cpp ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/" AND BUILD_SANITIZER) list(APPEND SRCS modules/sanitizer/detectors/EmailAddressDetector.cpp modules/sanitizer/detectors/JwtDetector.cpp @@ -181,7 +181,7 @@ if(PAL_IMPLEMENTATION STREQUAL "CPP11") ) endif() if(APPLE AND BUILD_OBJC_WRAPPER) - message("Include ObjC Wrappers") + message(STATUS "Include ObjC Wrappers") list(APPEND SRCS ../wrappers/obj-c/ODWLogger.mm ../wrappers/obj-c/ODWLogManager.mm @@ -189,19 +189,19 @@ if(PAL_IMPLEMENTATION STREQUAL "CPP11") ../wrappers/obj-c/ODWLogConfiguration.mm ../wrappers/obj-c/ODWSemanticContext.mm ) - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/") list(APPEND SRCS ../wrappers/obj-c/ODWDiagnosticDataViewer.mm ) endif() - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYGUARD) list(APPEND SRCS ../wrappers/obj-c/ODWCommonDataContext.mm ../wrappers/obj-c/ODWPrivacyGuard.mm ../wrappers/obj-c/ODWPrivacyGuardInitConfig.mm ) endif() - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/" AND BUILD_SANITIZER) list(APPEND SRCS ../wrappers/obj-c/ODWSanitizerInitConfig.mm ../wrappers/obj-c/ODWSanitizer.mm @@ -210,7 +210,7 @@ if(PAL_IMPLEMENTATION STREQUAL "CPP11") endif() if(APPLE AND BUILD_SWIFT_WRAPPER) - message("Building Swift Wrappers") + message(STATUS "Building Swift Wrappers") # Run swift build for the Swift Wrappers Package string(TOLOWER ${CMAKE_BUILD_TYPE} LOWER_BUILD_TYPE) execute_process( @@ -222,9 +222,9 @@ if(PAL_IMPLEMENTATION STREQUAL "CPP11") ) if(SWIFT_BUILD_RESULT EQUAL 0) - message("Swift Wrappers build succeeded!") + message(STATUS "Swift Wrappers build succeeded!") else() - message(FATAL_ERROR, "Swift build failed with error code: ${SWIFT_BUILD_RESULT}") + message(FATAL_ERROR "Swift build failed with error code: ${SWIFT_BUILD_RESULT}") endif() endif() @@ -247,7 +247,7 @@ remove_definitions(-D_MBCS) ) # UTC module - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/utc) + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/utc") list(APPEND SRCS modules/utc/desktop/UtcHelpers.cpp modules/utc/UtcTelemetrySystem.cpp @@ -259,7 +259,7 @@ else() endif() # Filtering module -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/filter) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/filter") list(APPEND SRCS modules/filter/CompliantByDefaultEventFilterModule.cpp modules/filter/CompliantByDefaultFilterApi.cpp @@ -278,7 +278,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") endif() if(BUILD_SHARED_LIBS STREQUAL "ON") - message("-- Building shared SDK library") + message(STATUS "Building shared SDK library") # include(FindCURL) # find_package(CURL REQUIRED) @@ -313,7 +313,7 @@ if(BUILD_SHARED_LIBS STREQUAL "ON") # target_link_libraries(mat PUBLIC libsqlite3 libcurl.a libz.a libssl.a libcrypto.a "${SQLITE_LIBRARY}" "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" ) install(TARGETS mat EXPORT mat LIBRARY DESTINATION ${INSTALL_LIB_DIR}) else() - message("-- Building static SDK library") + message(STATUS "Building static SDK library") add_library(mat STATIC ${SRCS}) if(LINK_STATIC_DEPENDS) if(PAL_IMPLEMENTATION STREQUAL "WIN32") @@ -336,10 +336,6 @@ else() install(TARGETS mat EXPORT mat ARCHIVE DESTINATION ${INSTALL_LIB_DIR}) endif() -message("-- Library will be installed to ${INSTALL_LIB_DIR}") +message(STATUS "Library will be installed to ${INSTALL_LIB_DIR}") -#if(PAL_IMPLEMENTATION STREQUAL "CPP11") -# #target_link_libraries(mat PUBLIC libcurl.a libz.a libssl.a libcrypto.a "${SQLITE_LIBRARY}" "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" ) -# #target_link_libraries(mat PUBLIC libsqlite3.a libz.a ${LIBS} "${CMAKE_THREAD_LIBS_INIT}" "${CMAKE_DL_LIBS}" ) -#endif() diff --git a/lib/shared/Shared.vcxitems b/lib/shared/Shared.vcxitems index bf3d5df64..4b7c095ff 100644 --- a/lib/shared/Shared.vcxitems +++ b/lib/shared/Shared.vcxitems @@ -24,7 +24,6 @@ - diff --git a/lib/shared/Shared.vcxitems.filters b/lib/shared/Shared.vcxitems.filters index c488b869b..1868316bf 100644 --- a/lib/shared/Shared.vcxitems.filters +++ b/lib/shared/Shared.vcxitems.filters @@ -1,7 +1,6 @@  - diff --git a/tests/functests/CMakeLists.txt b/tests/functests/CMakeLists.txt index 656f8f866..afffaf283 100644 --- a/tests/functests/CMakeLists.txt +++ b/tests/functests/CMakeLists.txt @@ -1,4 +1,4 @@ -message("--- functests") +message(STATUS "Building functests") set(SRCS APITest.cpp @@ -8,47 +8,40 @@ set(SRCS MultipleLogManagersTests.cpp ) -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYGUARD) add_definitions(-DHAVE_MAT_PRIVACYGUARD) list(APPEND SRCS PrivacyGuardFuncTests.cpp ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/" AND BUILD_SANITIZER) list(APPEND SRCS SanitizerFuncTests.cpp ) endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/") list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/tests/functests/DefaultDataViewerFuncTests.cpp ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/ AND BUILD_LIVEEVENTINSPECTOR) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/" AND BUILD_LIVEEVENTINSPECTOR) add_definitions(-DHAVE_MAT_LIVEEVENTINSPECTOR) list(APPEND SRCS LiveEventInspectorFuncTests.cpp ) endif() -if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests) +if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/exp/tests") list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSClientFuncTests.cpp ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSClientRealworldFuncTests.cpp ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSConfigCacheFuncTests.cpp ) - if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json) - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.21") - # Use file(COPY_FILE ...) for CMake 3.21 and later - file(COPY_FILE ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json ${CMAKE_BINARY_DIR}/test.json) - else() - # Use file(COPY ...) as an alternative for older versions - file(COPY ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json - DESTINATION ${CMAKE_BINARY_DIR}) - endif() + if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json") + configure_file(${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json ${CMAKE_BINARY_DIR}/test.json COPYONLY) endif() endif() @@ -63,11 +56,11 @@ endif() if(PAL_IMPLEMENTATION STREQUAL "WIN32") # Link against prebuilt libraries on Windows - message("--- WIN32: Linking against prebuilt libraries") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/gtest") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/gmock") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/zlib") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/sqlite") + message(STATUS "WIN32: Linking against prebuilt libraries") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/gtest") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/gmock") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/zlib") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/sqlite") # link_directories(${CMAKE_BINARY_DIR}/gtest/ ${CMAKE_BINARY_DIR}/gmock/ ${CMAKE_BINARY_DIR}/zlib/ ${CMAKE_BINARY_DIR}/sqlite/) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../zlib ) target_link_libraries(FuncTests @@ -109,10 +102,9 @@ else() set (PLATFORM_LIBS "atomic") endif() - # Find libraries - message("--- Linking libraries! ") - message("Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}") - message("Binary Dir: ${CMAKE_BINARY_DIR}") + message(STATUS "Linking libraries") + message(STATUS "Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}") + message(STATUS "Binary Dir: ${CMAKE_BINARY_DIR}") set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) diff --git a/tests/functests/FuncTests.vcxproj b/tests/functests/FuncTests.vcxproj index 50f4e2427..87b0b5b53 100644 --- a/tests/functests/FuncTests.vcxproj +++ b/tests/functests/FuncTests.vcxproj @@ -436,7 +436,6 @@ - diff --git a/tests/functests/FuncTests.vcxproj.filters b/tests/functests/FuncTests.vcxproj.filters index 22f2ac5d9..e19381a72 100644 --- a/tests/functests/FuncTests.vcxproj.filters +++ b/tests/functests/FuncTests.vcxproj.filters @@ -53,9 +53,6 @@ mocks - - mocks - mocks diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index e453df619..388b7024f 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -1,4 +1,4 @@ -message("--- unittests") +message(STATUS "Building unittests") set(SRCS AIJsonSerializerTests.cpp @@ -54,7 +54,7 @@ set_source_files_properties(${SRCS} PROPERTIES COMPILE_FLAGS -Wno-deprecated-dec # Enable Azure Monitor unit tests when the module is present. # The AIJsonSerializer test sources are guarded by HAVE_MAT_AI. -if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/azmon/AIJsonSerializer.hpp) +if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/azmon/AIJsonSerializer.hpp") add_definitions(-DHAVE_MAT_AI) endif() @@ -66,7 +66,7 @@ if (APPLE) endif() endif() -if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests) +if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/exp/tests") list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/unittests/ECSConfigCacheTests.cpp ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/unittests/ECSClientUtilsTests.cpp @@ -74,7 +74,7 @@ if (EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests) ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUARD) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYGUARD) add_definitions(-DHAVE_MAT_PRIVACYGUARD) list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/unittests/InitializationConfigurationTests.cpp @@ -85,7 +85,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/ AND BUILD_PRIVACYGUA ) endif() -if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER) +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/" AND BUILD_SANITIZER) list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerJwtTests.cpp ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerProviderTests.cpp @@ -97,7 +97,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/ AND BUILD_SANITIZER) ) endif() -if(EXISTS ${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/") list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/tests/unittests/DefaultDataViewerTests.cpp DataViewerCollectionTests.cpp @@ -115,11 +115,11 @@ endif() if(PAL_IMPLEMENTATION STREQUAL "WIN32") # Link against prebuilt libraries on Windows - message("--- WIN32: Linking against prebuilt libraries") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/gtest") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/gmock") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/zlib") - message("--- WIN32: ... ${CMAKE_BINARY_DIR}/sqlite") + message(STATUS "WIN32: Linking against prebuilt libraries") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/gtest") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/gmock") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/zlib") + message(STATUS "WIN32: ... ${CMAKE_BINARY_DIR}/sqlite") # link_directories(${CMAKE_BINARY_DIR}/gtest/ ${CMAKE_BINARY_DIR}/gmock/ ${CMAKE_BINARY_DIR}/zlib/ ${CMAKE_BINARY_DIR}/sqlite/) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../zlib ) target_link_libraries(UnitTests @@ -162,10 +162,9 @@ else() set (PLATFORM_LIBS "atomic") endif() - # Find libraries - message("--- Linking libraries! ") - message("Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}") - message("Binary Dir: ${CMAKE_BINARY_DIR}") + message(STATUS "Linking libraries") + message(STATUS "Current Dir: ${CMAKE_CURRENT_SOURCE_DIR}") + message(STATUS "Binary Dir: ${CMAKE_BINARY_DIR}") include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../lib/ ) @@ -183,8 +182,8 @@ else() ${CMAKE_CURRENT_SOURCE_DIR}/../../third_party/googletest/build/lib/ ) - message("GTEST: ${LIBGTEST}") - message("GMOCK: ${LIBGMOCK}") + message(STATUS "GTEST: ${LIBGTEST}") + message(STATUS "GMOCK: ${LIBGMOCK}") target_link_libraries(UnitTests ${LIBGTEST} diff --git a/tests/unittests/UnitTests.vcxproj b/tests/unittests/UnitTests.vcxproj index 579c52a83..12f44eae7 100644 --- a/tests/unittests/UnitTests.vcxproj +++ b/tests/unittests/UnitTests.vcxproj @@ -495,7 +495,6 @@ - diff --git a/tools/MakeDeb.cmake b/tools/MakeDeb.cmake index efec5ad32..4f839ab5b 100644 --- a/tools/MakeDeb.cmake +++ b/tools/MakeDeb.cmake @@ -24,7 +24,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}") # FIXME: add architecture name in file name set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${CPACK_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") -message("-- Package name: ${CPACK_PACKAGE_FILE_NAME}.deb") +message(STATUS "Package name: ${CPACK_PACKAGE_FILE_NAME}.deb") #install(TARGETS ${MAT_SDK_LIB_DIR}/libMAT.a ARCHIVE DESTINATION lib/MAT COMPONENT headers) #install(FILES ${MAT_SDK_INC_DIR}/*.* DESTINATION include/MAT COMPONENT libraries) diff --git a/tools/MakeRpm.cmake b/tools/MakeRpm.cmake index c4db45de0..121eba7b6 100644 --- a/tools/MakeRpm.cmake +++ b/tools/MakeRpm.cmake @@ -18,7 +18,7 @@ set(CPACK_PACKAGE_NAME "mat_sdk") set(CPACK_PACKAGE_RELEASE "0") set(CPACK_PACKAGE_VENDOR "Microsoft") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") -message("-- Package name: ${CPACK_RPM_PACKAGE_FILE_NAME}.rpm") +message(STATUS "Package name: ${CPACK_RPM_PACKAGE_FILE_NAME}.rpm") #configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mat-sdk.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/arka-sdk.spec" @ONLY IMMEDIATE) #set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/mat-sdk.spec") diff --git a/tools/MakeTgz.cmake b/tools/MakeTgz.cmake index bf159ab8d..44c308e32 100644 --- a/tools/MakeTgz.cmake +++ b/tools/MakeTgz.cmake @@ -24,8 +24,7 @@ file(GLOB ALL_TARGET_LIBS "${CMAKE_CURRENT_BINARY_DIR}/lib/libmat.*") install(FILES ${ALL_TARGET_LIBS} DESTINATION lib COMPONENT libraries) #install(FILES ${MAT_SDK_INC_DIR}/*.* DESTINATION include/mat COMPONENT libraries) -# FIXME: add architecture name in file name set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}-${CPACK_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") -message("-- Package name: ${CPACK_PACKAGE_FILE_NAME}.tgz") +message(STATUS "Package name: ${CPACK_PACKAGE_FILE_NAME}.tgz") include(CPack) diff --git a/tools/ParseOsRelease.cmake b/tools/ParseOsRelease.cmake index 48bd0398a..fc3abe9af 100644 --- a/tools/ParseOsRelease.cmake +++ b/tools/ParseOsRelease.cmake @@ -1,6 +1,6 @@ # Parse /etc/os-release to determine Linux distro -if(EXISTS /etc/os-release) +if(EXISTS "/etc/os-release") file(STRINGS /etc/os-release OS_RELEASE) foreach(NameAndValue ${OS_RELEASE}) @@ -13,7 +13,7 @@ foreach(NameAndValue ${OS_RELEASE}) # Strip quotes from value string(REPLACE "\"" "" Value ${Value}) # Set the variable - message("-- /etc/os_release : ${Name}=${Value}") + message(STATUS "/etc/os_release : ${Name}=${Value}") set("OS_RELEASE_${Name}" "${Value}") endforeach() From ecd10fa645872211b9920eca2552d349cf8f50e1 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Thu, 30 Apr 2026 06:57:19 -0700 Subject: [PATCH 2/8] Fix #1416 review follow-ups Keep the before.targets toolset selection deterministic on newer Visual Studio hosts, but only set the MIP props fallback when a consumer has not already chosen a toolset. While addressing the MSBuild review comments, also point the optional module test conditions and source paths at the real lib/modules locations and use CPACK_PACKAGE_FILE_NAME for the RPM status message. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Solutions/before.targets | 13 +++++----- Solutions/build.MIP.props | 43 +++++++++++++++++++--------------- tests/functests/CMakeLists.txt | 12 +++++----- tests/unittests/CMakeLists.txt | 4 ++-- tools/MakeRpm.cmake | 2 +- 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/Solutions/before.targets b/Solutions/before.targets index a31ed4e93..052e5d77f 100644 --- a/Solutions/before.targets +++ b/Solutions/before.targets @@ -3,13 +3,12 @@ $(SolutionDir)\..\third_party\krabsetw\krabs;$(CustomIncludePath) - v141 - v142 - v143 - v145 - - $(DefaultPlatformToolset) - $(PlatformToolset) + + v145 + v143 + v142 + v141 + v141 $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) $(LatestTargetPlatformVersion) diff --git a/Solutions/build.MIP.props b/Solutions/build.MIP.props index 14ed449b9..2419c4c36 100644 --- a/Solutions/build.MIP.props +++ b/Solutions/build.MIP.props @@ -1,19 +1,24 @@ - - - - - %(PreprocessorDefinitions);CONFIG_CUSTOM_H="config-MIP.h";MATSDK_SHARED_LIB=1; - - - ucrtbased.dll; %(DelayLoadDLLs) - - - - true - $(DefaultPlatformToolset) - - - mip_ClientTelemetry - - - + + + + + %(PreprocessorDefinitions);CONFIG_CUSTOM_H="config-MIP.h";MATSDK_SHARED_LIB=1; + + + ucrtbased.dll; %(DelayLoadDLLs) + + + + true + $(DefaultPlatformToolset) + v145 + v143 + v142 + v141 + v141 + + + mip_ClientTelemetry + + + diff --git a/tests/functests/CMakeLists.txt b/tests/functests/CMakeLists.txt index afffaf283..cb295e5c8 100644 --- a/tests/functests/CMakeLists.txt +++ b/tests/functests/CMakeLists.txt @@ -8,16 +8,16 @@ set(SRCS MultipleLogManagersTests.cpp ) -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYGUARD) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/" AND BUILD_PRIVACYGUARD) add_definitions(-DHAVE_MAT_PRIVACYGUARD) list(APPEND SRCS - PrivacyGuardFuncTests.cpp + ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/functests/PrivacyGuardFuncTests.cpp ) endif() -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/" AND BUILD_SANITIZER) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/" AND BUILD_SANITIZER) list(APPEND SRCS - SanitizerFuncTests.cpp + ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/functests/SanitizerFuncTests.cpp ) endif() @@ -27,10 +27,10 @@ if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/dataviewer/") ) endif() -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/liveeventinspector/" AND BUILD_LIVEEVENTINSPECTOR) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/liveeventinspector/" AND BUILD_LIVEEVENTINSPECTOR) add_definitions(-DHAVE_MAT_LIVEEVENTINSPECTOR) list(APPEND SRCS - LiveEventInspectorFuncTests.cpp + ${CMAKE_SOURCE_DIR}/lib/modules/liveeventinspector/tests/functests/LiveEventInspectorFuncTests.cpp ) endif() diff --git a/tests/unittests/CMakeLists.txt b/tests/unittests/CMakeLists.txt index 388b7024f..1b29db3bf 100644 --- a/tests/unittests/CMakeLists.txt +++ b/tests/unittests/CMakeLists.txt @@ -74,7 +74,7 @@ if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/exp/tests") ) endif() -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYGUARD) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/" AND BUILD_PRIVACYGUARD) add_definitions(-DHAVE_MAT_PRIVACYGUARD) list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/unittests/InitializationConfigurationTests.cpp @@ -85,7 +85,7 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/privacyguard/" AND BUILD_PRIVACYG ) endif() -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/modules/sanitizer/" AND BUILD_SANITIZER) +if(EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/" AND BUILD_SANITIZER) list(APPEND SRCS ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerJwtTests.cpp ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerProviderTests.cpp diff --git a/tools/MakeRpm.cmake b/tools/MakeRpm.cmake index 121eba7b6..8d9cf0b67 100644 --- a/tools/MakeRpm.cmake +++ b/tools/MakeRpm.cmake @@ -18,7 +18,7 @@ set(CPACK_PACKAGE_NAME "mat_sdk") set(CPACK_PACKAGE_RELEASE "0") set(CPACK_PACKAGE_VENDOR "Microsoft") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}") -message(STATUS "Package name: ${CPACK_RPM_PACKAGE_FILE_NAME}.rpm") +message(STATUS "Package name: ${CPACK_PACKAGE_FILE_NAME}.rpm") #configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mat-sdk.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/arka-sdk.spec" @ONLY IMMEDIATE) #set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/mat-sdk.spec") From 5ab2691552cf9fb0fe0bb05dc90a3a274701dd7c Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Fri, 1 May 2026 15:23:36 -0500 Subject: [PATCH 3/8] Fix #1416 Apple runtime regressions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 8 ++++---- lib/api/Logger.cpp | 3 ++- lib/http/HttpClientManager.cpp | 10 ++++++++-- lib/http/HttpClient_Apple.mm | 24 ++++++------------------ lib/http/HttpResponseDecoder.cpp | 6 +++--- 5 files changed, 23 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7306afe8..cc99131af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,20 +121,20 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(WARN_FLAGS "-Wall -Werror -Wextra -Wno-unused-parameter -Wno-unused-but-set-variable") else() # Clang / AppleClang - set(WARN_FLAGS "-Wall -Werror -Wextra -Wno-unused-parameter -Wno-unknown-warning-option -Wno-unused-but-set-variable") + set(WARN_FLAGS "-Wall -Werror -Wextra -Wno-unused-parameter -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-nan-infinity-disabled") endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # Using GCC with -s and -Wl linker flags - set(REL_FLAGS "-s -Wl,--gc-sections -Os ${WARN_FLAGS} -ffunction-sections -fdata-sections -fmerge-all-constants -ffast-math -fno-finite-math-only") + set(REL_FLAGS "-s -Wl,--gc-sections -Os ${WARN_FLAGS} -ffunction-sections -fdata-sections -fmerge-all-constants -ffast-math") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") set(REL_FLAGS "${WARN_FLAGS}") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # AppleClang does not support -ffunction-sections and -fdata-sections with the -fembed-bitcode and -fembed-bitcode-marker - set(REL_FLAGS "-Os ${WARN_FLAGS} -fmerge-all-constants -ffast-math -fno-finite-math-only") + set(REL_FLAGS "-Os ${WARN_FLAGS} -fmerge-all-constants -ffast-math") else() # Using clang - strip unsupported GCC options - set(REL_FLAGS "-Os ${WARN_FLAGS} -ffunction-sections -fmerge-all-constants -ffast-math -fno-finite-math-only") + set(REL_FLAGS "-Os ${WARN_FLAGS} -ffunction-sections -fmerge-all-constants -ffast-math") endif() ## Uncomment this to reduce the volume of note warnings on RPi4 w/gcc-8 Ref. https://gcc.gnu.org/ml/gcc/2017-05/msg00073.html diff --git a/lib/api/Logger.cpp b/lib/api/Logger.cpp index 54d883664..cbe503f8c 100644 --- a/lib/api/Logger.cpp +++ b/lib/api/Logger.cpp @@ -127,7 +127,8 @@ namespace MAT_NS_BEGIN Logger::~Logger() noexcept { - LOG_TRACE("%p: Destroyed", this); + // Intentionally empty — logging here triggers a static-destruction-order + // crash on iOS simulator after logging teardown. } ISemanticContext* Logger::GetSemanticContext() const diff --git a/lib/http/HttpClientManager.cpp b/lib/http/HttpClientManager.cpp index 58fa5fb4a..eea19fd1b 100644 --- a/lib/http/HttpClientManager.cpp +++ b/lib/http/HttpClientManager.cpp @@ -149,11 +149,17 @@ namespace MAT_NS_BEGIN { void HttpClientManager::cancelAllRequests() { cancelAllRequestsAsync(); - while (!m_httpCallbacks.empty()) + while (true) + { + { + LOCKGUARD(m_httpCallbacksMtx); + if (m_httpCallbacks.empty()) + break; + } std::this_thread::yield(); + } } // start async cancellation } MAT_NS_END - diff --git a/lib/http/HttpClient_Apple.mm b/lib/http/HttpClient_Apple.mm index 05817087a..579b05313 100644 --- a/lib/http/HttpClient_Apple.mm +++ b/lib/http/HttpClient_Apple.mm @@ -132,23 +132,6 @@ void HandleResponse(NSData* data, NSURLResponse* response, NSError* error) void Cancel() { [m_dataTask cancel]; - [session getTasksWithCompletionHandler:^(NSArray* dataTasks, NSArray* uploadTasks, NSArray* downloadTasks) - { - for (NSURLSessionTask* _task in dataTasks) - { - [_task cancel]; - } - - for (NSURLSessionTask* _task in downloadTasks) - { - [_task cancel]; - } - - for (NSURLSessionTask* _task in uploadTasks) - { - [_task cancel]; - } - }]; } private: @@ -214,8 +197,13 @@ void Cancel() for (const auto &id : ids) CancelRequestAsync(id); - while (!m_requests.empty()) + while (true) { + { + std::lock_guard lock(m_requestsMtx); + if (m_requests.empty()) + break; + } PAL::sleep(100); std::this_thread::yield(); } diff --git a/lib/http/HttpResponseDecoder.cpp b/lib/http/HttpResponseDecoder.cpp index 11e9d4096..508e0e205 100644 --- a/lib/http/HttpResponseDecoder.cpp +++ b/lib/http/HttpResponseDecoder.cpp @@ -67,13 +67,11 @@ namespace MAT_NS_BEGIN { break; case HttpResult_Aborted: - ctx->httpResponse = nullptr; outcome = Abort; break; case HttpResult_LocalFailure: case HttpResult_NetworkFailure: - ctx->httpResponse = nullptr; outcome = RetryNetwork; break; } @@ -129,6 +127,7 @@ namespace MAT_NS_BEGIN { evt.param1 = 0; // response.GetStatusCode(); DispatchEvent(evt); } + delete ctx->httpResponse; ctx->httpResponse = nullptr; // eventsRejected(ctx); // FIXME: [MG] - investigate why ctx gets corrupt after eventsRejected requestAborted(ctx); @@ -159,6 +158,8 @@ namespace MAT_NS_BEGIN { evt.param1 = response.GetStatusCode(); DispatchEvent(evt); } + delete ctx->httpResponse; + ctx->httpResponse = nullptr; temporaryNetworkFailure(ctx); break; } @@ -253,4 +254,3 @@ namespace MAT_NS_BEGIN { } } MAT_NS_END - From aeb72ae0e87a294b65368f429db5386e3fe73f80 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Fri, 1 May 2026 17:09:41 -0500 Subject: [PATCH 4/8] Make CurlHttpOperation own CA path Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/http/HttpClient_Curl.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/http/HttpClient_Curl.hpp b/lib/http/HttpClient_Curl.hpp index 972cc4fec..c7a5bdecb 100644 --- a/lib/http/HttpClient_Curl.hpp +++ b/lib/http/HttpClient_Curl.hpp @@ -109,6 +109,7 @@ class CurlHttpOperation { m_callback(callback), m_method(method), m_url(url), + m_sslCaInfo(sslCaInfo), // Local vars requestHeaders(requestHeaders), @@ -140,8 +141,8 @@ class CurlHttpOperation { curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, sslVerify ? 1L : 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, sslVerify ? 2L : 0L); - if (!sslCaInfo.empty()) { - curl_easy_setopt(curl, CURLOPT_CAINFO, sslCaInfo.c_str()); + if (!m_sslCaInfo.empty()) { + curl_easy_setopt(curl, CURLOPT_CAINFO, m_sslCaInfo.c_str()); } // HTTP/2 please, fallback to HTTP/1.1 if not supported curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); @@ -434,6 +435,7 @@ class CurlHttpOperation { // Request values std::string m_method; std::string m_url; + std::string m_sslCaInfo; const std::map& requestHeaders; const std::vector& requestBody; struct curl_slist *m_headersChunk = nullptr; @@ -534,4 +536,3 @@ class CurlHttpOperation { #endif // HAVE_MAT_DEFAULT_HTTP_CLIENT #endif // HTTPCLIENTCURL_HPP - From edae32828f706fda21f038d82bd040dc4005db3a Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Fri, 1 May 2026 18:01:29 -0500 Subject: [PATCH 5/8] Restore nonfunctional CMake comments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc99131af..3117d4b29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # -Wno-unknown-warning-option is Clang-only, omitted here set(WARN_FLAGS "-Wall -Werror -Wextra -Wno-unused-parameter -Wno-unused-but-set-variable") else() - # Clang / AppleClang + # No -pedantic -Wno-extra-semi -Wno-gnu-zero-variadic-macro-arguments set(WARN_FLAGS "-Wall -Werror -Wextra -Wno-unused-parameter -Wno-unknown-warning-option -Wno-unused-but-set-variable -Wno-nan-infinity-disabled") endif() @@ -167,10 +167,17 @@ if(MSVC) endif() endif() -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # GCC needs explicit position-independent code +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # using Clang +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # using GCC + # Prefer to generate position-independent code set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + # using Intel C++ +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # using Visual Studio C++ endif() include(tools/Utils.cmake) @@ -292,10 +299,17 @@ if(BUILD_APPLE_HTTP) add_definitions(-DAPPLE_HTTP=1) endif() +# Bond Lite subdirectories include_directories(bondlite/include) include_directories(lib/pal) +#if(BUILD_UNIT_TESTS) +# message("Adding bondlite tests") +# enable_testing() +# add_subdirectory(bondlite/tests) +#endif() + # Include repo root to allow includes of sqlite, zlib, and nlohmann include_directories(${CMAKE_SOURCE_DIR}) @@ -320,14 +334,18 @@ endif() if (BUILD_PACKAGE) if ("${CMAKE_PACKAGE_TYPE}" STREQUAL "deb") + # FIXME: hardcode it for 64-bit Linux for now set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/${CPACK_DEBIAN_ARCHITECTURE}-linux-gnu) include(tools/MakeDeb.cmake) endif() if ("${CMAKE_PACKAGE_TYPE}" STREQUAL "rpm") + # TODO: [MG] - fix path set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_SYSTEM_PROCESSOR}-linux-gnu) include(tools/MakeRpm.cmake) endif() if ("${CMAKE_PACKAGE_TYPE}" STREQUAL "tgz") + # TODO: [MG] - fix path... should we simply use /usr/local/lib without CPU? + # TODO: [MG] - Windows path is not ideal -- C:/Program Files (x86)/MSTelemetry/* - what should we use instead? include(tools/MakeTgz.cmake) endif() endif() From 826cc9a031b57b1f1f0e4eefc96c62e0e61238f3 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Fri, 1 May 2026 18:41:17 -0500 Subject: [PATCH 6/8] Remove runtime overlap with #1429 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- lib/api/Logger.cpp | 3 +-- lib/http/HttpClientManager.cpp | 10 ++-------- lib/http/HttpClient_Apple.mm | 24 ++++++++++++++++++------ lib/http/HttpResponseDecoder.cpp | 6 +++--- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/api/Logger.cpp b/lib/api/Logger.cpp index cbe503f8c..54d883664 100644 --- a/lib/api/Logger.cpp +++ b/lib/api/Logger.cpp @@ -127,8 +127,7 @@ namespace MAT_NS_BEGIN Logger::~Logger() noexcept { - // Intentionally empty — logging here triggers a static-destruction-order - // crash on iOS simulator after logging teardown. + LOG_TRACE("%p: Destroyed", this); } ISemanticContext* Logger::GetSemanticContext() const diff --git a/lib/http/HttpClientManager.cpp b/lib/http/HttpClientManager.cpp index eea19fd1b..58fa5fb4a 100644 --- a/lib/http/HttpClientManager.cpp +++ b/lib/http/HttpClientManager.cpp @@ -149,17 +149,11 @@ namespace MAT_NS_BEGIN { void HttpClientManager::cancelAllRequests() { cancelAllRequestsAsync(); - while (true) - { - { - LOCKGUARD(m_httpCallbacksMtx); - if (m_httpCallbacks.empty()) - break; - } + while (!m_httpCallbacks.empty()) std::this_thread::yield(); - } } // start async cancellation } MAT_NS_END + diff --git a/lib/http/HttpClient_Apple.mm b/lib/http/HttpClient_Apple.mm index 579b05313..05817087a 100644 --- a/lib/http/HttpClient_Apple.mm +++ b/lib/http/HttpClient_Apple.mm @@ -132,6 +132,23 @@ void HandleResponse(NSData* data, NSURLResponse* response, NSError* error) void Cancel() { [m_dataTask cancel]; + [session getTasksWithCompletionHandler:^(NSArray* dataTasks, NSArray* uploadTasks, NSArray* downloadTasks) + { + for (NSURLSessionTask* _task in dataTasks) + { + [_task cancel]; + } + + for (NSURLSessionTask* _task in downloadTasks) + { + [_task cancel]; + } + + for (NSURLSessionTask* _task in uploadTasks) + { + [_task cancel]; + } + }]; } private: @@ -197,13 +214,8 @@ void Cancel() for (const auto &id : ids) CancelRequestAsync(id); - while (true) + while (!m_requests.empty()) { - { - std::lock_guard lock(m_requestsMtx); - if (m_requests.empty()) - break; - } PAL::sleep(100); std::this_thread::yield(); } diff --git a/lib/http/HttpResponseDecoder.cpp b/lib/http/HttpResponseDecoder.cpp index 508e0e205..11e9d4096 100644 --- a/lib/http/HttpResponseDecoder.cpp +++ b/lib/http/HttpResponseDecoder.cpp @@ -67,11 +67,13 @@ namespace MAT_NS_BEGIN { break; case HttpResult_Aborted: + ctx->httpResponse = nullptr; outcome = Abort; break; case HttpResult_LocalFailure: case HttpResult_NetworkFailure: + ctx->httpResponse = nullptr; outcome = RetryNetwork; break; } @@ -127,7 +129,6 @@ namespace MAT_NS_BEGIN { evt.param1 = 0; // response.GetStatusCode(); DispatchEvent(evt); } - delete ctx->httpResponse; ctx->httpResponse = nullptr; // eventsRejected(ctx); // FIXME: [MG] - investigate why ctx gets corrupt after eventsRejected requestAborted(ctx); @@ -158,8 +159,6 @@ namespace MAT_NS_BEGIN { evt.param1 = response.GetStatusCode(); DispatchEvent(evt); } - delete ctx->httpResponse; - ctx->httpResponse = nullptr; temporaryNetworkFailure(ctx); break; } @@ -254,3 +253,4 @@ namespace MAT_NS_BEGIN { } } MAT_NS_END + From c6ae85e8a34b53af33e0959f4b20bd516534f7d2 Mon Sep 17 00:00:00 2001 From: bmehta001 Date: Mon, 11 May 2026 12:34:45 -0500 Subject: [PATCH 7/8] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tools/ParseOsRelease.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/ParseOsRelease.cmake b/tools/ParseOsRelease.cmake index fc3abe9af..61952f57f 100644 --- a/tools/ParseOsRelease.cmake +++ b/tools/ParseOsRelease.cmake @@ -13,7 +13,7 @@ foreach(NameAndValue ${OS_RELEASE}) # Strip quotes from value string(REPLACE "\"" "" Value ${Value}) # Set the variable - message(STATUS "/etc/os_release : ${Name}=${Value}") + message(STATUS "/etc/os-release : ${Name}=${Value}") set("OS_RELEASE_${Name}" "${Value}") endforeach() From 953ff8bca80a60dc3e3dfd600bd33037ba150749 Mon Sep 17 00:00:00 2001 From: Bhagirath Mehta Date: Mon, 11 May 2026 12:40:14 -0500 Subject: [PATCH 8/8] Quote functest configure_file paths Quote the optional ECS test.json configure_file input and output paths so CMake handles source or build directories that contain spaces. Files changed: - tests/functests/CMakeLists.txt Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/functests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functests/CMakeLists.txt b/tests/functests/CMakeLists.txt index cb295e5c8..0c2074e99 100644 --- a/tests/functests/CMakeLists.txt +++ b/tests/functests/CMakeLists.txt @@ -41,7 +41,7 @@ if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/exp/tests") ${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/ECSConfigCacheFuncTests.cpp ) if (EXISTS "${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json") - configure_file(${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json ${CMAKE_BINARY_DIR}/test.json COPYONLY) + configure_file("${CMAKE_SOURCE_DIR}/lib/modules/exp/tests/functests/test.json" "${CMAKE_BINARY_DIR}/test.json" COPYONLY) endif() endif()