From 4ca012d702e504ac1d11f00653abe3658e495f5b Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Sat, 18 Oct 2025 13:43:50 +0300 Subject: [PATCH 1/2] Fix usage of HAVE_VISIBILITY/DEFAULT_VISIBILITY Fixes: #36 --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5464724f..e574630b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,10 @@ function(generate_config_file) check_struct_has_member("struct timespec" tv_sec time.h HAVE_STRUCT_TIMESPEC) + if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") + check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY) + endif() + if(HAVE_VISIBILITY) set(DEFAULT_VISIBILITY "__attribute__((visibility(\"default\")))") else() @@ -70,10 +74,6 @@ function(generate_config_file) set(ENABLE_DEBUG_LOGGING ${LIBUSB_ENABLE_DEBUG_LOGGING}) endif() - if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") - check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY) - endif() - file(MAKE_DIRECTORY "${LIBUSB_GEN_INCLUDES}") if(NOT MSVC) set(_GNU_SOURCE TRUE) From 425d2f261a0c2696050de8fc7484abea5b88e6bf Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Sat, 18 Oct 2025 13:56:35 +0300 Subject: [PATCH 2/2] strict check --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d42265..27fa014c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,8 @@ function(generate_config_file) if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "GNU") check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY) + else() + set(HAVE_VISIBILITY OFF) endif() if(HAVE_VISIBILITY)