Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SLEEF_BUILD_SHARED_LIBS to override BUILD_SHARED_LIBS from including projects #531

Merged
merged 4 commits into from Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 26 additions & 23 deletions CMakeLists.txt
@@ -1,3 +1,7 @@
cmake_minimum_required(VERSION 3.18)
project(SLEEF VERSION 3.6.0 LANGUAGES C)

set(SLEEF_SOVERSION ${SLEEF_VERSION_MAJOR})

# Options

Expand Down Expand Up @@ -29,6 +33,22 @@ option(SLEEF_DISABLE_SSL "Disable testing with the SSL library" OFF)
option(SLEEF_ENABLE_CUDA "Enable CUDA" OFF)
option(SLEEF_ENABLE_CXX "Enable C++" OFF)

#

if (DEFINED SLEEF_BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ${SLEEF_BUILD_SHARED_LIBS})
endif ()

if (SLEEF_SHOW_CONFIG)
# Normalize the value of BUILD_SHARED_LIBS so that it displays nicely
# in the configuration display
if (BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS YES)
else ()
set(BUILD_SHARED_LIBS NO)
alexreinking marked this conversation as resolved.
Show resolved Hide resolved
endif ()
endif ()

# Function used to generate safe command arguments for add_custom_command
function(command_arguments PROPNAME)
set(quoted_args "")
Expand Down Expand Up @@ -63,7 +83,7 @@ set(SLEEF_ALL_SUPPORTED_EXTENSIONS
SVENOFMA SVE ADVSIMDNOFMA ADVSIMD # Aarch64
NEON32 NEON32VFPV4 # Aarch32
VSX VSXNOFMA VSX3 VSX3NOFMA # PPC64
VXE VXENOFMA VXE2 VXE2NOFMA # IBM Z
VXE VXENOFMA VXE2 VXE2NOFMA # IBM Z
RVVM1NOFMA RVVM1 RVVM2NOFMA RVVM2 # RISC-V Vectors
PUREC_SCALAR PURECFMA_SCALAR # Generic type
CACHE STRING "List of SIMD architectures supported by libsleef."
Expand All @@ -74,7 +94,7 @@ set(SLEEF_SUPPORTED_LIBM_EXTENSIONS
SVENOFMA SVE ADVSIMDNOFMA ADVSIMD # Aarch64
NEON32 NEON32VFPV4 # Aarch32
VSX VSXNOFMA VSX3 VSX3NOFMA # PPC64
VXE VXENOFMA VXE2 VXE2NOFMA # IBM Z
VXE VXENOFMA VXE2 VXE2NOFMA # IBM Z
RVVM1NOFMA RVVM1 RVVM2NOFMA RVVM2 # RISC-V Vectors
PUREC_SCALAR PURECFMA_SCALAR # Generic type
CACHE STRING "List of SIMD architectures supported by libsleef."
Expand Down Expand Up @@ -112,31 +132,15 @@ set(COSTOVERRIDE_RVVM2NOFMA 20)

#

cmake_minimum_required(VERSION 3.18)

if(${CMAKE_VERSION} VERSION_GREATER "3.14.99")
cmake_policy(SET CMP0091 NEW)
endif()

enable_testing()

set(SLEEF_VERSION_MAJOR 3)
set(SLEEF_VERSION_MINOR 6)
set(SLEEF_VERSION_PATCHLEVEL 0)
set(SLEEF_VERSION ${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL})
set(SLEEF_SOVERSION ${SLEEF_VERSION_MAJOR})

set(LANGLIST C)

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

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

project(SLEEF VERSION ${SLEEF_VERSION} LANGUAGES ${LANGLIST})
if (SLEEF_ENABLE_CUDA)
enable_language(CUDA)
endif()

# For specifying installation directories
include(GNUInstallDirs)
Expand All @@ -162,7 +166,6 @@ if(SLEEF_ENABLE_LTO AND BUILD_SHARED_LIBS)
endif(SLEEF_ENABLE_LTO AND BUILD_SHARED_LIBS)

if(SLEEF_ENABLE_LTO)
cmake_policy(SET CMP0069 NEW)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
endif()
Expand Down
1 change: 1 addition & 0 deletions docs/build-with-cmake.md
Expand Up @@ -134,6 +134,7 @@ optimized, or any other special set of flags.
- `SLEEF_SHOW_ERROR_LOG` : Show the content of CMakeError.log

- `BUILD_SHARED_LIBS` : Static libs are built if set to FALSE
- `SLEEF_BUILD_SHARED_LIBS` : If set, override the value of `BUILD_SHARED_LIBS` when configuring SLEEF.
- `SLEEF_BUILD_GNUABI_LIBS` : Avoid building libraries with GNU ABI if set to FALSE
- `SLEEF_BUILD_INLINE_HEADERS` : Generate header files for inlining whole SLEEF functions

Expand Down
9 changes: 0 additions & 9 deletions src/dft/CMakeLists.txt
Expand Up @@ -423,12 +423,3 @@ install(
INCLUDES #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(
TARGETS ${TARGET_LIBDFT}
DESTINATION dummy # provided above already
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
28 changes: 1 addition & 27 deletions src/libm/CMakeLists.txt
Expand Up @@ -594,7 +594,7 @@ if(SLEEF_BUILD_INLINE_HEADERS)
${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.tmp3
| ${SED_COMMAND}
# Embed version number into the header
-e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g"
-e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCH}/g"
-e "s/SLEEF_SIMD_SLEEF/${SIMD}/g"
# Substitute "SLEEFSHARP" at the beginning of line with "#"
-e "s/^SLEEFSHARP/#/g"
Expand Down Expand Up @@ -1004,15 +1004,6 @@ if(SLEEF_BUILD_SCALAR_LIB)
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
)

install(
TARGETS sleefscalar
DESTINATION dummy # provided above already
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
endif()

# --------------------------------------------------------------------
Expand All @@ -1038,14 +1029,6 @@ install(
INCLUDES #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(
TARGETS ${TARGET_LIBSLEEF}
DESTINATION dummy # provided above already
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
configure_file("sleef.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc" @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/sleef.pc"
Expand All @@ -1068,13 +1051,4 @@ if(ENABLE_GNUABI)
DESTINATION "${CMAKE_INSTALL_BINDIR}"
COMPONENT sleef_Runtime
)

install(
TARGETS ${TARGET_LIBSLEEF}
DESTINATION dummy # provided above already
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
endif()
2 changes: 1 addition & 1 deletion src/libm/sleef.pc.in
Expand Up @@ -4,6 +4,6 @@ includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@

Name: SLEEF
Description: SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT
Version: @SLEEF_VERSION_MAJOR@.@SLEEF_VERSION_MINOR@.@SLEEF_VERSION_PATCHLEVEL@
Version: @SLEEF_VERSION_MAJOR@.@SLEEF_VERSION_MINOR@.@SLEEF_VERSION_PATCH@
Cflags: -I${includedir}
Libs: -L${libdir} -lsleef
2 changes: 1 addition & 1 deletion src/libm/sleeflibm_header.h.org.in
Expand Up @@ -8,7 +8,7 @@

#define SLEEF_VERSION_MAJOR @SLEEF_VERSION_MAJOR@
#define SLEEF_VERSION_MINOR @SLEEF_VERSION_MINOR@
#define SLEEF_VERSION_PATCHLEVEL @SLEEF_VERSION_PATCHLEVEL@
#define SLEEF_VERSION_PATCHLEVEL @SLEEF_VERSION_PATCH@

#include <stddef.h>
#include <stdint.h>
Expand Down
13 changes: 2 additions & 11 deletions src/quad/CMakeLists.txt
Expand Up @@ -327,8 +327,8 @@ if(SLEEF_BUILD_INLINE_HEADERS)
${CMAKE_CURRENT_BINARY_DIR}/sleef${SIMD}.h.qtmp2
| ${SED_COMMAND}
# Embed version number into the header
-e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCHLEVEL}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
-e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" # -e "s/SLEEF_SIMD_SLEEF/SSE2/g"
-e "s/SLEEF_VERSION_SLEEF/${SLEEF_VERSION_MAJOR}.${SLEEF_VERSION_MINOR}.${SLEEF_VERSION_PATCH}/g" # "s/SLEEF_VERSION_SLEEF/3.5.0/g"
-e "s/SLEEF_SIMD_SLEEF/${SIMD}/g" # -e "s/SLEEF_SIMD_SLEEF/SSE2/g"
# Substitute "SLEEFSHARP" at the beginning of line with "#"
-e "s/^SLEEFSHARP/#/g"
# Remove SLEEFXXX
Expand Down Expand Up @@ -502,12 +502,3 @@ install(
INCLUDES #
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(
TARGETS sleefquad
DESTINATION dummy # provided above already
LIBRARY #
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
COMPONENT sleef_Development
NAMELINK_ONLY
)
2 changes: 1 addition & 1 deletion src/quad/sleefquad_header.h.org.in
Expand Up @@ -8,7 +8,7 @@

#define SLEEF_VERSION_MAJOR @SLEEF_VERSION_MAJOR@
#define SLEEF_VERSION_MINOR @SLEEF_VERSION_MINOR@
#define SLEEF_VERSION_PATCHLEVEL @SLEEF_VERSION_PATCHLEVEL@
#define SLEEF_VERSION_PATCHLEVEL @SLEEF_VERSION_PATCH@

#include "sleef.h"
#include <string.h>
Expand Down