cmake: do not add visibility attributes to shared lib builds for win32.
authorsezero <sezero@users.sourceforge.net>
Tue, 8 Oct 2019 12:14:04 +0000 (15:14 +0300)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Thu, 10 Oct 2019 07:30:39 +0000 (18:30 +1100)
src/libFLAC++/CMakeLists.txt
src/libFLAC/CMakeLists.txt

index d6e3dfd..4f4a02b 100644 (file)
@@ -24,17 +24,25 @@ add_library(FLAC++
     stream_encoder.cpp)
 target_compile_definitions(FLAC++
     PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLACPP_API_EXPORTS>
-    PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>
     PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:FLAC__NO_DLL>)
+if(NOT WIN32)
+target_compile_definitions(FLAC++
+    PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>
+)
+endif()
 target_include_directories(FLAC++ INTERFACE
     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
 target_link_libraries(FLAC++ PUBLIC FLAC)
 if(BUILD_SHARED_LIBS)
     set_target_properties(FLAC++ PROPERTIES
-        CXX_VISIBILITY_PRESET hidden
         VERSION 6.3.0
         SOVERSION 6)
+if(NOT WIN32)
+    set_target_properties(FLAC++ PROPERTIES
+        CXX_VISIBILITY_PRESET hidden
+    )
+endif()
 endif()
 
 install(TARGETS FLAC++ EXPORT targets
index a6e0c01..63711cf 100644 (file)
@@ -97,8 +97,12 @@ endif()
 
 target_compile_definitions(FLAC
     PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC_API_EXPORTS>
-    PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>
     PUBLIC $<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:FLAC__NO_DLL>)
+if(NOT WIN32)
+target_compile_definitions(FLAC
+    PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:FLAC__USE_VISIBILITY_ATTR>
+)
+endif()
 target_include_directories(FLAC INTERFACE
     "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
     "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
@@ -108,10 +112,15 @@ if(TARGET Ogg::ogg)
 endif()
 if(BUILD_SHARED_LIBS)
     set_target_properties(FLAC PROPERTIES
-        C_VISIBILITY_PRESET hidden
         VERSION 8.3.0
         SOVERSION 8)
+if(NOT WIN32)
+    set_target_properties(FLAC PROPERTIES
+        C_VISIBILITY_PRESET hidden
+    )
 endif()
+endif()
+
 
 install(TARGETS FLAC EXPORT targets
     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/"