Skip to content

Commit

Permalink
CMakeLists.txt: Set policy CMP0151. (introduced in CMake-3.27)
Browse files Browse the repository at this point in the history
clang complains about namespace pollution in generated moc_*.cpp files:

In file included from src/kde/kf5/kfilemetadata_rom-properties-kf5_autogen/mocs_compilation.cpp:2:
src/kde/kf5/kfilemetadata_rom-properties-kf5_autogen/BKZOEHIFDQ/moc_ExtractorPluginKF5.cpp:1082:17:
    warning: using namespace directive in global context in header [-Wheader-hygiene]
 1082 | using namespace RomPropertiesKF5;
      |                 ^

Setting CMP0151 tells AUTOGEN to add the include paths using -isystem,
which tells clang it shouldn't print warnings about these files.
  • Loading branch information
GerbilSoft committed Jan 25, 2025
1 parent 47296cf commit 1f8dc86
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,29 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5)

# CMP0048: Set VERSION variables based on the project version specified in PROJECT().
# Introduced in CMake 3.0.
CMAKE_POLICY(SET CMP0048 NEW)
IF(POLICY CMP0048)
CMAKE_POLICY(SET CMP0048 NEW)
ENDIF(CMP0048)

# CMP0063: Honor visibility properties for all target types,
# including static libraries and executables.
# Introduced in CMake 3.3.
CMAKE_POLICY(SET CMP0063 NEW)
IF(POLICY CMP0063)
CMAKE_POLICY(SET CMP0063 NEW)
ENDIF(POLICY CMP0063)

# CMP0151: Use -isystem for AUTOMOC include directories.
# clang complains about `using namespace` statements in the
# generated moc_*.cpp files:
# In file included from src/kde/kf5/kfilemetadata_rom-properties-kf5_autogen/mocs_compilation.cpp:2:
# src/kde/kf5/kfilemetadata_rom-properties-kf5_autogen/BKZOEHIFDQ/moc_ExtractorPluginKF5.cpp:1082:17:
# warning: using namespace directive in global context in header [-Wheader-hygiene]
# 1082 | using namespace RomPropertiesKF5;
# | ^
# Introduced in CMake 3.27.
IF(POLICY CMP0151)
CMAKE_POLICY(SET CMP0151 NEW)
ENDIF(POLICY CMP0151)

# Read the project version.
CONFIGURE_FILE(version.txt version.txt.tmp)
Expand Down

0 comments on commit 1f8dc86

Please sign in to comment.