Apply CMake best practices and remove stale references#1416
Conversation
34e4948 to
790fdd0
Compare
9a5a166 to
2feeb94
Compare
There was a problem hiding this comment.
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 thislist(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 toSRCS.
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
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>
|
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. |
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>
|
Addressed Copilot round 2: dropped the speculative |
The top-level CMakeLists.txt asks for C++14 (CMAKE_CXX_STANDARD 14, set in 2018) but then re-injects -std=c++11 into CMAKE_CXX_FLAGS for both Release and Debug Unix builds (set in 2019 when gcc-4.x / gcc-5.x C++14 support was still spotty). That explicit flag wins, so the Unix builds have actually been C++11 ever since, contradicting the stated standard. This is a vestige: gcc-5+, clang-3.4+, and MSVC 2015+ all support C++14 fully, and Android (lib/android_build/) already sets CMAKE_CXX_STANDARD 14 explicitly. Removing the override aligns the Unix CMake builds with the intended standard. - Drop the stale gcc-4.x/5.x caveat comment and add CMAKE_CXX_STANDARD_REQUIRED ON so the build fails loudly on toolchains that cannot do C++14, rather than silently falling back. - Drop the -std=c++11 fragment from both REL and DBG CMAKE_CXX_FLAGS lines. C and C11 are left alone (C11 remains the C floor). Not touched in this commit: - examples/**/CMakeLists.txt and wrappers/obj-c/CMakeLists.txt also pin -std=c++11. Those are standalone sample/wrapper build scripts not wired via add_subdirectory and not built by any CI workflow; their pins are intentional statements of each sample's minimum and can stay. - This commit does not bump the project to C++17. Cleanup ideas like cpp_client_telemetry_modules#302 (std::string::data() -> char*) require C++17 and are still out of scope. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Added commit Why it fits this PR's "remove stale references" theme:
Toolchain risk: gcc-5+, clang-3.4+, and MSVC 2015+ all fully support C++14. The original comment ("…we may get C++11 on older gcc-4.x and gcc-5.x") is a 7-year-old caveat that no realistic build environment hits today. I also added Out of scope (intentional):
PR description's "What changes" list updated to mention this; no other text changes needed. |
Derive package version components from MATSDK_BUILD_VERSION so CPack packages stay aligned with the SDK version. Use PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR for test CMake paths so the SDK remains subproject-friendly. Files changed: - CMakeLists.txt - tools/MakeDeb.cmake - tools/MakeRpm.cmake - tools/MakeTgz.cmake - tests/functests/CMakeLists.txt - tests/unittests/CMakeLists.txt Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate MATSDK_BUILD_VERSION before deriving CPack version components and remove now-dead DAYNUMBER calculations from package scripts. Files changed: - CMakeLists.txt - tools/MakeDeb.cmake - tools/MakeRpm.cmake - tools/MakeTgz.cmake Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts: # lib/CMakeLists.txt
The previous merge from main left a conflict marker block in lib/CMakeLists.txt's trailing commented-link section. Remove the marker block and keep the cleaned-up file content. Files changed: - lib/CMakeLists.txt Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep package script version cleanup out of the CMake cleanup PR; package version alignment can be handled separately before the next release. Files changed: - CMakeLists.txt - tools/MakeDeb.cmake - tools/MakeRpm.cmake - tools/MakeTgz.cmake Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pure build/project cleanup
CMake improvements (3 files)
Cleanup / CMake hygiene
LANGUAGES C CXXto the top-levelproject()callmessage(STATUS ...)instead of baremessage(...)message(FATAL_ERROR, ...)comma bug (invalid CMake syntax)if(EXISTS ...)quoting inlib/,tests/functests/, andtests/unittestsconfigure_file(... COPYONLY)Solutions/before.targetsandSolutions/build.MIP.propsMATSDK_API_VERSIONfrom 3.4 to 3.10 to match recent releases-fPICflags preservedinclude_directoriesentryVisual Studio project cleanup (8 files)
targetver.h(SampleCpp, SampleCppMini)LogManagerV1.hpp(Shared.vcxitems)MockILocalStorageReader.hpp(UnitTests.vcxproj)SanitizerBaseTests.cpp(FuncTests.vcxproj)Packaging