rsimd

Make SIMD instruction sets easier to use
git clone git://git.meso-star.fr/rsimd.git
Log | Files | Refs | README | LICENSE

commit 77f3276967897bd8e37befd299a225f1a186ee4e
parent dc44f07f5fca4178b6a4dd52cb81f06391660402
Author: vaplv <vaplv@free.fr>
Date:   Thu, 29 Apr 2021 15:21:12 +0200

Update the CMake config file

Diffstat:
Mcmake/CMakeLists.txt | 18+++++++++++++++---
Dcmake/RSIMDConfig.cmake | 121-------------------------------------------------------------------------------
Acmake/RSIMDConfig.cmake.in | 127+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 124 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -37,8 +37,13 @@ include(rcmake) ################################################################################ # Check compiler features ################################################################################ + if(CMAKE_COMPILER_IS_GNUCC) include(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG("-msse2" SSE2) + if(NOT SSE2) + message(FATAL_ERROR "The SSE2 instruction set must be supported.") + endif() CHECK_C_COMPILER_FLAG("-msse4.1" SSE4_1) CHECK_C_COMPILER_FLAG("-mavx" AVX) CHECK_C_COMPILER_FLAG("-mfma" FMA) @@ -52,11 +57,18 @@ set(VERSION_MINOR 3) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) +set(RSIMD_SSE2 ${SSE2}) +set(RSIMD_SSE4_1 ${SSE4_1}) +set(RSIMD_AVX ${AVX}) +set(RSIMD_FMA ${FMA}) + # Configure the files generic to the RSIMD version configure_file(${RSIMD_SOURCE_DIR}/rsimd_version.h.in ${CMAKE_CURRENT_BINARY_DIR}/rsimd_version.h @ONLY) configure_file(${PROJECT_SOURCE_DIR}/RSIMDConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/RSIMDConfigVersion.cmake @ONLY) +configure_file(${PROJECT_SOURCE_DIR}/RSIMDConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/RSIMDConfig.cmake @ONLY) set(RSIMD_FILES_INC_LEGACY aosf33.h @@ -178,8 +190,8 @@ install(FILES ${RSIMD_FILES_INC_AVX} DESTINATION include/rsimd/avx) install(FILES ${RSIMD_FILES_DOC} DESTINATION share/doc/rsimd) install(FILES ${Sleef_DIR}/SleefConfig.cmake DESTINATION lib/cmake/Sleef/) -install(FILES ${PROJECT_SOURCE_DIR}/RSIMDConfig.cmake - DESTINATION lib/cmake/RSIMD) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/RSIMDConfigVersion.cmake +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/RSIMDConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/RSIMDConfigVersion.cmake DESTINATION lib/cmake/RSIMD) diff --git a/cmake/RSIMDConfig.cmake b/cmake/RSIMDConfig.cmake @@ -1,121 +0,0 @@ -# Copyright (C) 2013-2017 Vincent Forest (vaplv@free.fr) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program 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 General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -cmake_minimum_required(VERSION 3.1) - -# Check dependenc -find_package(Sleef REQUIRED) - -# Check compiler features -if(CMAKE_COMPILER_IS_GNUCC) - include(CheckCCompilerFlag) - CHECK_C_COMPILER_FLAG("-msse2" SSE2) - CHECK_C_COMPILER_FLAG("-msse4.1" SSE4_1) - CHECK_C_COMPILER_FLAG("-mavx" AVX) - CHECK_C_COMPILER_FLAG("-mfma" FMA) - - if(SSE2) - list(APPEND _compile_flags -msse2) - endif() - if(SSE4_1) - list(APPEND _compile_flags -msse4.1) - endif() - if(AVX) - list(APPEND _compile_flags -mavx) - endif() - if(FMA) - list(APPEND _compile_flags -mfma) - endif() -endif() - -# Try to find the RSIMD devel. Once done this will define: -# - RSIMD_FOUND: system has RSIMD -# - RSIMD_INCLUDE_DIR: the include directory -# - RSIMD Target: Link this to use rsimd - -# Look for library header -find_path(RSIMD_INCLUDE_DIR rsimd/rsimd_version.h) - -# Look for Release, Debug, RelWithDebInfo and MinSizeRel libraries -unset(RSIMD_LIBRARY CACHE) -unset(RSIMD_LIBRARY_RELEASE CACHE) -unset(RSIMD_LIBRARY_DEBUG CACHE) -unset(RSIMD_LIBRARY_RELWITHDEBINFO CACHE) -unset(RSIMD_LIBRARY_MINSIZEREL CACHE) - -# Find per configuration type libraries -find_library(RSIMD_LIBRARY_RELEASE - rsimd - PATH_SUFFIXES bin Bin BIN - DOC "Path to the library rsimd used during release builds.") -find_library(RSIMD_LIBRARY_DEBUG - rsimd-dbg - PATH_SUFFIXES bin Bin BIN - DOC "Path to the library rsimd used during debug builds.") -find_library(RSIMD_LIBRARY_RELWITHDEBINFO - rsimd-rdbg - PATH_SUFFIXES bin Bin BIN - DOC "Path to the library rsimd used during release with debug info builds.") -find_library(RSIMD_LIBRARY_MINSIZEREL - rsimd-mszr - PATH_SUFFIXES bin Bin BIN - DOC "Path to the library rsimd used during minsize builds.") - -# Define the generic rsimd library -if(RSIMD_LIBRARY_RELEASE) - set(RSIMD_LIBRARY ${RSIMD_LIBRARY_RELEASE}) -elseif(RSIMD_LIBRARY_RELWITHDEBINFO) - set(RSIMD_LIBRARY ${RSIMD_LIBRARY_RELWITHDEBINFO}) -elseif(RSIMD_LIBRARY_MINSIZEREL) - set(RSIMD_LIBRARY ${RSIMD_LIBRARY_MINSIZEREL}) -elseif(RSIMD_LIBRARY_DEBUG) - set(RSIMD_LIBRARY ${RSIMD_LIBRARY_DEBUG}) -endif() - -# Define the per configuration library fallback when not found -set(_configs RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) -foreach(_cfg ${_configs}) - if(NOT RSIMD_LIBRARY_${_cfg}) - get_property(_doc CACHE RSIMD_LIBRARY_${_cfg} PROPERTY HELPSTRING) - set(RSIMD_LIBRARY_${_cfg} - ${RSIMD_LIBRARY} CACHE PATH ${_doc} FORCE) - endif() -endforeach() - -# Create the imported library target -add_library(RSIMD SHARED IMPORTED) - -# Setup the properties of the imported target -if(CMAKE_HOST_WIN32) - set(_import_prop IMPORTED_IMPLIB) -else() - set(_import_prop IMPORTED_LOCATION) -endif() -set_target_properties(RSIMD PROPERTIES - ${_import_prop} ${RSIMD_LIBRARY} - ${_import_prop}_RELEASE ${RSIMD_LIBRARY_RELEASE} - ${_import_prop}_DEBUG ${RSIMD_LIBRARY_DEBUG} - ${_import_prop}_RELWITHDEBINFO ${RSIMD_LIBRARY_RELWITHDEBINFO} - ${_import_prop}_MINSIZEREL ${RSIMD_LIBRARY_MINSIZEREL} - INTERFACE_INCLUDE_DIRECTORIES ${RSIMD_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES Sleef - INTERFACE_COMPILE_OPTIONS "${_compile_flags}") - -# Check the package -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(RSIMD DEFAULT_MSG - RSIMD_INCLUDE_DIR - RSIMD_LIBRARY) - diff --git a/cmake/RSIMDConfig.cmake.in b/cmake/RSIMDConfig.cmake.in @@ -0,0 +1,127 @@ +# Copyright (C) 2013-2021 Vincent Forest (vaplv@free.fr) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +cmake_minimum_required(VERSION 3.1) + +# Check dependenc +find_package(Sleef REQUIRED) + +set(RSIMD_SSE2 @RSIMD_SSE2@) +set(RSIMD_SSE4_1 @RSIMD_SSE4_1@) +set(RSIMD_AVX @RSIMD_AVX@) +set(RSIMD_FMA @RSIMD_FMA@) + +# Check compiler features +if(CMAKE_COMPILER_IS_GNUCC) + include(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG("-msse2" SSE2) + CHECK_C_COMPILER_FLAG("-msse4.1" SSE4_1) + CHECK_C_COMPILER_FLAG("-mavx" AVX) + CHECK_C_COMPILER_FLAG("-mfma" FMA) + + if(SSE2 AND RSIMD_SSE2) + list(APPEND _compile_flags -msse2) + endif() + if(SSE4_1 AND RSIMD_SSE4_1) + list(APPEND _compile_flags -msse4.1) + endif() + if(AVX AND RSIMD_AVX) + list(APPEND _compile_flags -mavx) + endif() + if(FMA AND RSIMD_FMA) + set(RSIMD_FMA ON) + list(APPEND _compile_flags -mfma) + endif() +endif() + +# Try to find the RSIMD devel. Once done this will define: +# - RSIMD_FOUND: system has RSIMD +# - RSIMD_INCLUDE_DIR: the include directory +# - RSIMD Target: Link this to use rsimd + +# Look for library header +find_path(RSIMD_INCLUDE_DIR rsimd/rsimd_version.h) + +# Look for Release, Debug, RelWithDebInfo and MinSizeRel libraries +unset(RSIMD_LIBRARY CACHE) +unset(RSIMD_LIBRARY_RELEASE CACHE) +unset(RSIMD_LIBRARY_DEBUG CACHE) +unset(RSIMD_LIBRARY_RELWITHDEBINFO CACHE) +unset(RSIMD_LIBRARY_MINSIZEREL CACHE) + +# Find per configuration type libraries +find_library(RSIMD_LIBRARY_RELEASE + rsimd + PATH_SUFFIXES bin Bin BIN + DOC "Path to the library rsimd used during release builds.") +find_library(RSIMD_LIBRARY_DEBUG + rsimd-dbg + PATH_SUFFIXES bin Bin BIN + DOC "Path to the library rsimd used during debug builds.") +find_library(RSIMD_LIBRARY_RELWITHDEBINFO + rsimd-rdbg + PATH_SUFFIXES bin Bin BIN + DOC "Path to the library rsimd used during release with debug info builds.") +find_library(RSIMD_LIBRARY_MINSIZEREL + rsimd-mszr + PATH_SUFFIXES bin Bin BIN + DOC "Path to the library rsimd used during minsize builds.") + +# Define the generic rsimd library +if(RSIMD_LIBRARY_RELEASE) + set(RSIMD_LIBRARY ${RSIMD_LIBRARY_RELEASE}) +elseif(RSIMD_LIBRARY_RELWITHDEBINFO) + set(RSIMD_LIBRARY ${RSIMD_LIBRARY_RELWITHDEBINFO}) +elseif(RSIMD_LIBRARY_MINSIZEREL) + set(RSIMD_LIBRARY ${RSIMD_LIBRARY_MINSIZEREL}) +elseif(RSIMD_LIBRARY_DEBUG) + set(RSIMD_LIBRARY ${RSIMD_LIBRARY_DEBUG}) +endif() + +# Define the per configuration library fallback when not found +set(_configs RELEASE DEBUG RELWITHDEBINFO MINSIZEREL) +foreach(_cfg ${_configs}) + if(NOT RSIMD_LIBRARY_${_cfg}) + get_property(_doc CACHE RSIMD_LIBRARY_${_cfg} PROPERTY HELPSTRING) + set(RSIMD_LIBRARY_${_cfg} + ${RSIMD_LIBRARY} CACHE PATH ${_doc} FORCE) + endif() +endforeach() + +# Create the imported library target +add_library(RSIMD SHARED IMPORTED) + +# Setup the properties of the imported target +if(CMAKE_HOST_WIN32) + set(_import_prop IMPORTED_IMPLIB) +else() + set(_import_prop IMPORTED_LOCATION) +endif() +set_target_properties(RSIMD PROPERTIES + ${_import_prop} ${RSIMD_LIBRARY} + ${_import_prop}_RELEASE ${RSIMD_LIBRARY_RELEASE} + ${_import_prop}_DEBUG ${RSIMD_LIBRARY_DEBUG} + ${_import_prop}_RELWITHDEBINFO ${RSIMD_LIBRARY_RELWITHDEBINFO} + ${_import_prop}_MINSIZEREL ${RSIMD_LIBRARY_MINSIZEREL} + INTERFACE_INCLUDE_DIRECTORIES ${RSIMD_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES Sleef + INTERFACE_COMPILE_OPTIONS "${_compile_flags}") + +# Check the package +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(RSIMD DEFAULT_MSG + RSIMD_INCLUDE_DIR + RSIMD_LIBRARY) +