summaryrefslogtreecommitdiffstats
path: root/Modules/GenerateExportHeader.cmake
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2011-08-11 16:18:19 (GMT)
committerStephen Kelly <steveire@gmail.com>2011-08-11 17:06:23 (GMT)
commite1f7ee3de71fc0e7a34bf05ec2cf4ec586ff9e32 (patch)
tree47a5dc6f427ae41244d3cb4d484e5aa21a8deda6 /Modules/GenerateExportHeader.cmake
parent9554e1013ef5d9971092ed0cd45daf59b8a6bd87 (diff)
downloadCMake-e1f7ee3de71fc0e7a34bf05ec2cf4ec586ff9e32.zip
CMake-e1f7ee3de71fc0e7a34bf05ec2cf4ec586ff9e32.tar.gz
CMake-e1f7ee3de71fc0e7a34bf05ec2cf4ec586ff9e32.tar.bz2
Test for compiler features, instead of for specific platforms.
Diffstat (limited to 'Modules/GenerateExportHeader.cmake')
-rw-r--r--Modules/GenerateExportHeader.cmake38
1 files changed, 22 insertions, 16 deletions
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index f690655..578d71f 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -115,6 +115,20 @@
include(CMakeParseArguments)
include(CheckCXXCompilerFlag)
+
+# TODO: Install this macro separately?
+macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT)
+ check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } int main() { return somefunc();}" ${_RESULT}
+ # Some compilers do not fail with a bad flag
+ FAIL_REGEX "unrecognized .*option" # GNU
+ FAIL_REGEX "ignoring unknown option" # MSVC
+ FAIL_REGEX "warning D9002" # MSVC, any lang
+ FAIL_REGEX "[Uu]nknown option" # HP
+ FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
+ FAIL_REGEX "command option .* is not recognized" # XL
+ )
+endmacro()
+
macro(_test_compiler_hidden_visibility)
if (CMAKE_COMPILER_IS_GNUCXX)
@@ -141,15 +155,11 @@ macro(_test_compiler_hidden_visibility)
endmacro()
macro(_test_compiler_has_deprecated)
- if (WIN32)
- if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES Borland)
- set(COMPILER_HAS_DEPRECATED TRUE)
- endif()
+ _check_cxx_compiler_attribute("__declspec(deprecated)" COMPILER_HAS_DEPRECATED_DECLSPEC)
+ if(COMPILER_HAS_DEPRECATED_DECLSPEC)
+ set(COMPILER_HAS_DEPRECATED ${COMPILER_HAS_DEPRECATED_DECLSPEC})
else()
- # TODO: Test properly for this
- if(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY)
- set(COMPILER_HAS_DEPRECATED TRUE)
- endif()
+ _check_cxx_compiler_attribute("__attribute__((__deprecated__))" COMPILER_HAS_DEPRECATED)
endif()
set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED}" CACHE INTERNAL "Compiler support for a deprecated attribute")
endmacro()
@@ -162,14 +172,10 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY)
set(DEFINE_IMPORT)
set(DEFINE_NO_EXPORT)
- if(WIN32)
- if (COMPILER_HAS_DEPRECATED)
- set(DEFINE_DEPRECATED "__declspec(deprecated)")
- endif()
- else()
- if(COMPILER_HAS_DEPRECATED)
- set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))")
- endif()
+ if (COMPILER_HAS_DEPRECATED_DECLSPEC)
+ set(DEFINE_DEPRECATED "__declspec(deprecated)")
+ elseif(COMPILER_HAS_DEPRECATED)
+ set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))")
endif()
get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE)