Skip to content

Apply CMake best practices and remove stale references#1416

Open
bmehta001 wants to merge 13 commits into
microsoft:mainfrom
bmehta001:bhamehta/code-cleanup
Open

Apply CMake best practices and remove stale references#1416
bmehta001 wants to merge 13 commits into
microsoft:mainfrom
bmehta001:bhamehta/code-cleanup

Conversation

@bmehta001
Copy link
Copy Markdown
Contributor

@bmehta001 bmehta001 commented Mar 18, 2026

Pure build/project cleanup

CMake improvements (3 files)

Cleanup / CMake hygiene

  • add LANGUAGES C CXX to the top-level project() call
  • switch build/config logging to message(STATUS ...) instead of bare message(...)
  • Fix message(FATAL_ERROR, ...) comma bug (invalid CMake syntax)
  • fix if(EXISTS ...) quoting in lib/, tests/functests/, and tests/unittests
  • simplify cross-version file copies to configure_file(... COPYONLY)
  • remove stale Visual Studio project/header references
  • update VS toolset fallback logic in Solutions/before.targets and Solutions/build.MIP.props
  • Update MATSDK_API_VERSION from 3.4 to 3.10 to match recent releases
  • Remove empty compiler-id blocks (Clang/Intel/MSVC with no content); GCC -fPIC flags preserved
  • Remove commented-out bondlite test block and stale TODO comments
  • Remove duplicate include_directories entry

Visual Studio project cleanup (8 files)

  • Remove stale header references that no longer exist in the repo:
    • targetver.h (SampleCpp, SampleCppMini)
    • LogManagerV1.hpp (Shared.vcxitems)
    • MockILocalStorageReader.hpp (UnitTests.vcxproj)
    • SanitizerBaseTests.cpp (FuncTests.vcxproj)
  • Modernize VS toolset: use `` fallback instead of hardcoded v141 (Solutions/before.targets, build.MIP.props)

Packaging

  • keep the package install-dir overrides that Debian/RPM packaging expects
  • adjust packaging messages / cleanup so the CMake changes stay behavior-correct

@bmehta001 bmehta001 requested a review from a team as a code owner March 18, 2026 08:34
@bmehta001 bmehta001 force-pushed the bhamehta/code-cleanup branch 2 times, most recently from 34e4948 to 790fdd0 Compare March 18, 2026 09:03
@bmehta001 bmehta001 changed the title Use best CMake practices, rm outdated headers, and update VS settings Use best CMake practices, rm/update outdated code Mar 18, 2026
@bmehta001 bmehta001 force-pushed the bhamehta/code-cleanup branch 18 times, most recently from 9a5a166 to 2feeb94 Compare March 19, 2026 05:40
@bmehta001 bmehta001 self-assigned this Mar 19, 2026
Comment thread lib/CMakeLists.txt Outdated
Comment thread lib/CMakeLists.txt Outdated
Comment thread lib/CMakeLists.txt Outdated
Comment thread lib/CMakeLists.txt Outdated
Comment thread lib/CMakeLists.txt Outdated
Copy link
Copy Markdown
Contributor

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments.

Comment thread lib/http/HttpClient_Apple.mm Outdated
bmehta001 added a commit to bmehta001/cpp_client_telemetry that referenced this pull request May 15, 2026
PR microsoft#1416 inadvertently regressed PR microsoft#1415 by removing
-fno-finite-math-only from the three Unix REL_FLAGS branches and adding
-Wno-nan-infinity-disabled to silence the Clang diagnostic. That left
release builds using -ffast-math without preserving the NaN/Inf
semantics needed by nlohmann::json and SQLite paths.

Remove -ffast-math entirely from the GCC, AppleClang, and generic Clang
release flags rather than relying on -fno-finite-math-only to partially
undo it. This SDK is not floating-point compute-bound; its hot paths are
string, Bond/JSON serialization, HTTP I/O, and SQLite reads/writes.

Avoiding -ffast-math:
- preserves std::isnan/std::isinf behavior for JSON and storage code,
- avoids compiler/runtime fast-math side effects such as x86 GCC's
  crtfastmath.o changing MXCSR FTZ/DAZ behavior process-wide, and
- aligns with SQLite's guidance to avoid fast-math.

This subsumes microsoft#1415's partial mitigation and aligns with microsoft#1392's intent,
extended to GCC because GCC fast-math has the same broad assumptions and
runtime side effects. Also remove -Wno-nan-infinity-disabled because the
warning should not be suppressed once the cause is gone.

Validation:
- CMake Release build of UnitTests on macOS arm64 (AppleClang 21).
- UnitTests passed on macOS arm64.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 force-pushed the bhamehta/code-cleanup branch from b34147f to 0e8018c Compare May 15, 2026 03:06
@bmehta001 bmehta001 requested a review from ThomsonTan May 21, 2026 00:59
bmehta001 added a commit to bmehta001/cpp_client_telemetry that referenced this pull request May 22, 2026
Keep PR microsoft#1416 focused by reverting the broad MSBuild project metadata cleanup now carried by a separate branch.

Files changed:

- Solutions/Clienttelemetry/Clienttelemetry.vcxitems

- examples/cpp project and filter files

- lib/pal and lib/tracing shared item files

- tests/googletest filter metadata

- third_party/Solutions/zlib/vc14/zlibvc.vcxproj

- tools/ports/mstelemetry/v142-build.patch

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 force-pushed the bhamehta/code-cleanup branch from 17b72ca to 1d09c10 Compare May 22, 2026 07:35
bmehta001 and others added 10 commits May 22, 2026 15:02
- 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>
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>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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>
PR microsoft#1416 inadvertently regressed PR microsoft#1415 by removing
-fno-finite-math-only from the three Unix REL_FLAGS branches and adding
-Wno-nan-infinity-disabled to silence the Clang diagnostic. That left
release builds using -ffast-math without preserving the NaN/Inf
semantics needed by nlohmann::json and SQLite paths.

Remove -ffast-math entirely from the GCC, AppleClang, and generic Clang
release flags rather than relying on -fno-finite-math-only to partially
undo it. This SDK is not floating-point compute-bound; its hot paths are
string, Bond/JSON serialization, HTTP I/O, and SQLite reads/writes.

Avoiding -ffast-math:
- preserves std::isnan/std::isinf behavior for JSON and storage code,
- avoids compiler/runtime fast-math side effects such as x86 GCC's
  crtfastmath.o changing MXCSR FTZ/DAZ behavior process-wide, and
- aligns with SQLite's guidance to avoid fast-math.

This subsumes microsoft#1415's partial mitigation and aligns with microsoft#1392's intent,
extended to GCC because GCC fast-math has the same broad assumptions and
runtime side effects. Also remove -Wno-nan-infinity-disabled because the
warning should not be suppressed once the cause is gone.

Validation:
- CMake Release build of UnitTests on macOS arm64 (AppleClang 21).
- UnitTests passed on macOS arm64.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Avoid carrying a confusing note about warning flags that are not used, and keep CMakeLists.txt focused on active compiler settings.

Files changed:

- CMakeLists.txt

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001 bmehta001 force-pushed the bhamehta/code-cleanup branch from 1d09c10 to 1cfe326 Compare May 22, 2026 20:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Comments suppressed due to low confidence (2)

tests/unittests/CMakeLists.txt:84

  • The appended privacyguard test source paths are unquoted. If ${CMAKE_SOURCE_DIR} contains spaces, these will be split into multiple arguments and break the build. Quote each ${CMAKE_SOURCE_DIR}/... path in this list(APPEND SRCS ...) block.
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
  ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/unittests/PrivacyConcernEventTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/unittests/PrivacyConcernMetadataProviderTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/unittests/PrivacyGuardTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/privacyguard/tests/unittests/SystematicSamplerTests.cpp

tests/unittests/CMakeLists.txt:96

  • The sanitizer test source paths added here are unquoted. If ${CMAKE_SOURCE_DIR} contains spaces, the paths can be mis-parsed as multiple arguments. Quote each ${CMAKE_SOURCE_DIR}/... entry when appending to SRCS.
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
  ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerSitePathTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerStringUtilsTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerUrlTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SanitizerTrieTests.cpp
  ${CMAKE_SOURCE_DIR}/lib/modules/sanitizer/tests/unittests/SPOPasswordTests.cpp

Comment thread tests/unittests/CMakeLists.txt
Comment thread tests/unittests/CMakeLists.txt
Comment thread tests/functests/CMakeLists.txt
Comment thread tests/functests/CMakeLists.txt
Comment thread tests/functests/CMakeLists.txt Outdated
Comment thread tests/functests/CMakeLists.txt Outdated
Comment thread tests/functests/CMakeLists.txt
Copilot review on PR microsoft#1416 flagged 7 unquoted ${CMAKE_SOURCE_DIR}/...
paths inside list(APPEND SRCS ...) calls. CMake splits unquoted
arguments on whitespace, so a checkout path containing spaces (very
common on Windows: C:\Users\First Last\source\...) would fragment a
single source path into multiple list elements and the test wouldn't
compile.

Quote every ${CMAKE_SOURCE_DIR}/.../*.cpp path inside
list(APPEND SRCS ...) in both tests/unittests/CMakeLists.txt and
tests/functests/CMakeLists.txt (23 paths total, including the
privacyguard + sanitizer blocks Copilot didn't cite but that share the
same hazard).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001
Copy link
Copy Markdown
Contributor Author

Addressed in 1de44ae: quoted all 23 ${CMAKE_SOURCE_DIR}/... paths inside list(APPEND SRCS ...) blocks across both ests/unittests/CMakeLists.txt and ests/functests/CMakeLists.txt (including the privacyguard + sanitizer blocks not explicitly flagged but sharing the same hazard). Re-requesting Copilot review.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.

Comment thread CMakeLists.txt
Comment thread Solutions/before.targets
Comment thread Solutions/build.MIP.props
Copilot review on PR microsoft#1416 flagged that mapping VisualStudioVersion >= 18.0
to PlatformToolset v145 is a guess: VS 2025/2026/etc. has not shipped, the
toolset moniker for that release may differ, and pinning to a non-existent
toolset name causes MSBuild to fail early with "unknown PlatformToolset"
on any machine that does pick up that VS version.

Drop the v145 mapping from both before.targets and build.MIP.props. Future
VS versions fall through to the v141 fallback (same behavior as before
PR microsoft#1416, just one less wrong-toolset-name failure mode). Add explicit
mappings for new toolsets as they actually ship.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bmehta001
Copy link
Copy Markdown
Contributor Author

Addressed Copilot round 2: dropped the speculative v145 PlatformToolset mapping from Solutions/before.targets + Solutions/build.MIP.props (337028a). Replied on the -ffast-math thread explaining the removal was intentional (commit 704d29b, SDK isn't FP-heavy and -ffast-math brings IEEE-754 reassociation hazards). All 10 Copilot threads on this PR are now resolved.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants