summaryrefslogtreecommitdiff
path: root/Modules/GenerateExportHeader.cmake
diff options
context:
space:
mode:
authorCorentin Damman <c.damman@intopix.com>2023-02-17 08:53:55 -0500
committerCorentin Damman <c.damman@intopix.com>2023-02-23 09:19:06 +0100
commit1e199363200f33c63160b2fd2730c2f86283ce1e (patch)
treea1fc768e698fd2dd10d6802fedfaaf6e60b106e2 /Modules/GenerateExportHeader.cmake
parentab049ed7f1efef546ef82d1ec2585a03b47eccce (diff)
downloadcmake-1e199363200f33c63160b2fd2730c2f86283ce1e.tar.gz
GenerateExportHeader: Fix Clang support on Windows
When using Clang with Visual Studio, the GenerateExportHeader function generates the DEPRECATED definition "__attribute__ ((__deprecated__))", because Clang can compile such instruction. However, if a user wants to compile the library with this generated header with MSVC, the declaration is not valid. We suggest to always use the DEPRECATED definition "__declspec(deprecated)" on Windows, which is valid for both Clang and MSVC.
Diffstat (limited to 'Modules/GenerateExportHeader.cmake')
-rw-r--r--Modules/GenerateExportHeader.cmake2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index 7461a3e5d0..ea8616af12 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -293,7 +293,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY)
set(DEFINE_IMPORT)
set(DEFINE_NO_EXPORT)
- if (COMPILER_HAS_DEPRECATED_ATTR)
+ if (COMPILER_HAS_DEPRECATED_ATTR AND NOT WIN32)
set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))")
elseif(COMPILER_HAS_DEPRECATED)
set(DEFINE_DEPRECATED "__declspec(deprecated)")