Files
Aaru.Compression.Native/CMakeLists.txt
2021-10-14 04:39:10 +01:00

77 lines
2.9 KiB
CMake

cmake_minimum_required(VERSION 3.15)
# 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/>.
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)
project("Aaru.Compression.Native" C)
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()
message("Detected system processor: ${CMAKE_SYSTEM_PROCESSOR}")
message("Detected vs platform name: ${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
message("Detected compiler: ${CMAKE_C_COMPILER_ID}")
message("Detected build type: ${CMAKE_BUILD_TYPE}")
message("Detected platform: ${CMAKE_C_PLATFORM_ID}")
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
add_compile_options("/O2" "/fp:fast")
if(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "X86" OR ${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "x64")
add_compile_options("/arch:SSE2")
endif()
else()
add_compile_options(-ffast-math -O3)
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
add_compile_options(-march=core2 -mtune=westmere -mfpmath=sse)
endif()
add_compile_options(-msse3)
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
add_compile_options(-flto)
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
add_compile_options(-march=armv8-a)
endif()
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
add_compile_options(-flto)
endif()
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l")
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
add_compile_options(-march=armv7)
endif()
endif()
endif()
endif()
add_library("Aaru.Compression.Native" SHARED library.c apple_rle.c apple_rle.h)
add_subdirectory(tests)