source: lzo/vendor/current/cmakelists.txt@ 1076

Last change on this file since 1076 was 1076, checked in by Silvan Scherrer, 10 years ago

liblzo: update to vendor version 2.09

File size: 7.3 KB
Line 
1#
2# CMakeLists.txt --- a simple "CMake" file for building LZO
3#
4# This file is part of the LZO data compression library.
5#
6# Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer
7# All Rights Reserved.
8#
9
10#
11# simple usage:
12# mkdir -p build && cd build && cmake .. && make
13#
14# another usage example:
15# mkdir -p build/release-i686
16# cd build/release-i686
17# cmake ../.. -DENABLE_STATIC=0 -DENABLE_SHARED=1 \
18# -DCMAKE_C_COMPILER=gcc -DCMAKE_C_FLAGS="-m32 -march=i686" \
19# -DCMAKE_INSTALL_PREFIX=/opt/local/prefix-i686
20# make VERBOSE=1
21# make install
22#
23# see http://www.cmake.org/ for more info
24#
25
26#
27# init
28#
29
30cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
31
32# Disallow in-source builds. Note that you will still have to manually
33# clean up a few files if you accidentally try an in-source build.
34set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
35set(CMAKE_DISABLE_SOURCE_CHANGES ON)
36if(",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_BINARY_DIR},")
37 message(FATAL_ERROR "ERROR: In-source builds are not allowed.")
38endif()
39
40project(lzo C)
41
42#
43# configuration options
44#
45
46option(ENABLE_STATIC "Build static LZO library." ON)
47option(ENABLE_SHARED "Build shared LZO library." OFF)
48
49if(NOT CMAKE_BUILD_TYPE)
50 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
51endif()
52if(NOT CMAKE_INSTALL_PREFIX)
53 set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "" FORCE)
54endif()
55
56#
57# targets
58#
59
60file(GLOB lzo_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
61list(SORT lzo_SOURCES)
62
63# LZO library
64if(NOT ENABLE_STATIC AND NOT ENABLE_SHARED)
65 set(ENABLE_STATIC ON)
66endif()
67if(ENABLE_STATIC)
68 add_library(lzo_static STATIC ${lzo_SOURCES})
69 set_target_properties(lzo_static PROPERTIES OUTPUT_NAME lzo2)
70endif()
71if(ENABLE_SHARED)
72 add_library(lzo_shared SHARED ${lzo_SOURCES})
73 set_target_properties(lzo_shared PROPERTIES OUTPUT_NAME lzo2)
74 set_target_properties(lzo_shared PROPERTIES SOVERSION 2 VERSION 2.0.0)
75endif()
76
77# tests & examples
78macro(lzo_add_executable t)
79 add_executable(${t} ${ARGN})
80 if(ENABLE_STATIC)
81 target_link_libraries(${t} lzo_static)
82 else()
83 target_link_libraries(${t} lzo_shared)
84 endif()
85endmacro()
86# main test driver
87lzo_add_executable(lzotest lzotest/lzotest.c)
88# examples
89lzo_add_executable(dict examples/dict.c)
90lzo_add_executable(lzopack examples/lzopack.c)
91lzo_add_executable(overlap examples/overlap.c)
92lzo_add_executable(precomp examples/precomp.c)
93lzo_add_executable(precomp2 examples/precomp2.c)
94lzo_add_executable(simple examples/simple.c)
95# some boring internal test programs
96if(0)
97 lzo_add_executable(align tests/align.c)
98 lzo_add_executable(chksum tests/chksum.c)
99 lzo_add_executable(promote tests/promote.c)
100 lzo_add_executable(sizes tests/sizes.c)
101endif()
102
103# miniLZO
104if(1)
105 add_executable(testmini minilzo/testmini.c minilzo/minilzo.c)
106 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/lzo) # needed for "lzoconf.h"
107endif()
108
109#
110# compilation flags
111#
112
113include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
114include_directories(${CMAKE_CURRENT_SOURCE_DIR})
115
116include(CheckFunctionExists)
117include(CheckIncludeFile)
118include(CheckLibraryExists)
119include(CheckSymbolExists)
120include(CheckTypeSize)
121include(TestBigEndian)
122
123# Checks for header files
124macro(mfx_check_include_file f var)
125 check_include_file("${f}" "mfx_${var}")
126 if(NOT ",${mfx_${var}}," STREQUAL ",,")
127 add_definitions(-D${var}=1)
128 set(mfx_${var} 1)
129 else()
130 set(mfx_${var} 0)
131 endif()
132endmacro()
133# mfx_ACC_CHECK_HEADERS
134set(l assert.h ctype.h dirent.h errno.h fcntl.h float.h limits.h malloc.h memory.h setjmp.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h strings.h time.h unistd.h utime.h sys/mman.h sys/resource.h sys/stat.h sys/time.h sys/types.h sys/wait.h)
135foreach(f ${l})
136 string(TOUPPER "${f}" var)
137 string(REGEX REPLACE "[^0-9A-Z_]" "_" var "${var}")
138 mfx_check_include_file("${f}" "HAVE_${var}")
139endforeach()
140
141# Checks for typedefs and structures
142macro(mfx_check_type_size type var)
143 check_type_size("${type}" "mfx_${var}")
144 if("${mfx_${var}}" MATCHES "^[1-9][0-9]*$")
145 add_definitions(-D${var}=${mfx_${var}})
146 else()
147 set(mfx_${var} 0)
148 endif()
149endmacro()
150# mfx_ACC_CHECK_SIZEOF + mfx_CHECK_SIZEOF
151set(l short int long "long long" __int16 __int32 __int64 "void *" size_t ptrdiff_t intmax_t uintmax_t intptr_t uintptr_t float double "long double" dev_t fpos_t mode_t off_t ssize_t time_t)
152foreach(f ${l})
153 string(TOUPPER "${f}" var)
154 string(REGEX REPLACE " \\*" "_P" var "${var}")
155 string(REGEX REPLACE "[^0-9A-Z_]" "_" var "${var}")
156 mfx_check_type_size("${f}" "SIZEOF_${var}")
157endforeach()
158
159# Checks for library functions
160macro(mfx_check_function_exists func var)
161 check_function_exists("${func}" "mfx_${var}")
162 if(NOT ",${mfx_${var}}," STREQUAL ",,")
163 add_definitions(-D${var}=1)
164 set(mfx_${var} 1)
165 else()
166 set(mfx_${var} 0)
167 endif()
168endmacro()
169# mfx_ACC_CHECK_FUNCS
170set(l access alloca atexit atoi atol chmod chown clock_getcpuclockid clock_getres clock_gettime ctime difftime fstat getenv getpagesize getrusage gettimeofday gmtime isatty localtime longjmp lstat memcmp memcpy memmove memset mkdir mktime mmap mprotect munmap qsort raise rmdir setjmp signal snprintf strcasecmp strchr strdup strerror strftime stricmp strncasecmp strnicmp strrchr strstr time umask utime vsnprintf)
171foreach(f ${l})
172 string(TOUPPER "${f}" var)
173 string(REGEX REPLACE "[^0-9A-Z_]" "_" var "${var}")
174 mfx_check_function_exists("${f}" "HAVE_${var}")
175endforeach()
176
177# mfx_LZO_CHECK_ENDIAN
178TEST_BIG_ENDIAN(big_endian)
179if ("${big_endian}" MATCHES "^1$")
180 add_definitions(-DLZO_ABI_BIG_ENDIAN=1)
181elseif ("${big_endian}" MATCHES "^0$")
182 add_definitions(-DLZO_ABI_LITTLE_ENDIAN=1)
183else()
184 message(FATAL_ERROR "ERROR: TEST_BIG_ENDIAN failed with result '${big_endian}'.")
185endif()
186
187# LZO_HAVE_CONFIG_H
188add_definitions(-DLZO_CFG_NO_CONFIG_HEADER=1)
189
190#
191# "make install"
192#
193
194# these subdirs are relative to CMAKE_INSTALL_PREFIX
195if(NOT DEFINED install_doc_subdir)
196 set(install_doc_subdir "share/doc/lzo")
197endif()
198if(NOT DEFINED install_include_subdir)
199 set(install_include_subdir "include/lzo")
200endif()
201if(NOT DEFINED install_lib_subdir)
202 set(install_lib_subdir "lib")
203endif()
204if(NOT DEFINED install_examples_subdir)
205 set(install_examples_subdir "libexec/lzo/examples")
206endif()
207
208set(doc_DATA AUTHORS COPYING NEWS THANKS doc/LZO.FAQ doc/LZO.TXT doc/LZOAPI.TXT)
209set(pkginclude_HEADERS
210 include/lzo/lzo1.h include/lzo/lzo1a.h include/lzo/lzo1b.h
211 include/lzo/lzo1c.h include/lzo/lzo1f.h include/lzo/lzo1x.h
212 include/lzo/lzo1y.h include/lzo/lzo1z.h include/lzo/lzo2a.h
213 include/lzo/lzo_asm.h include/lzo/lzoconf.h include/lzo/lzodefs.h
214 include/lzo/lzoutil.h
215)
216
217install(FILES ${doc_DATA} DESTINATION "${install_doc_subdir}")
218install(FILES ${pkginclude_HEADERS} DESTINATION "${install_include_subdir}")
219if(ENABLE_STATIC)
220 install(TARGETS lzo_static DESTINATION "${install_lib_subdir}")
221endif()
222if(ENABLE_SHARED)
223 install(TARGETS lzo_shared DESTINATION "${install_lib_subdir}")
224endif()
225if(0)
226 set(lzo_EXAMPLES lzopack lzotest simple)
227 if(NOT ENABLE_STATIC)
228 set(d "${CMAKE_INSTALL_PREFIX}/${install_lib_subdir}")
229 set_target_properties(${lzo_EXAMPLES} PROPERTIES INSTALL_RPATH "${d}")
230 endif()
231 install(TARGETS ${lzo_EXAMPLES} DESTINATION "${install_examples_subdir}")
232endif()
233
234# vim:set ft=cmake ts=4 sw=4 tw=0 et:
Note: See TracBrowser for help on using the repository browser.