2021-10-05 04:18:11 +01:00
|
|
|
cmake_minimum_required(VERSION 3.15)
|
2021-10-13 00:41:58 +01:00
|
|
|
|
2021-10-13 03:25:16 +01:00
|
|
|
# This file is part of the Aaru Data Preservation Suite.
|
|
|
|
|
# Copyright (c) 2019-2021 Natalia Portillo.
|
|
|
|
|
#
|
|
|
|
|
# This library is free software; you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
# published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This library is distributed in the hope that it will be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2021-10-13 00:41:58 +01:00
|
|
|
IF(APPLE)
|
|
|
|
|
IF("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
|
|
|
|
SET(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "Build architectures for Mac OS X" FORCE)
|
|
|
|
|
ENDIF()
|
|
|
|
|
ENDIF(APPLE)
|
|
|
|
|
|
2021-09-21 20:33:32 +01:00
|
|
|
project("Aaru.Checksums.Native" C)
|
|
|
|
|
|
2021-10-13 00:41:58 +01:00
|
|
|
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" AND "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARMV7")
|
|
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
|
|
else()
|
|
|
|
|
set(CMAKE_C_STANDARD 90)
|
|
|
|
|
endif()
|
2021-09-21 20:33:32 +01:00
|
|
|
|
2021-09-26 17:42:32 +01:00
|
|
|
message("Detected system processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
2021-10-13 00:41:58 +01:00
|
|
|
message("Detected vs platform name: ${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
|
2021-09-28 19:50:26 +01:00
|
|
|
message("Detected compiler: ${CMAKE_C_COMPILER_ID}")
|
|
|
|
|
message("Detected build type: ${CMAKE_BUILD_TYPE}")
|
2021-09-26 17:42:32 +01:00
|
|
|
|
2021-09-28 19:50:26 +01:00
|
|
|
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
|
|
|
|
|
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
|
|
|
|
add_compile_options("/O2" "/fp:fast")
|
2021-10-13 02:53:47 +01:00
|
|
|
if(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "X86" OR ${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "x64")
|
2021-09-28 19:50:26 +01:00
|
|
|
add_compile_options("/arch:SSE2")
|
|
|
|
|
endif()
|
|
|
|
|
else()
|
2021-10-05 04:18:11 +01:00
|
|
|
add_compile_options(-ffast-math -O3)
|
2021-09-28 19:50:26 +01:00
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
2021-10-05 04:18:11 +01:00
|
|
|
add_compile_options(-march=core2 -mfpmath=sse -msse3 -mtune=westmere -flto)
|
2021-09-29 01:27:02 +01:00
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
2021-10-05 04:18:11 +01:00
|
|
|
add_compile_options(-march=armv8-a -flto)
|
|
|
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l")
|
|
|
|
|
add_compile_options(-march=armv7)
|
2021-09-28 19:50:26 +01:00
|
|
|
endif()
|
|
|
|
|
endif()
|
2021-09-26 17:42:32 +01:00
|
|
|
endif()
|
2021-09-22 17:04:40 +01:00
|
|
|
|
2021-10-13 03:50:10 +01:00
|
|
|
add_library("Aaru.Checksums.Native" SHARED adler32.h adler32.c crc16.h crc16.c crc16_ccitt.h crc16_ccitt.c crc32.c crc32.h crc64.c crc64.h fletcher16.h fletcher16.c fletcher32.h fletcher32.c library.h spamsum.c spamsum.h crc32_clmul.c crc64_clmul.c simd.c simd.h adler32_ssse3.c adler32_avx2.c adler32_neon.c crc32_arm_simd.c crc32_vmull.c crc32_simd.h arm_vmull.c arm_vmull.h crc64_vmull.c library.c)
|
2021-10-05 01:58:31 +01:00
|
|
|
|
2021-10-13 00:41:58 +01:00
|
|
|
add_subdirectory(tests)
|