Backed out 3 changesets (bug 1790375) for causing wd failures on fetch_error.py....
[gecko.git] / third_party / jpeg-xl / lib / CMakeLists.txt
blob1e4ad78452684b32ccb4f560664ff1442809db48
1 # Copyright (c) the JPEG XL Project Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
6 set(JPEGXL_MAJOR_VERSION 0)
7 set(JPEGXL_MINOR_VERSION 10)
8 set(JPEGXL_PATCH_VERSION 0)
9 set(JPEGXL_LIBRARY_VERSION
10     "${JPEGXL_MAJOR_VERSION}.${JPEGXL_MINOR_VERSION}.${JPEGXL_PATCH_VERSION}")
12 # This is the library API/ABI compatibility version. Changing this value makes
13 # the shared library incompatible with previous version. A program linked
14 # against this shared library SOVERSION will not run with an older SOVERSION.
15 # It is important to update this value when making incompatible API/ABI changes
16 # so that programs that depend on libjxl can update their dependencies. Semantic
17 # versioning allows 0.y.z to have incompatible changes in minor versions.
18 set(JPEGXL_SO_MINOR_VERSION 10)
19 if (JPEGXL_MAJOR_VERSION EQUAL 0)
20   set(JPEGXL_LIBRARY_SOVERSION
21       "${JPEGXL_MAJOR_VERSION}.${JPEGXL_SO_MINOR_VERSION}")
22 else()
23   set(JPEGXL_LIBRARY_SOVERSION "${JPEGXL_MAJOR_VERSION}")
24 endif()
27 # List of warning and feature flags for our library and tests.
28 if (MSVC)
29   set(JPEGXL_INTERNAL_FLAGS
30     # TODO(janwas): add flags
31   )
32 else ()
33   set(JPEGXL_INTERNAL_FLAGS
34     # F_FLAGS
35     -fmerge-all-constants
36     -fno-builtin-fwrite
37     -fno-builtin-fread
39     # WARN_FLAGS
40     -Wall
41     -Wextra
42     -Wc++11-compat
43     -Warray-bounds
44     -Wformat-security
45     -Wimplicit-fallthrough
46     -Wno-register  # Needed by public headers in lcms
47     -Wno-unused-function
48     -Wno-unused-parameter
49     -Wnon-virtual-dtor
50     -Woverloaded-virtual
51     -Wvla
52   )
54   # Warning flags supported by clang.
55   if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
56     list(APPEND JPEGXL_INTERNAL_FLAGS
57       -Wdeprecated-increment-bool
58       # TODO(deymo): Add -Wextra-semi once we update third_party/highway.
59       # -Wextra-semi
60       -Wfloat-overflow-conversion
61       -Wfloat-zero-conversion
62       -Wfor-loop-analysis
63       -Wgnu-redeclared-enum
64       -Winfinite-recursion
65       -Wliteral-conversion
66       -Wno-c++98-compat
67       -Wno-unused-command-line-argument
68       -Wprivate-header
69       -Wself-assign
70       -Wstring-conversion
71       -Wtautological-overlap-compare
72       -Wthread-safety-analysis
73       -Wundefined-func-template
74       -Wunreachable-code
75       -Wunused-comparison
76     )
77     if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0)
78       list(APPEND HWY_FLAGS -Wc++2a-extensions)
79     endif()
80   endif()  # Clang
82   if (WIN32)
83     list(APPEND JPEGXL_INTERNAL_FLAGS
84       -Wno-cast-align
85       -Wno-double-promotion
86       -Wno-float-equal
87       -Wno-format-nonliteral
88       -Wno-shadow
89       -Wno-sign-conversion
90       -Wno-zero-as-null-pointer-constant
91     )
93     if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
94       list(APPEND JPEGXL_INTERNAL_FLAGS
95         -Wno-used-but-marked-unused
96         -Wno-unused-template
97         -Wno-unused-member-function
98         -Wno-shadow-field-in-constructor
99         -Wno-language-extension-token
100         -Wno-global-constructors
101         -Wno-c++98-compat-pedantic
102       )
103     endif()  # Clang
104   else()  # WIN32
105     list(APPEND JPEGXL_INTERNAL_FLAGS
106       -fsized-deallocation
107       -fno-exceptions
109       # Language flags
110       -fmath-errno
111     )
113     if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
114       list(APPEND JPEGXL_INTERNAL_FLAGS
115         -fnew-alignment=8
116         -fno-cxx-exceptions
117         -fno-slp-vectorize
118         -fno-vectorize
120         -disable-free
121         -disable-llvm-verifier
122       )
123     endif()  # Clang
124   endif()  # WIN32
125 endif()  #!MSVC
127 if (JPEGXL_ENABLE_SKCMS)
128   list(APPEND JPEGXL_INTERNAL_FLAGS -DJPEGXL_ENABLE_SKCMS=1)
129 endif ()
131 # strips the -internal suffix from all the elements in LIST
132 function(strip_internal OUTPUT_VAR LIB_LIST)
133   foreach(lib IN LISTS ${LIB_LIST})
134     string(REGEX REPLACE "-internal$" "" lib "${lib}")
135     list(APPEND out_list "${lib}")
136   endforeach()
137   set(${OUTPUT_VAR} ${out_list} PARENT_SCOPE)
138 endfunction()
140 # set variables for jxl_cms.cmake and jxl.cmake
141 if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
142     set(PKGCONFIG_TARGET_INCLUDES "${CMAKE_INSTALL_INCLUDEDIR}")
143 else()
144     set(PKGCONFIG_TARGET_INCLUDES "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
145 endif()
146 if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
147     set(PKGCONFIG_TARGET_LIBS "${CMAKE_INSTALL_LIBDIR}")
148 else()
149     set(PKGCONFIG_TARGET_LIBS "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
150 endif()
152 # The jxl_cms library definition.
153 include(jxl_cms.cmake)
154 # The jxl library definition.
155 include(jxl.cmake)
157 # Other libraries outside the core jxl library.
158 if(JPEGXL_ENABLE_TOOLS OR BUILD_TESTING)
159   include(jxl_extras.cmake)
160 endif()
161 include(jxl_threads.cmake)
162 if (JPEGXL_ENABLE_JPEGLI)
163   include(jpegli.cmake)
164 endif()
166 # Install all the library headers from the source and the generated ones. There
167 # is no distinction on which libraries use which header since it is expected
168 # that all developer libraries are available together at build time.
169 install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/jxl
170   DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
171 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/jxl
172   DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
174 if(BUILD_TESTING)
175   include(GoogleTest)
176 endif()
178 # Tests for the jxl library.
179 include(jxl_tests.cmake)
181 if(BUILD_TESTING)
182   # Google benchmark for the jxl library
183   include(jxl_benchmark.cmake)
184 endif()