summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-09-20 16:53:05 -0700
committerChris Robinson <[email protected]>2011-09-20 16:53:05 -0700
commit4e19f82a2b5cd53d0efec226b319b825fa280f4c (patch)
treef219f6eb9a0544fe4a7c09bf935c4dc41275060c /CMakeLists.txt
parent97743e32c265b8d6bf799912ea1863ca456bf42d (diff)
Try to use "default" and "hidden" visibility when "protected" and "internal" aren't available
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt27
1 files changed, 23 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36cc991a..b52e469c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -180,13 +180,32 @@ IF(WIN32)
ENDIF()
ENDIF()
ELSE()
- CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_SWITCH)
+ SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+ SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Werror")
+
CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\")));
- int main() {return 0;}" HAVE_GCC_VISIBILITY)
- IF(HAVE_VISIBILITY_SWITCH AND HAVE_GCC_VISIBILITY)
- ADD_DEFINITIONS(-fvisibility=internal)
+ int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
+ IF(HAVE_GCC_PROTECTED_VISIBILITY)
SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
+ ELSE()
+ CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\")));
+ int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
+ IF(HAVE_GCC_DEFAULT_VISIBILITY)
+ SET(EXPORT_DECL "__attribute__((visibility(\"default\")))")
+ ENDIF()
+ ENDIF()
+
+ CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH)
+ IF(HAVE_VISIBILITY_INTERNAL_SWITCH)
+ ADD_DEFINITIONS(-fvisibility=internal)
+ ELSE()
+ CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_HIDDEN_SWITCH)
+ IF(HAVE_VISIBILITY_HIDDEN_SWITCH)
+ ADD_DEFINITIONS(-fvisibility=hidden)
+ ENDIF()
ENDIF()
+
+ SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
ENDIF()
CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2)));