diff --git a/CMakeLists.txt b/CMakeLists.txt index 44601ba9..42f9bf46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,6 +120,10 @@ if(WEBP_UNICODE) add_definitions(-DUNICODE -D_UNICODE) endif() +if(MSVC AND BUILD_SHARED_LIBS) + add_definitions(-DWEBP_DLL) +endif() + set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\$\{prefix\}") set(libdir "\$\{prefix\}/lib") diff --git a/Makefile.vc b/Makefile.vc index f2541097..8d1ab877 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -119,8 +119,7 @@ LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME).lib LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME).lib LIBWEBPDEMUX = $(DIRLIB)\$(LIBWEBPDEMUX_BASENAME).lib !ELSE IF "$(DLLBUILD)" == "TRUE" -DLLINC = webp_dll.h -CC = $(CC) /I$(DIROBJ) /FI$(DLLINC) $(RTLIB) /DWEBP_DLL +CC = $(CC) /I$(DIROBJ) $(RTLIB) /DWEBP_DLL LIBWEBPDECODER = $(DIRLIB)\$(LIBWEBPDECODER_BASENAME)_dll.lib LIBWEBP = $(DIRLIB)\$(LIBWEBP_BASENAME)_dll.lib LIBWEBPMUX = $(DIRLIB)\$(LIBWEBPMUX_BASENAME)_dll.lib @@ -425,9 +424,6 @@ $(LIBWEBPDEMUX): $(LIBWEBPDEMUX_OBJS) $(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): $(OUTPUT_DIRS) !IF "$(DLLBUILD)" == "TRUE" -$(LIBWEBP_OBJS) $(LIBWEBPMUX_OBJS) $(LIBWEBPDEMUX_OBJS): \ - $(DIROBJ)\$(DLLINC) - {$(DIROBJ)}.c{$(DIROBJ)}.obj: $(CC) $(CFLAGS) /Fd$(LIBWEBP_PDBNAME) /Fo$@ $< @@ -446,9 +442,6 @@ $(LIBWEBPDEMUX): $(LIBWEBP) $(DIROBJ)\demux\$(LIBWEBPDEMUX_BASENAME:_debug=).res $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): $(LNKDLL) /out:$(DIRBIN)\$(@B:_dll=.dll) /implib:$@ $(LFLAGS) $** -xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y - -clean:: - @-erase /s $(DIROBJ)\$(DLLINC) 2> NUL !ELSE $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): $(LNKLIB) /out:$@ $** @@ -458,13 +451,6 @@ $(LIBWEBPDECODER) $(LIBWEBP) $(LIBWEBPMUX) $(LIBWEBPDEMUX): $(OUTPUT_DIRS): @if not exist "$(@)" mkdir "$(@)" -# generate a helper include to define WEBP_EXTERN suitable for the DLL build -$(DIROBJ)\$(DLLINC): - @echo #ifndef WEBP_DLL_H_ > $@ - @echo #define WEBP_DLL_H_ >> $@ - @echo #define WEBP_EXTERN __declspec(dllexport) >> $@ - @echo #endif /* WEBP_DLL_H_ */ >> $@ - .SUFFIXES: .c .obj .res .exe # File-specific flag builds. Note batch rules take precedence over wildcards, # so for now name each file individually. diff --git a/cmake/cpu.cmake b/cmake/cpu.cmake index bc0dbc98..1c88a8e0 100644 --- a/cmake/cpu.cmake +++ b/cmake/cpu.cmake @@ -58,7 +58,6 @@ else() "-mno-sse4.1;-mno-sse2;;-mno-dspr2;;-mno-msa") endif() -set(WEBP_SIMD_FILES_TO_NOT_INCLUDE) set(WEBP_SIMD_FILES_TO_INCLUDE) set(WEBP_SIMD_FLAGS_TO_INCLUDE) diff --git a/sharpyuv/sharpyuv.h b/sharpyuv/sharpyuv.h index 7ce92f9b..2ea7564d 100644 --- a/sharpyuv/sharpyuv.h +++ b/sharpyuv/sharpyuv.h @@ -27,7 +27,11 @@ extern "C" { #if defined(__GNUC__) && __GNUC__ >= 4 #define SHARPYUV_EXTERN extern __attribute__((visibility("default"))) #else +#if defined(_MSC_VER) && defined(WEBP_DLL) +#define SHARPYUV_EXTERN __declspec(dllexport) +#else #define SHARPYUV_EXTERN extern +#endif /* _MSC_VER && WEBP_DLL */ #endif /* __GNUC__ >= 4 */ #endif /* WEBP_EXTERN */ #endif /* SHARPYUV_EXTERN */ diff --git a/src/webp/types.h b/src/webp/types.h index 47f7f2b0..f255432e 100644 --- a/src/webp/types.h +++ b/src/webp/types.h @@ -42,7 +42,11 @@ typedef long long int int64_t; # if defined(__GNUC__) && __GNUC__ >= 4 # define WEBP_EXTERN extern __attribute__ ((visibility ("default"))) # else -# define WEBP_EXTERN extern +# if defined(_MSC_VER) && defined(WEBP_DLL) +# define WEBP_EXTERN __declspec(dllexport) +# else +# define WEBP_EXTERN extern +# endif # endif /* __GNUC__ >= 4 */ #endif /* WEBP_EXTERN */