aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-08-29 05:22:51 -0700
committerChris Robinson <[email protected]>2023-08-29 05:22:51 -0700
commit7910f1afbdfb1ab886b3a9c7ac3165c7fd2065c0 (patch)
tree6f78d0416269edbf3c024fd3b8cc79aa30c97b10 /CMakeLists.txt
parente987e511a962772c96a2122265874c00cca2a54f (diff)
Don't set VISIBILITY_PRESETs without visibility attributes
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt43
1 files changed, 20 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 23dc7bd3..bb1f0399 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,9 +33,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(ALSOFT_UWP TRUE)
endif()
-set(CMAKE_C_VISIBILITY_PRESET hidden)
-set(CMAKE_CXX_VISIBILITY_PRESET hidden)
-
if(COMMAND CMAKE_POLICY)
cmake_policy(SET CMP0003 NEW)
cmake_policy(SET CMP0005 NEW)
@@ -361,32 +358,32 @@ else()
endif()
# Set visibility/export options if available
-if(WIN32)
- if(NOT LIBTYPE STREQUAL "STATIC")
+if(NOT LIBTYPE STREQUAL "STATIC")
+ if(WIN32)
set(EXPORT_DECL "__declspec(dllexport)")
- endif()
-else()
- set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
- # Yes GCC, really don't accept visibility modes you don't support
- set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
-
- check_c_source_compiles("int foo() __attribute__((visibility(\"protected\")));
- int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY)
- if(HAVE_GCC_PROTECTED_VISIBILITY)
- if(NOT LIBTYPE STREQUAL "STATIC")
- set(EXPORT_DECL "__attribute__((visibility(\"protected\")))")
- endif()
else()
- check_c_source_compiles("int foo() __attribute__((visibility(\"default\")));
- int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY)
- if(HAVE_GCC_DEFAULT_VISIBILITY)
- if(NOT LIBTYPE STREQUAL "STATIC")
+ set(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
+ # Yes GCC, really don't accept visibility modes you don't support
+ set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror")
+
+ check_c_source_compiles("int foo() __attribute__((visibility(\"protected\")));
+ 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()
- endif()
+ if(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY)
+ set(CMAKE_C_VISIBILITY_PRESET hidden)
+ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
+ endif()
- set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
+ set(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}")
+ endif()
endif()