]> git.lyx.org Git - lyx.git/blob - 3rdparty/zlib/CMakeLists.txt
Cache the value of FontMetrics::xHeight()
[lyx.git] / 3rdparty / zlib / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.1)
2
3 set(LYX_IPO_SUPPORTED FALSE)
4 if (POLICY CMP0069)
5   cmake_policy(SET CMP0069 NEW)
6   if (LYX_USE_IPO MATCHES "ON")
7     set(LYX_IPO_SUPPORTED YES)
8   endif()
9 endif()
10 if (POLICY CMP0075)
11   cmake_policy(SET CMP0075 NEW)
12 endif()
13
14 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
15
16 project(zlib C)
17
18 set(VERSION "1.2.11")
19 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/1.2.11)
20
21 option(ASM686 "Enable building i686 assembly implementation")
22 option(AMD64 "Enable building amd64 assembly implementation")
23
24 include(CheckTypeSize)
25 include(CheckFunctionExists)
26 include(CheckIncludeFile)
27 include(CheckCSourceCompiles)
28 enable_testing()
29
30 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
31 check_include_file(stdint.h    HAVE_STDINT_H)
32 check_include_file(stddef.h    HAVE_STDDEF_H)
33
34 #
35 # Check to see if we have large file support
36 #
37 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
38 # We add these other definitions here because CheckTypeSize.cmake
39 # in CMake 2.4.x does not automatically do so and we want
40 # compatibility with CMake 2.4.x.
41 if(HAVE_SYS_TYPES_H)
42     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
43 endif()
44 if(HAVE_STDINT_H)
45     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
46 endif()
47 if(HAVE_STDDEF_H)
48     list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
49 endif()
50 check_type_size(off64_t OFF64_T)
51 if(HAVE_OFF64_T)
52    add_definitions(-D_LARGEFILE64_SOURCE=1)
53 endif()
54 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
55
56 #
57 # Check for fseeko
58 #
59 check_function_exists(fseeko HAVE_FSEEKO)
60 if(NOT HAVE_FSEEKO)
61     add_definitions(-DNO_FSEEKO)
62 endif()
63
64 #
65 # Check for unistd.h
66 #
67 check_include_file(unistd.h Z_HAVE_UNISTD_H)
68
69 if(MSVC)
70     set(CMAKE_DEBUG_POSTFIX "d")
71     add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
72     add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
73     include_directories(${CMAKE_CURRENT_SOURCE_DIR})
74 endif()
75
76 if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
77     # If we're doing an out of source build and the user has a zconf.h
78     # in their source tree...
79     if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
80         message(STATUS "Renaming")
81         message(STATUS "    ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
82         message(STATUS "to 'zconf.h.included' because this file is included with zlib")
83         message(STATUS "but CMake generates it automatically in the build directory.")
84         file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
85   endif()
86 endif()
87
88 #set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
89 #configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
90 set(Z_PREFIX 1)
91 configure_file(${SRCDIR}/zconf.h.cmakein ${CMAKE_BINARY_DIR}/zconf.h @ONLY)
92 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
93
94
95 #============================================================================
96 # zlib
97 #============================================================================
98
99 set(ZLIB_PUBLIC_HDRS
100     ${CMAKE_BINARY_DIR}/zconf.h
101     ${SRCDIR}/zlib.h
102 )
103 set(ZLIB_PRIVATE_HDRS
104     ${SRCDIR}/crc32.h
105     ${SRCDIR}/deflate.h
106     ${SRCDIR}/gzguts.h
107     ${SRCDIR}/inffast.h
108     ${SRCDIR}/inffixed.h
109     ${SRCDIR}/inflate.h
110     ${SRCDIR}/inftrees.h
111     ${SRCDIR}/trees.h
112     ${SRCDIR}/zutil.h
113 )
114 set(ZLIB_SRCS
115     ${SRCDIR}/adler32.c
116     ${SRCDIR}/compress.c
117     ${SRCDIR}/crc32.c
118     ${SRCDIR}/deflate.c
119     ${SRCDIR}/gzclose.c
120     ${SRCDIR}/gzlib.c
121     ${SRCDIR}/gzread.c
122     ${SRCDIR}/gzwrite.c
123     ${SRCDIR}/inflate.c
124     ${SRCDIR}/infback.c
125     ${SRCDIR}/inftrees.c
126     ${SRCDIR}/inffast.c
127     ${SRCDIR}/trees.c
128     ${SRCDIR}/uncompr.c
129     ${SRCDIR}/zutil.c
130 )
131
132
133 if(CMAKE_COMPILER_IS_GNUCC)
134     if(ASM686)
135         set(ZLIB_ASMS contrib/asm686/match.S)
136     elseif (AMD64)
137         set(ZLIB_ASMS contrib/amd64/amd64-match.S)
138     endif ()
139
140         if(ZLIB_ASMS)
141                 add_definitions(-DASMV)
142                 set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
143         endif()
144 endif()
145
146 if(MSVC)
147     if(ASM686)
148                 ENABLE_LANGUAGE(ASM_MASM)
149         set(ZLIB_ASMS
150                         contrib/masmx86/inffas32.asm
151                         contrib/masmx86/match686.asm
152                 )
153     elseif (AMD64)
154                 ENABLE_LANGUAGE(ASM_MASM)
155         set(ZLIB_ASMS
156                         contrib/masmx64/gvmat64.asm
157                         contrib/masmx64/inffasx64.asm
158                 )
159     endif()
160
161         if(ZLIB_ASMS)
162                 add_definitions(-DASMV -DASMINF)
163         endif()
164 endif()
165
166 add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
167
168
169 set(ZLIB_LIBRARY zlibstatic CACHE STRING "Zlib library" FORCE)
170 set(ZLIB_INCLUDE_DIR  ${SRCDIR} CACHE STRING "Zlib include dir" FORCE)
171 set(ZLIB_FOUND CACHE STRING "Zlib found" FORCE )
172
173 set_target_properties(zlibstatic PROPERTIES
174         FOLDER "3rd_party"
175         INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})