Internal changes

PiperOrigin-RevId: 621907514
This commit is contained in:
Richard O'Grady
2024-04-04 17:48:40 +00:00
committed by Danila Kutenin
parent 0212163f6e
commit e1e7329dc7
18 changed files with 83 additions and 391 deletions

View File

@@ -26,8 +26,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.10)
project(Snappy VERSION 1.2.2 LANGUAGES C CXX)
cmake_minimum_required(VERSION 3.1)
project(Snappy VERSION 1.1.10 LANGUAGES C CXX)
# C++ standard can be overridden when this is used as a sub-project.
if(NOT CMAKE_CXX_STANDARD)
@@ -38,7 +38,7 @@ if(NOT CMAKE_CXX_STANDARD)
endif(NOT CMAKE_CXX_STANDARD)
# https://github.com/izenecloud/cmake/blob/master/SetCompilerWarningAll.cmake
if(MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use the highest warning level for Visual Studio.
set(CMAKE_CXX_WARNING_LEVEL 4)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
@@ -55,7 +55,7 @@ if(MSVC)
# Disable RTTI.
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
else(MSVC)
else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# Use -Wall for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
@@ -85,7 +85,7 @@ else(MSVC)
# Disable RTTI.
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
endif(MSVC)
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
# it prominent in the GUI.
@@ -155,20 +155,10 @@ int main() {
return __builtin_expect(0, 1);
}" HAVE_BUILTIN_EXPECT)
# Check if the built-in __builtin_ctz (count trailing zeros) is available.
# Require either a non-RISC-V target, or a RISC-V core that implements
# the Zbb bit-manipulation extension where ctz is guaranteed.
check_cxx_source_compiles("
#ifdef __riscv
#ifdef __riscv_zbb
int main() { return __builtin_ctzll(0); }
#else
#error \"ZBB not enabled in current config\"
#endif
#else
int main() { return __builtin_ctzll(0); }
#endif
" HAVE_BUILTIN_CTZ)
int main() {
return __builtin_ctzll(0);
}" HAVE_BUILTIN_CTZ)
check_cxx_source_compiles("
int main() {
@@ -216,41 +206,13 @@ int main() {
check_cxx_source_compiles("
#include <arm_neon.h>
#include <stdint.h>
int main() {
uint8_t val = 3, dup[8];
uint8x16_t v1 = vld1q_dup_u8(&val);
uint8x16_t v2 = vqtbl1q_u8(v1, v1);
vst1q_u8(dup, v1);
vst1q_u8(dup, v2);
uint8x16_t v = vld1q_dup_u8(&val);
vst1q_u8(dup, v);
return 0;
}" SNAPPY_HAVE_NEON)
#check RVV 1.0 need __riscv_ prefix
check_cxx_source_compiles("
#include <riscv_vector.h>
#include <stdint.h>
#include <stddef.h>
int main() {
uint8_t val = 3, dup[8];
size_t vl = __riscv_vsetvl_e8m1(8);
vuint8m1_t v = __riscv_vmv_v_x_u8m1(val, vl);
return 0;
}" SNAPPY_RVV_1)
#check RVV 0.7.1 not __riscv_ prefix
check_cxx_source_compiles("
#include <riscv_vector.h>
#include <stdint.h>
#include <stddef.h>
int main() {
uint8_t val = 3, dup[8];
size_t vl = vsetvl_e8m1(8);
vuint8m1_t v = vmv_v_x_u8m1(val, vl);
return 0;
}" SNAPPY_RVV_0_7)
include(CheckSymbolExists)
check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
@@ -296,7 +258,9 @@ target_sources(snappy
"snappy-stubs-internal.cc"
"snappy.cc"
"${PROJECT_BINARY_DIR}/config.h"
PUBLIC
# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
$<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
$<INSTALL_INTERFACE:include/snappy-c.h>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
@@ -333,9 +297,6 @@ if(SNAPPY_BUILD_TESTS OR SNAPPY_BUILD_BENCHMARKS)
# Test files include snappy-test.h, HAVE_CONFIG_H must be defined.
target_compile_definitions(snappy_test_support PUBLIC -DHAVE_CONFIG_H)
if(BUILD_SHARED_LIBS)
set_target_properties(snappy_test_support PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(BUILD_SHARED_LIBS)
target_link_libraries(snappy_test_support snappy)