aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/libpng/cmake.patch
blob: ebac200f74d6849473d3b6a0136a5d3d8fe3dff1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d91e3a6c3..249d04c0f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,6 +144,12 @@ set(PNG_LINK_LIBRARIES ZLIB::ZLIB)
 # Find the math library (unless we already know it's not available or
 # not needed).
 if(UNIX AND NOT (APPLE OR BEOS OR HAIKU OR EMSCRIPTEN))
+  block(SCOPE_FOR VARIABLES)
+    if(VCPKG_CRT_LINKAGE STREQUAL "static")
+      list(PREPEND CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}")
+    endif()
+    check_library_exists(m pow "${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}" PNG_HAVE_LIBM_POW)
+  endblock()
   check_library_exists(m pow "" PNG_HAVE_LIBM_POW)
 endif()
 if(PNG_HAVE_LIBM_POW)
@@ -240,9 +246,9 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
 
   # Set definitions and sources for MIPS.
   if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)")
-    set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
+    set(PNG_MIPS_MSA_POSSIBLE_VALUES on off check)
     set(PNG_MIPS_MSA
-        "on"
+        "check"
         CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
     set_property(CACHE PNG_MIPS_MSA
                  PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
@@ -269,6 +275,12 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
           mips/filter_mmi_inline_assembly.c)
       add_definitions(-DPNG_MIPS_MSA_OPT=2)
       add_definitions(-DPNG_MIPS_MMI_OPT=1)
+    elseif(PNG_MIPS_MSA STREQUAL "check")
+      set(libpng_mips_sources
+          mips/mips_init.c
+          mips/filter_msa_intrinsics.c)
+      add_definitions(-DPNG_MIPS_MSA_CHECK_SUPPORTED)
+      add_definitions(-DPNG_MIPS_MMI_CHECK_SUPPORTED)
     elseif(PNG_MIPS_MSA STREQUAL "on")
       set(libpng_mips_sources
           mips/mips_init.c
@@ -661,7 +673,7 @@ else()
   # We also need to use a custom suffix, in order to distinguish between the
   # shared import library name and the static library name.
   set(PNG_SHARED_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
-  set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}_static")
+  set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
 endif()
 
 if(PNG_SHARED)
@@ -939,10 +951,10 @@ if(PNG_TESTS AND PNG_SHARED)
                FILES ${PNGSUITE_PNGS})
 endif()
 
-if(PNG_SHARED AND PNG_TOOLS)
+if(PNG_TOOLS)
   add_executable(pngfix ${pngfix_sources})
   target_link_libraries(pngfix
-                        PRIVATE png_shared)
+                        PRIVATE $<TARGET_NAME_IF_EXISTS:png_shared> $<TARGET_NAME_IF_EXISTS:png_static>) # in vcpkg there's only one
   set(PNG_BIN_TARGETS pngfix)
 
   add_executable(png-fix-itxt ${png_fix_itxt_sources})
@@ -1028,12 +1040,15 @@ endif()
 # We use the same files like ./configure, so we have to set its vars.
 # Only do this on Windows for Cygwin - the files don't make much sense
 # outside of a UNIX look-alike.
-if(NOT WIN32 OR CYGWIN OR MINGW)
+if(1)
   set(prefix "${CMAKE_INSTALL_PREFIX}")
   set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
   set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
   set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
-  set(LIBS "-lz -lm")
+  set(LIBS "")
+  if(PNG_HAVE_LIBM_POW)
+    string(APPEND LIBS "-lm")
+  endif()
   configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in"
                  "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc"
                  @ONLY)
@@ -1092,6 +1107,9 @@ if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
 endif()
 
 if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
+          DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+elseif(0)
   # Install the man pages.
   install(FILES libpng.3 libpngpf.3
           DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")