1 cmake_minimum_required(VERSION 3.1)
3 set(LYX_IPO_SUPPORTED FALSE)
5 cmake_policy(SET CMP0069 NEW)
6 if (LYX_USE_IPO MATCHES "ON")
7 set(LYX_IPO_SUPPORTED YES)
11 cmake_policy(SET CMP0075 NEW)
14 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
19 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/1.2.11)
21 option(ASM686 "Enable building i686 assembly implementation")
22 option(AMD64 "Enable building amd64 assembly implementation")
24 include(CheckTypeSize)
25 include(CheckFunctionExists)
26 include(CheckIncludeFile)
27 include(CheckCSourceCompiles)
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)
35 # Check to see if we have large file support
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.
42 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
45 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
48 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
50 check_type_size(off64_t OFF64_T)
52 add_definitions(-D_LARGEFILE64_SOURCE=1)
54 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
59 check_function_exists(fseeko HAVE_FSEEKO)
61 add_definitions(-DNO_FSEEKO)
67 check_include_file(unistd.h Z_HAVE_UNISTD_H)
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})
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)
88 #set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
89 #configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
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})
95 #============================================================================
97 #============================================================================
100 ${CMAKE_BINARY_DIR}/zconf.h
103 set(ZLIB_PRIVATE_HDRS
133 if(CMAKE_COMPILER_IS_GNUCC)
135 set(ZLIB_ASMS contrib/asm686/match.S)
137 set(ZLIB_ASMS contrib/amd64/amd64-match.S)
141 add_definitions(-DASMV)
142 set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
148 ENABLE_LANGUAGE(ASM_MASM)
150 contrib/masmx86/inffas32.asm
151 contrib/masmx86/match686.asm
154 ENABLE_LANGUAGE(ASM_MASM)
156 contrib/masmx64/gvmat64.asm
157 contrib/masmx64/inffasx64.asm
162 add_definitions(-DASMV -DASMINF)
166 add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
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 )
173 set_target_properties(zlibstatic PROPERTIES
175 INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})