Skip to content

Commit 84400ed

Browse files
authored
Fix usage of HAVE_VISIBILITY/DEFAULT_VISIBILITY (#37)
Fixes: #36
1 parent 2eb3a90 commit 84400ed

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ function(generate_config_file)
5050

5151
check_struct_has_member("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC)
5252

53+
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
54+
check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
55+
else()
56+
set(HAVE_VISIBILITY OFF)
57+
endif()
58+
5359
if(HAVE_VISIBILITY)
5460
set(DEFAULT_VISIBILITY "__attribute__((visibility(\"default\")))")
5561
else()
@@ -74,10 +80,6 @@ function(generate_config_file)
7480
set(LIBUSB_WINDOWS_HOTPLUG 1)
7581
endif()
7682

77-
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
78-
check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
79-
endif()
80-
8183
file(MAKE_DIRECTORY "${LIBUSB_GEN_INCLUDES}")
8284
if(NOT MSVC)
8385
set(_GNU_SOURCE TRUE)

0 commit comments

Comments
 (0)