Skip to content

Commit 4b7e9a5

Browse files
committed
[ML] Suppress Clang -Wunused-macros for test targets only
BOOST_TEST_MODULE and BOOST_TEST_NO_MAIN are consumed by the subsequent #include <boost/test/unit_test.hpp> but Clang flags them as unused since they're not referenced directly in source. Suppress for test targets only via target_compile_options in ml_add_test_executable, rather than globally. Made-with: Cursor
1 parent b3bf995 commit 4b7e9a5

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

cmake/compiler/clang.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ list(APPEND ML_C_FLAGS
3737
"-Wno-switch-default"
3838
"-Wno-unknown-warning-option"
3939
"-Wno-unreachable-code"
40-
"-Wno-unused-macros"
4140
"-Wno-used-but-marked-unused"
4241
${ML_COVERAGE})
4342

cmake/compiler/msvc.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ list(APPEND ML_COMPILE_DEFINITIONS
2727
_WIN32_WINNT=0x0601
2828
Windows)
2929

30+
# Treat SYSTEM include directories as external — suppress warnings from
31+
# third-party headers (Boost, Eigen, PyTorch, etc.). Requires MSVC 17.0+.
32+
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "/external:I ")
3033
list(APPEND ML_C_FLAGS
3134
"/X"
3235
"/nologo"
3336
"/W4"
37+
"/external:W0"
3438
"/EHsc"
3539
"/Gw"
3640
"/Zc:inline"

cmake/functions.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ function(ml_add_test_executable _target)
382382

383383
set_property(TARGET ml_test_${_target} PROPERTY POSITION_INDEPENDENT_CODE TRUE)
384384

385+
# Boost.Test's BOOST_TEST_MODULE / BOOST_TEST_NO_MAIN macros are consumed
386+
# by the subsequent #include <boost/test/unit_test.hpp> but Clang flags
387+
# them as unused. Suppress for test targets only.
388+
target_compile_options(ml_test_${_target} PRIVATE
389+
$<$<CXX_COMPILER_ID:AppleClang,Clang>:-Wno-unused-macros>)
390+
385391
if(ML_PCH)
386392
target_precompile_headers(ml_test_${_target} PRIVATE
387393
<string>

0 commit comments

Comments
 (0)