Skip to content

Commit

Permalink
add sleef prefix to cmake options. (#509)
Browse files Browse the repository at this point in the history
Add SLEEF_ prefix to SLEEF-specific and user facing cmake options.
Do not overwrite BUILD_SHARED_LIBS anymore.
Udpate docs.
  • Loading branch information
xuhancn committed Feb 7, 2024
1 parent df84fc7 commit bd7ae3a
Show file tree
Hide file tree
Showing 21 changed files with 249 additions and 250 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ env:
LLVM_VERSION: "17"
COMMON_CMAKE_FLAGS: |
-DSLEEF_SHOW_CONFIG=1
-DBUILD_GNUABI_LIBS=ON
-DBUILD_INLINE_HEADERS=ON
-DBUILD_DFT=ON
-DBUILD_QUAD=ON
-DBUILD_SCALAR_LIB=ON
-DBUILD_STATIC_TEST_BINS=ON
-DENFORCE_TESTER=ON
-DENFORCE_TESTER3=ON
-DSLEEF_BUILD_GNUABI_LIBS=ON
-DSLEEF_BUILD_INLINE_HEADERS=ON
-DSLEEF_BUILD_DFT=ON
-DSLEEF_BUILD_QUAD=ON
-DSLEEF_BUILD_SCALAR_LIB=ON
-DSLEEF_BUILD_STATIC_TEST_BINS=ON
-DSLEEF_ENFORCE_TESTER=ON
-DSLEEF_ENFORCE_TESTER3=ON
jobs:
build-native:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Build native
shell: bash -ex -o pipefail {0}
run: |
EXTRA_CMAKE_FLAGS="-DENFORCE_SSE2=ON -DENFORCE_SSE4=ON -DENFORCE_AVX=ON -DENFORCE_AVX=ON -DENFORCE_AVX2=ON -DENFORCE_AVX512F=ON -DENFORCE_FMA4=ON"
EXTRA_CMAKE_FLAGS="-DSLEEF_ENFORCE_SSE2=ON -DSLEEF_ENFORCE_SSE4=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX=ON -DSLEEF_ENFORCE_AVX2=ON -DSLEEF_ENFORCE_AVX512F=ON -DSLEEF_ENFORCE_FMA4=ON"
cmake -S . -B _build-native -GNinja \
-DCMAKE_INSTALL_PREFIX=$(pwd)/_install-native \
-DCMAKE_TOOLCHAIN_FILE=$(pwd)/toolchains/native-${{ matrix.compiler }}.cmake \
Expand Down Expand Up @@ -213,24 +213,24 @@ jobs:
run: |
EXTRA_CMAKE_FLAGS=""
if [[ ${{ matrix.arch }} = "aarch64" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_SVE=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_SVE=ON"
elif [[ ${{ matrix.arch }} = "armhf" ]]; then
# Disable inline headers, they just don't compile on armhf
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_INLINE_HEADERS=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_INLINE_HEADERS=OFF"
elif [[ ${{ matrix.arch }} = "ppc64el" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_VSX=ON -DENFORCE_VSX3=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_VSX=ON -DSLEEF_ENFORCE_VSX3=ON"
elif [[ ${{ matrix.arch }} = "s390x" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_VXE=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_VXE=ON"
# Disable VXE2 support, QEMU doesn't support some instructions generated by gcc or llvm
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DDISABLE_VXE2=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_DISABLE_VXE2=ON"
elif [[ ${{ matrix.arch }} = "riscv64" ]]; then
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DENFORCE_RVVM1=ON -DENFORCE_RVVM2=ON"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_ENFORCE_RVVM1=ON -DSLEEF_ENFORCE_RVVM2=ON"
# Disable inline headers, they just don't compile on riscv64
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_INLINE_HEADERS=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_INLINE_HEADERS=OFF"
# Disable dft, it fails with linker error to `cexp`
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_DFT=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_DFT=OFF"
# Disable quad, it's missing the `Sleef_quad` function
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DBUILD_QUAD=OFF"
EXTRA_CMAKE_FLAGS="${EXTRA_CMAKE_FLAGS} -DSLEEF_BUILD_QUAD=OFF"
fi
cmake -S . -B _build-${{ matrix.arch }} -GNinja \
Expand Down
53 changes: 26 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@

# Options

option(BUILD_SHARED_LIBS "Build shared libs" ON)
option(BUILD_STATIC_TEST_BINS "Build statically linked test executables" OFF)
option(ENABLE_LTO "Enable LTO on GCC or ThinLTO on clang" OFF)
option(BUILD_LIBM "libsleef will be built." ON)
option(BUILD_DFT "libsleefdft will be built." OFF)
option(BUILD_QUAD "libsleefquad will be built." OFF)
option(BUILD_GNUABI_LIBS "libsleefgnuabi will be built." ON)
option(BUILD_SCALAR_LIB "libsleefscalar will be built." OFF)
option(BUILD_TESTS "Tests will be built." ON)
option(BUILD_INLINE_HEADERS "Build header for inlining whole SLEEF functions" OFF)
option(SLEEF_BUILD_STATIC_TEST_BINS "Build statically linked test executables" OFF)
option(SLEEF_ENABLE_LTO "Enable LTO on GCC or ThinLTO on clang" OFF)
option(SLEEF_BUILD_LIBM "libsleef will be built." ON)
option(SLEEF_BUILD_DFT "libsleefdft will be built." OFF)
option(SLEEF_BUILD_QUAD "libsleefquad will be built." OFF)
option(SLEEF_BUILD_GNUABI_LIBS "libsleefgnuabi will be built." ON)
option(SLEEF_BUILD_SCALAR_LIB "libsleefscalar will be built." OFF)
option(SLEEF_BUILD_TESTS "Tests will be built." ON)
option(SLEEF_BUILD_INLINE_HEADERS "Build header for inlining whole SLEEF functions" OFF)

option(SLEEF_TEST_ALL_IUT "Perform tests on implementations with all vector extensions" OFF)
option(SLEEF_SHOW_CONFIG "Show SLEEF configuration status messages." ON)
option(SLEEF_SHOW_ERROR_LOG "Show cmake error log." OFF)
option(SLEEF_ASAN "Enable address sanitizing on all targets." OFF)

option(ENFORCE_TESTER "Build fails if tester is not available" OFF)
option(ENFORCE_TESTER3 "Build fails if tester3 is not built" OFF)
option(SLEEF_ENFORCE_TESTER "Build fails if tester is not available" OFF)
option(SLEEF_ENFORCE_TESTER3 "Build fails if tester3 is not built" OFF)

option(ENABLE_ALTDIV "Enable alternative division method (aarch64 only)" OFF)
option(ENABLE_ALTSQRT "Enable alternative sqrt method (aarch64 only)" OFF)
option(SLEEF_ENABLE_ALTDIV "Enable alternative division method (aarch64 only)" OFF)
option(SLEEF_ENABLE_ALTSQRT "Enable alternative sqrt method (aarch64 only)" OFF)

option(DISABLE_FFTW "Disable testing the DFT library with FFTW" OFF)
option(DISABLE_MPFR "Disable testing with the MPFR library" OFF)
option(DISABLE_SSL "Disable testing with the SSL library" OFF)
option(SLEEF_DISABLE_FFTW "Disable testing the DFT library with FFTW" OFF)
option(SLEEF_DISABLE_MPFR "Disable testing with the MPFR library" OFF)
option(SLEEF_DISABLE_SSL "Disable testing with the SSL library" OFF)

option(ENABLE_CUDA "Enable CUDA" OFF)
option(ENABLE_CXX "Enable C++" OFF)
option(SLEEF_ENABLE_CUDA "Enable CUDA" OFF)
option(SLEEF_ENABLE_CXX "Enable C++" OFF)

# Function used to generate safe command arguments for add_custom_command
function(command_arguments PROPNAME)
Expand Down Expand Up @@ -129,11 +128,11 @@ set(SLEEF_SOVERSION ${SLEEF_VERSION_MAJOR})

set(LANGLIST C)

if (ENABLE_CUDA)
if (SLEEF_ENABLE_CUDA)
set(LANGLIST ${LANGLIST} CUDA)
endif()

if (ENABLE_CXX)
if (SLEEF_ENABLE_CXX)
set(LANGLIST ${LANGLIST} CXX)
endif()

Expand All @@ -158,11 +157,11 @@ separate build directory. Note: Please remove autogenerated file \
`CMakeCache.txt` and directory `CMakeFiles` in the current directory.")
endif()

if(ENABLE_LTO AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "ENABLE_LTO and BUILD_SHARED_LIBS cannot be specified at the same time")
endif(ENABLE_LTO AND BUILD_SHARED_LIBS)
if(SLEEF_ENABLE_LTO AND BUILD_SHARED_LIBS)
message(FATAL_ERROR "SLEEF_ENABLE_LTO and BUILD_SHARED_LIBS cannot be specified at the same time")
endif(SLEEF_ENABLE_LTO AND BUILD_SHARED_LIBS)

if(ENABLE_LTO)
if(SLEEF_ENABLE_LTO)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
Expand Down Expand Up @@ -307,7 +306,7 @@ if(SLEEF_SHOW_CONFIG)
endif(CMAKE_CROSSCOMPILING)
message(STATUS "Using option `${SLEEF_C_FLAGS}` to compile libsleef")
message(STATUS "Building shared libs : " ${BUILD_SHARED_LIBS})
message(STATUS "Building static test bins: " ${BUILD_STATIC_TEST_BINS})
message(STATUS "Building static test bins: " ${SLEEF_BUILD_STATIC_TEST_BINS})
message(STATUS "MPFR : " ${LIB_MPFR})
if (MPFR_INCLUDE_DIR)
message(STATUS "MPFR header file in " ${MPFR_INCLUDE_DIR})
Expand All @@ -317,7 +316,7 @@ if(SLEEF_SHOW_CONFIG)
message(STATUS "FFTW3 : " ${LIBFFTW3})
message(STATUS "OPENSSL : " ${OPENSSL_VERSION})
message(STATUS "SDE : " ${SDE_COMMAND})
if (BUILD_INLINE_HEADERS)
if (SLEEF_BUILD_INLINE_HEADERS)
message(STATUS "SED : " ${SED_COMMAND})
endif()
message(STATUS "COMPILER_SUPPORTS_OPENMP : " ${COMPILER_SUPPORTS_OPENMP})
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt.nested
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ target_link_libraries(hellox86 sleef)

#

if (BUILD_DFT)
if (SLEEF_BUILD_DFT)
add_executable(dfttutorial tutorial.c)
set_target_properties(dfttutorial PROPERTIES C_STANDARD 99)
add_dependencies(dfttutorial sleef)
Expand Down

0 comments on commit bd7ae3a

Please sign in to comment.