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 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
16 set(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/1.2.11)
18 option(ASM686 "Enable building i686 assembly implementation")
19 option(AMD64 "Enable building amd64 assembly implementation")
21 include(CheckTypeSize)
22 include(CheckFunctionExists)
23 include(CheckIncludeFile)
24 include(CheckCSourceCompiles)
27 check_include_file(sys/types.h HAVE_SYS_TYPES_H)
28 check_include_file(stdint.h HAVE_STDINT_H)
29 check_include_file(stddef.h HAVE_STDDEF_H)
32 # Check to see if we have large file support
34 set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
35 # We add these other definitions here because CheckTypeSize.cmake
36 # in CMake 2.4.x does not automatically do so and we want
37 # compatibility with CMake 2.4.x.
39 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
42 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
45 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
47 check_type_size(off64_t OFF64_T)
49 add_definitions(-D_LARGEFILE64_SOURCE=1)
51 set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
56 check_function_exists(fseeko HAVE_FSEEKO)
58 add_definitions(-DNO_FSEEKO)
64 check_include_file(unistd.h Z_HAVE_UNISTD_H)
67 set(CMAKE_DEBUG_POSTFIX "d")
68 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
69 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
70 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
73 if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
74 # If we're doing an out of source build and the user has a zconf.h
75 # in their source tree...
76 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
77 message(STATUS "Renaming")
78 message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
79 message(STATUS "to 'zconf.h.included' because this file is included with zlib")
80 message(STATUS "but CMake generates it automatically in the build directory.")
81 file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
85 #set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
86 #configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
88 configure_file(${SRCDIR}/zconf.h.cmakein ${CMAKE_BINARY_DIR}/zconf.h @ONLY)
89 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
92 #============================================================================
94 #============================================================================
97 ${CMAKE_BINARY_DIR}/zconf.h
100 set(ZLIB_PRIVATE_HDRS
130 if(CMAKE_COMPILER_IS_GNUCC)
132 set(ZLIB_ASMS contrib/asm686/match.S)
134 set(ZLIB_ASMS contrib/amd64/amd64-match.S)
138 add_definitions(-DASMV)
139 set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
145 ENABLE_LANGUAGE(ASM_MASM)
147 contrib/masmx86/inffas32.asm
148 contrib/masmx86/match686.asm
151 ENABLE_LANGUAGE(ASM_MASM)
153 contrib/masmx64/gvmat64.asm
154 contrib/masmx64/inffasx64.asm
159 add_definitions(-DASMV -DASMINF)
163 add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
166 set(ZLIB_LIBRARY zlibstatic CACHE STRING "Zlib library" FORCE)
167 set(ZLIB_INCLUDE_DIR ${SRCDIR} CACHE STRING "Zlib include dir" FORCE)
168 set(ZLIB_FOUND CACHE STRING "Zlib found" FORCE )
170 set_target_properties(zlibstatic PROPERTIES
172 INTERPROCEDURAL_OPTIMIZATION ${LYX_IPO_SUPPORTED})