Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 6 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
# The full license is in the file LICENSE, distributed with this software. #
############################################################################

cmake_minimum_required(VERSION 3.10)
project(xsimd)
option(XSIMD_REFACTORING ON)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XSIMD_REFACTORING, that brings back some memories :-)

cmake_minimum_required(VERSION 3.13)

set(XSIMD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
project(xsimd)

# Versioning
# ==========

file(STRINGS "${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_config.hpp" xsimd_version_defines
file(STRINGS "include/xsimd/config/xsimd_config.hpp" xsimd_version_defines
REGEX "#define XSIMD_VERSION_(MAJOR|MINOR|PATCH)")
foreach(ver ${xsimd_version_defines})
if(ver MATCHES "#define XSIMD_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$")
Expand All @@ -32,62 +30,11 @@ message(STATUS "xsimd v${${PROJECT_NAME}_VERSION}")
# Build
# =====

set(XSIMD_HEADERS
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_constants.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_fma3_avx.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_fma3_avx2.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_fma3_sse.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_fma4.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_common.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_isa.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_neon.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_neon64.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_rvv.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_scalar.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse2.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse3.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse4_1.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sse4_2.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_ssse3.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_vsx.hpp
${XSIMD_INCLUDE_DIR}/xsimd/arch/xsimd_sve.hpp
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_arch.hpp
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_config.hpp
${XSIMD_INCLUDE_DIR}/xsimd/config/xsimd_cpuid.hpp
${XSIMD_INCLUDE_DIR}/xsimd/memory/xsimd_aligned_allocator.hpp
${XSIMD_INCLUDE_DIR}/xsimd/memory/xsimd_alignment.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_all_registers.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_api.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_neon_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_neon64_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_avx2_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_avx512f_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_avx_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_batch.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_batch_constant.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_fma3_avx_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_fma3_avx2_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_fma3_sse_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_fma4_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_common_arch.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_vsx_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_rvv_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse2_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse3_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse4_1_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sse4_2_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_ssse3_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_sve_register.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_traits.hpp
${XSIMD_INCLUDE_DIR}/xsimd/types/xsimd_utils.hpp
${XSIMD_INCLUDE_DIR}/xsimd/xsimd.hpp
)

add_library(xsimd INTERFACE)
add_library(xsimd::xsimd ALIAS xsimd)

target_include_directories(xsimd INTERFACE
$<BUILD_INTERFACE:${XSIMD_INCLUDE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)

OPTION(ENABLE_XTL_COMPLEX "enables support for xcomplex defined in xtl" OFF)
Expand Down Expand Up @@ -123,8 +70,6 @@ if(${XSIMD_SKIP_INSTALL})
return() # skip installation
endif ()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(JoinPaths)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

Expand All @@ -135,7 +80,7 @@ install(TARGETS xsimd
export(EXPORT ${PROJECT_NAME}-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake")

install(DIRECTORY ${XSIMD_INCLUDE_DIR}/xsimd
install(DIRECTORY include/xsimd
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
Expand Down
13 changes: 5 additions & 8 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
# The full license is in the file LICENSE, distributed with this software. #
############################################################################

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
project(xsimd-benchmark)

find_package(xsimd REQUIRED CONFIG)
set(XSIMD_INCLUDE_DIR ${xsimd_INCLUDE_DIRS})
endif ()

if(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -63,18 +62,16 @@ if(MSVC)
endforeach()
endif()

include_directories(${XSIMD_INCLUDE_DIR})

set(XSIMD_BENCHMARK
set(XSIMD_BENCHMARK_SRC
main.cpp
xsimd_benchmark.hpp
)

set(XSIMD_BENCHMARK_TARGET benchmark_xsimd)
add_executable(${XSIMD_BENCHMARK_TARGET} ${XSIMD_BENCHMARK} ${XSIMD_HEADERS})
add_executable(benchmark_xsimd ${XSIMD_BENCHMARK_SRC})
target_link_libraries(benchmark_xsimd PRIVATE xsimd)

if(ENABLE_XTL_COMPLEX)
target_link_libraries(benchmark_xsimd PRIVATE xtl)
endif()

add_custom_target(xbenchmark COMMAND benchmark_xsimd DEPENDS ${XSIMD_BENCHMARK_TARGET})
add_custom_target(xbenchmark COMMAND benchmark_xsimd DEPENDS benchmark_xsimd)
26 changes: 0 additions & 26 deletions cmake/JoinPaths.cmake

This file was deleted.

9 changes: 4 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
# The full license is in the file LICENSE, distributed with this software. #
############################################################################

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
project(xsimd-examples)

find_package(xsimd REQUIRED CONFIG)
set(XSIMD_INCLUDE_DIR ${xsimd_INCLUDE_DIR})
endif ()

include_directories(${XSIMD_INCLUDE_DIR})

if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting examples build type to Release")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
Expand All @@ -35,7 +33,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
endif()
endif()

add_executable(mandelbrot mandelbrot.cpp ${XSIMD_HEADERS})
add_executable(mandelbrot mandelbrot.cpp)
target_link_libraries(mandelbrot PRIVATE xsimd)
set_property(TARGET mandelbrot PROPERTY CXX_STANDARD 14)
if(ENABLE_XTL_COMPLEX)
target_link_libraries(mandelbrot PRIVATE xtl)
Expand Down
7 changes: 3 additions & 4 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
# The full license is in the file LICENSE, distributed with this software. #
############################################################################

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)

if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
project(xsimd-test)

enable_testing()

find_package(xsimd REQUIRED CONFIG)
set(XSIMD_INCLUDE_DIR ${xsimd_INCLUDE_DIRS})
endif ()

if(NOT CMAKE_BUILD_TYPE)
Expand Down Expand Up @@ -174,8 +173,8 @@ if(NOT MSVC)
list(APPEND XSIMD_TESTS test_gnu_source.cpp)
endif()

add_executable(test_xsimd ${XSIMD_TESTS} ${XSIMD_HEADERS})
target_include_directories(test_xsimd PRIVATE ${XSIMD_INCLUDE_DIR})
add_executable(test_xsimd ${XSIMD_TESTS})
target_link_libraries(test_xsimd PRIVATE xsimd)

option(DOWNLOAD_DOCTEST OFF)
find_package(doctest QUIET)
Expand Down
6 changes: 5 additions & 1 deletion test/architectures/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ set(INTEL_PROCESSORS
icelake-server cascadelake cooperlake tigerlake sapphirerapids alderlake
rocketlake graniterapids graniterapids-d znver4)

if(NOT TARGET xsimd)
find_package(xsimd REQUIRED CONFIG)
endif()

foreach(INTEL_PROCESSOR ${INTEL_PROCESSORS})
# Adding the werror here to choke if the -march is incompatible with the
# native one.
Expand All @@ -11,7 +15,7 @@ foreach(INTEL_PROCESSOR ${INTEL_PROCESSORS})
message(STATUS ${INTEL_PROCESSOR})
add_library(test_${INTEL_PROCESSOR} OBJECT dummy.cpp)
target_compile_options(test_${INTEL_PROCESSOR} PRIVATE -march=${INTEL_PROCESSOR})
target_include_directories(test_${INTEL_PROCESSOR} PRIVATE ${XSIMD_INCLUDE_DIR})
target_link_libraries(test_${INTEL_PROCESSOR} PRIVATE xsimd)
add_dependencies(xtest test_${INTEL_PROCESSOR})
if(ENABLE_XTL_COMPLEX)
target_compile_features(test_${INTEL_PROCESSOR} PRIVATE cxx_std_14)
Expand Down
10 changes: 7 additions & 3 deletions test/doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" AND NOT CMAKE_OSX_ARCHITECTURES)

if(NOT TARGET xsimd)
find_package(xsimd REQUIRED CONFIG)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a very neat trick, <3

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not make it up, it comes up frequently in CMake files :)

endif()

if(ENABLE_XTL_COMPLEX)
add_compile_definitions(XSIMD_ENABLE_XTL_COMPLEX=1)
include_directories(${xtl_INCLUDE_DIRS})
Expand All @@ -16,19 +20,19 @@ add_library(test_doc_any_arch OBJECT
manipulating_abstract_batches.cpp
manipulating_parametric_batches.cpp
writing_vectorized_code.cpp)
target_include_directories(test_doc_any_arch PRIVATE ${XSIMD_INCLUDE_DIR})
target_link_libraries(test_doc_any_arch PRIVATE xsimd)
target_compile_options(test_doc_any_arch PRIVATE -mavx)

add_library(test_doc_avx2 OBJECT
explicit_use_of_an_instruction_set.cpp
sum_avx2.cpp)
target_link_libraries(test_doc_avx2 PRIVATE xsimd)
target_compile_options(test_doc_avx2 PRIVATE -mavx2)
target_include_directories(test_doc_avx2 PRIVATE ${XSIMD_INCLUDE_DIR})

add_library(test_doc_sse2 OBJECT
sum_sse2.cpp)
target_link_libraries(test_doc_sse2 PRIVATE xsimd)
target_compile_options(test_doc_sse2 PRIVATE -msse2)
target_include_directories(test_doc_sse2 PRIVATE ${XSIMD_INCLUDE_DIR})

add_dependencies(xtest test_doc_any_arch test_doc_avx2 test_doc_sse2)

Expand Down
Loading