From dc4998bf702b14f51f36ab40d85d3b090d5bfa9c Mon Sep 17 00:00:00 2001 From: codicodi Date: Fri, 21 Jul 2017 13:01:00 +0200 Subject: [PATCH] [sdl2] Prevent exports in static build --- ports/sdl2-image/CMakeLists.txt | 92 ++++++++++--------- ports/sdl2-image/CONTROL | 2 +- ports/sdl2-image/portfile.cmake | 1 + ports/sdl2-mixer/CMakeLists.txt | 1 + ports/sdl2-mixer/CONTROL | 2 +- ports/sdl2-net/CMakeLists.txt | 1 + ports/sdl2-net/CONTROL | 2 +- ports/sdl2-ttf/CMakeLists.txt | 1 + ports/sdl2-ttf/CONTROL | 2 +- ports/sdl2/CONTROL | 2 +- .../export-symbols-only-in-shared-build.patch | 16 ++++ ports/sdl2/portfile.cmake | 1 + ports/smpeg2/CMakeLists.txt | 3 +- ports/smpeg2/CONTROL | 2 +- ports/smpeg2/portfile.cmake | 1 + 15 files changed, 77 insertions(+), 52 deletions(-) create mode 100644 ports/sdl2/export-symbols-only-in-shared-build.patch diff --git a/ports/sdl2-image/CMakeLists.txt b/ports/sdl2-image/CMakeLists.txt index e742a408dd3..8b5f7131f5d 100644 --- a/ports/sdl2-image/CMakeLists.txt +++ b/ports/sdl2-image/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.6) -project(SDL2_image) +project(SDL2_image C) ### configuration ### @@ -27,24 +27,26 @@ set(WEBP_DYNAMIC \"libwebp-4.dll\") add_library(SDL2_image IMG.c - IMG_bmp.c - IMG_gif.c - IMG_jpg.c - IMG_lbm.c - IMG_pcx.c - IMG_png.c - IMG_pnm.c - IMG_tga.c - IMG_tif.c - IMG_webp.c - IMG_xcf.c - IMG_xpm.c - IMG_xv.c - IMG_xxx.c - ) + IMG_bmp.c + IMG_gif.c + IMG_jpg.c + IMG_lbm.c + IMG_pcx.c + IMG_png.c + IMG_pnm.c + IMG_tga.c + IMG_tif.c + IMG_webp.c + IMG_xcf.c + IMG_xpm.c + IMG_xv.c + IMG_xxx.c + ) + +set_target_properties(SDL2_image PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS) foreach(FORMAT ${SUPPORTED_FORMATS}) - add_definitions(-DLOAD_${FORMAT}) + add_definitions(-DLOAD_${FORMAT}) endforeach(FORMAT) # SDL @@ -59,27 +61,27 @@ target_link_libraries(SDL2_image ${SDL_LIBRARY}) # external dependencies foreach(DEPENDENCY ${DEPENDENCIES}) - find_package(${DEPENDENCY}) - - if(NOT DEFINED ${DEPENDENCY}_FLAG) - set(${DEPENDENCY}_FLAG ${DEPENDENCY}) - endif() - - add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}) - if(${DEPENDENCY}_FOUND) - message(STATUS " --> linking statically.") - target_link_libraries(SDL2_image ${${DEPENDENCY}_LIBRARIES}) - elseif(DEFINED ${DEPENDENCY}_DYNAMIC) - message(STATUS " --> linking dynamically.") - add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}_DYNAMIC=${${DEPENDENCY}_DYNAMIC}) - set(RUNTIME_DEPENDENCIES ON) - else() - message(STATUS " --> skipping.") - endif() + find_package(${DEPENDENCY}) + + if(NOT DEFINED ${DEPENDENCY}_FLAG) + set(${DEPENDENCY}_FLAG ${DEPENDENCY}) + endif() + + add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}) + if(${DEPENDENCY}_FOUND) + message(STATUS " --> linking statically.") + target_link_libraries(SDL2_image ${${DEPENDENCY}_LIBRARIES}) + elseif(DEFINED ${DEPENDENCY}_DYNAMIC) + message(STATUS " --> linking dynamically.") + add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}_DYNAMIC=${${DEPENDENCY}_DYNAMIC}) + set(RUNTIME_DEPENDENCIES ON) + else() + message(STATUS " --> skipping.") + endif() endforeach(DEPENDENCY) if(DEFINED RUNTIME_DEPENDENCIES) - include_directories(VisualC/external/include) + include_directories(VisualC/external/include) endif() @@ -94,16 +96,16 @@ install(FILES SDL_image.h DESTINATION include/SDL2 CONFIGURATIONS Release) message(STATUS "Link-time dependencies:") message(STATUS " " ${SDL_LIBRARY}) foreach(DEPENDENCY ${DEPENDENCIES}) - if(${DEPENDENCY}_FOUND) - message(STATUS " " ${DEPENDENCY}) - endif() + if(${DEPENDENCY}_FOUND) + message(STATUS " " ${DEPENDENCY}) + endif() endforeach(DEPENDENCY) if(DEFINED RUNTIME_DEPENDENCIES) - message(STATUS "Run-time dependencies:") - foreach(DEPENDENCY ${DEPENDENCIES}) - if(NOT ${DEPENDENCY}_FOUND AND DEFINED ${DEPENDENCY}_DYNAMIC) - message(STATUS " " ${${DEPENDENCY}_DYNAMIC}) - endif() - endforeach(DEPENDENCY) -endif() \ No newline at end of file + message(STATUS "Run-time dependencies:") + foreach(DEPENDENCY ${DEPENDENCIES}) + if(NOT ${DEPENDENCY}_FOUND AND DEFINED ${DEPENDENCY}_DYNAMIC) + message(STATUS " " ${${DEPENDENCY}_DYNAMIC}) + endif() + endforeach(DEPENDENCY) +endif() diff --git a/ports/sdl2-image/CONTROL b/ports/sdl2-image/CONTROL index 04c9f77bbc9..5ebec2f386f 100644 --- a/ports/sdl2-image/CONTROL +++ b/ports/sdl2-image/CONTROL @@ -1,5 +1,5 @@ Source: sdl2-image -Version: 2.0.1 +Version: 2.0.1-1 Build-Depends: sdl2, libpng, libjpeg-turbo, tiff, libwebp Description: SDL_image is an image file loading library. It loads images as SDL surfaces and textures, and supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF, WEBP, XCF, XPM, XV diff --git a/ports/sdl2-image/portfile.cmake b/ports/sdl2-image/portfile.cmake index 4cc6ce74af9..ad3f1a2d52d 100644 --- a/ports/sdl2-image/portfile.cmake +++ b/ports/sdl2-image/portfile.cmake @@ -25,6 +25,7 @@ file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindWEBP.cmake DESTINATION ${SOURCE_PATH}/cm vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA # OPTIONS # OPTIONS_RELEASE -DOPTIMIZE=1 # OPTIONS_DEBUG -DDEBUGGABLE=1 diff --git a/ports/sdl2-mixer/CMakeLists.txt b/ports/sdl2-mixer/CMakeLists.txt index 094912b4804..6d1cb28c044 100644 --- a/ports/sdl2-mixer/CMakeLists.txt +++ b/ports/sdl2-mixer/CMakeLists.txt @@ -76,6 +76,7 @@ add_library(SDL2_mixer native_midi/native_midi_common.c native_midi/native_midi_win32.c) +set_target_properties(SDL2_mixer PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS) target_compile_definitions(SDL2_mixer PRIVATE ${SDL_MIXER_DEFINES}) target_include_directories(SDL2_mixer PRIVATE ${SDL_MIXER_INCLUDES} ./native_midi) target_link_libraries(SDL2_mixer ${SDL_MIXER_LIBRARIES} Winmm) diff --git a/ports/sdl2-mixer/CONTROL b/ports/sdl2-mixer/CONTROL index b5d51aecdbe..88356b73f02 100644 --- a/ports/sdl2-mixer/CONTROL +++ b/ports/sdl2-mixer/CONTROL @@ -1,4 +1,4 @@ Source: sdl2-mixer -Version: 2.0.1 +Version: 2.0.1-1 Description: Multi-channel audio mixer library for SDL. Build-Depends: sdl2, libflac, smpeg2, libmodplug, libvorbis diff --git a/ports/sdl2-net/CMakeLists.txt b/ports/sdl2-net/CMakeLists.txt index d87b88c89cf..9b81f8d421c 100644 --- a/ports/sdl2-net/CMakeLists.txt +++ b/ports/sdl2-net/CMakeLists.txt @@ -8,6 +8,7 @@ find_library(SDL_LIBRARY SDL2) add_library(SDL2_net SDLnet.c SDLnetselect.c SDLnetTCP.c SDLnetUDP.c) +set_target_properties(SDL2_net PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS) target_compile_definitions(SDL2_net PRIVATE _WINSOCK_DEPRECATED_NO_WARNINGS) target_include_directories(SDL2_net PRIVATE ${SDL_INCLUDE_DIR}/SDL2) target_link_libraries(SDL2_net ${SDL_LIBRARY} ws2_32 iphlpapi) diff --git a/ports/sdl2-net/CONTROL b/ports/sdl2-net/CONTROL index 850cc916384..692bb7615e3 100644 --- a/ports/sdl2-net/CONTROL +++ b/ports/sdl2-net/CONTROL @@ -1,4 +1,4 @@ Source: sdl2-net -Version: 2.0.1 +Version: 2.0.1-1 Description: Networking library for SDL Build-Depends: sdl2 diff --git a/ports/sdl2-ttf/CMakeLists.txt b/ports/sdl2-ttf/CMakeLists.txt index f2e67748331..133616479cb 100644 --- a/ports/sdl2-ttf/CMakeLists.txt +++ b/ports/sdl2-ttf/CMakeLists.txt @@ -7,6 +7,7 @@ find_package(FreeType REQUIRED) add_library(SDL2_ttf SDL_ttf.c) +set_target_properties(SDL2_ttf PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS) target_include_directories(SDL2_ttf PRIVATE ${SDL_INCLUDE_DIR}/SDL2 ${FREETYPE_INCLUDE_DIR_ft2build}) target_link_libraries(SDL2_ttf ${SDL_LIBRARY} ${FREETYPE_LIBRARY}) diff --git a/ports/sdl2-ttf/CONTROL b/ports/sdl2-ttf/CONTROL index de0385428a3..fe09831eed9 100644 --- a/ports/sdl2-ttf/CONTROL +++ b/ports/sdl2-ttf/CONTROL @@ -1,4 +1,4 @@ Source: sdl2-ttf -Version: 2.0.14 +Version: 2.0.14-1 Description: A library for rendering TrueType fonts with SDL Build-Depends: sdl2, freetype diff --git a/ports/sdl2/CONTROL b/ports/sdl2/CONTROL index c0d74769106..f228205790d 100644 --- a/ports/sdl2/CONTROL +++ b/ports/sdl2/CONTROL @@ -1,3 +1,3 @@ Source: sdl2 -Version: 2.0.5-2 +Version: 2.0.5-3 Description: Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. diff --git a/ports/sdl2/export-symbols-only-in-shared-build.patch b/ports/sdl2/export-symbols-only-in-shared-build.patch new file mode 100644 index 00000000000..b442954d573 --- /dev/null +++ b/ports/sdl2/export-symbols-only-in-shared-build.patch @@ -0,0 +1,16 @@ +diff --git a/include/begin_code.h b/include/begin_code.h +index 04e78c6..16464f5 100644 +--- a/include/begin_code.h ++++ b/include/begin_code.h +@@ -58,8 +58,10 @@ + # else + # define DECLSPEC __declspec(dllimport) + # endif +-# else ++# elif defined(SDL2_EXPORTS) + # define DECLSPEC __declspec(dllexport) ++# else ++# define DECLSPEC + # endif + # else + # if defined(__GNUC__) && __GNUC__ >= 4 diff --git a/ports/sdl2/portfile.cmake b/ports/sdl2/portfile.cmake index 185e396654b..33123c1ba9d 100644 --- a/ports/sdl2/portfile.cmake +++ b/ports/sdl2/portfile.cmake @@ -11,6 +11,7 @@ vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} PATCHES ${CMAKE_CURRENT_LIST_DIR}/dont-ignore-default-libs.patch + ${CMAKE_CURRENT_LIST_DIR}/export-symbols-only-in-shared-build.patch ) if(VCPKG_CMAKE_SYSTEM_NAME MATCHES "WindowsStore") diff --git a/ports/smpeg2/CMakeLists.txt b/ports/smpeg2/CMakeLists.txt index 9f061cfb85b..7cda2840af6 100644 --- a/ports/smpeg2/CMakeLists.txt +++ b/ports/smpeg2/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.6) -project(SMPEG2) +project(SMPEG2 CXX) find_path(SDL_INCLUDE_DIR SDL2/SDL.h) find_library(SDL_LIBRARY SDL2) @@ -42,6 +42,7 @@ add_library(smpeg2 MPEGsystem.cpp smpeg.cpp) +set_target_properties(smpeg2 PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS) target_link_libraries(smpeg2 ${SDL_LIBRARY}) install(TARGETS smpeg2 diff --git a/ports/smpeg2/CONTROL b/ports/smpeg2/CONTROL index 8465a644691..26c0b3904cb 100644 --- a/ports/smpeg2/CONTROL +++ b/ports/smpeg2/CONTROL @@ -1,4 +1,4 @@ Source: smpeg2 -Version: 2.0.0 +Version: 2.0.0-1 Description: SDL MPEG Player Library Build-Depends: sdl2 diff --git a/ports/smpeg2/portfile.cmake b/ports/smpeg2/portfile.cmake index 43e6e623e40..7639ca26482 100644 --- a/ports/smpeg2/portfile.cmake +++ b/ports/smpeg2/portfile.cmake @@ -17,6 +17,7 @@ file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA OPTIONS_DEBUG -DSMPEG_SKIP_HEADERS=ON)