]> git.cworth.org Git - apitrace/blob - thirdparty/snappy/CMakeLists.txt
bcacda7514a8acf632548d73fcff59e01d78d161
[apitrace] / thirdparty / snappy / CMakeLists.txt
1 # We only do the subset of the snappy autoconf that actually affect the library
2 # (as most of them are for the tests which we don't build.)
3
4 include (CheckIncludeFileCXX)
5 include (CheckCXXSourceCompiles)
6 include (TestBigEndian)
7
8 check_include_file_cxx (sys/mman.h HAVE_SYS_MMAN_H)
9 check_include_file_cxx (sys/byteorder.h HAVE_SYS_BYTEORDER_H)
10 check_include_file_cxx (sys/endian.h HAVE_SYS_ENDIAN_H)
11 check_include_file_cxx (byteswap.h HAVE_BYTESWAP_H)
12
13 check_cxx_source_compiles (
14     "main() { return __builtin_expect(1, 1) ? 1 : 0; }"
15     HAVE_BUILTIN_EXPECT
16 )
17
18 check_cxx_source_compiles (
19     "main() { return (__builtin_ctzll(0x100000000LL) == 32) ? 1 : 0; }"
20     HAVE_BUILTIN_CTZ
21 )
22
23 test_big_endian (WORDS_BIGENDIAN)
24
25 configure_file (config.h.in config.h)
26
27 add_definitions (-DHAVE_CONFIG_H)
28
29 # Adjust warnings
30 if (CMAKE_COMPILER_IS_GNUCXX)
31     add_definitions (-Wno-unused-function)
32 endif ()
33
34
35 include_directories (${CMAKE_CURRENT_BINARY_DIR})
36
37 add_library (snappy_bundled STATIC
38     snappy.cc
39     snappy-sinksource.cc
40     snappy-stubs-internal.cc
41     snappy-c.cc
42 )
43
44 set_target_properties (snappy_bundled PROPERTIES
45     COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}"
46 )
47
48 # If we're doing an out of source build remove any config.h from the source tree.
49 if (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
50     add_custom_command (
51         TARGET snappy_bundled
52         PRE_BUILD
53         COMMAND ${CMAKE_COMMAND} -E remove -f ${CMAKE_CURRENT_SOURCE_DIR}/config.h
54     )
55 endif()