Skip to content

Commit

Permalink
STY: Format CMake files
Browse files Browse the repository at this point in the history
  • Loading branch information
RUrlus committed Oct 17, 2024
1 parent 47396a6 commit db04cb8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
66 changes: 33 additions & 33 deletions src/sparse_dot_topn_core/cmake/ConfigureTarget.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
target_include_directories(_sparse_dot_topn_core PUBLIC ${SDTN_INCLUDE_DIR})
if(OpenMP_CXX_FOUND)
target_link_libraries(_sparse_dot_topn_core PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(_sparse_dot_topn_core PRIVATE SDTN_OMP_ENABLED=TRUE)
target_link_libraries(_sparse_dot_topn_core PUBLIC OpenMP::OpenMP_CXX)
target_compile_definitions(_sparse_dot_topn_core PRIVATE SDTN_OMP_ENABLED=TRUE)
if(APPLE)
# store path to libomp found at build time in a variable
get_target_property(
Expand Down Expand Up @@ -78,7 +78,7 @@ target_compile_definitions(_sparse_dot_topn_core PRIVATE VERSION_INFO=${SKBUILD_

# -- Optional
if(SDTN_ENABLE_DEVMODE)
target_compile_options(_sparse_dot_topn_core PRIVATE ${SDTN_DEVMODE_OPTIONS})
target_compile_options(_sparse_dot_topn_core PRIVATE ${SDTN_DEVMODE_OPTIONS})
endif()

# -- Options & Properties
Expand All @@ -89,41 +89,41 @@ set_property(TARGET _sparse_dot_topn_core PROPERTY POSITION_INDEPENDENT_CODE ON)
include(CheckCXXCompilerFlag)

function(check_cxx_support FLAG DEST)
string(SUBSTRING ${FLAG} 1 -1 STRIPPED_FLAG)
string(REGEX REPLACE "=" "_" STRIPPED_FLAG ${STRIPPED_FLAG})
string(TOUPPER ${STRIPPED_FLAG} STRIPPED_FLAG)
set(RES_VAR "${STRIPPED_FLAG}_SUPPORTED")
check_cxx_compiler_flag("${FLAG}" ${RES_VAR})
if(${RES_VAR})
set(${DEST} "${${DEST}} ${FLAG}" PARENT_SCOPE)
endif()
string(SUBSTRING ${FLAG} 1 -1 STRIPPED_FLAG)
string(REGEX REPLACE "=" "_" STRIPPED_FLAG ${STRIPPED_FLAG})
string(TOUPPER ${STRIPPED_FLAG} STRIPPED_FLAG)
set(RES_VAR "${STRIPPED_FLAG}_SUPPORTED")
check_cxx_compiler_flag("${FLAG}" ${RES_VAR})
if(${RES_VAR})
set(${DEST} "${${DEST}} ${FLAG}" PARENT_SCOPE)
endif()
endfunction()

# -- Compiler Flags
if (SDTN_ENABLE_ARCH_FLAGS AND "${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_DEFAULT}")
set(SDTN_ARCHITECTURE_FLAGS "")
if (APPLE AND (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64"))
# see https://github.com/google/highway/issues/745
check_cxx_support("-march=native" SDTN_ARCHITECTURE_FLAGS)
else()
include(FindSse)
include(FindAvx)
SDTN_CHECK_FOR_SSE()
add_definitions(${SSE_DEFINITIONS})
SDTN_CHECK_FOR_AVX()
string(APPEND SDTN_ARCHITECTURE_FLAGS "${SSE_FLAGS} ${AVX_FLAGS}")
endif()
set(SDTN_ARCHITECTURE_FLAGS "")
if (APPLE AND (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64"))
# see https://github.com/google/highway/issues/745
check_cxx_support("-march=native" SDTN_ARCHITECTURE_FLAGS)
else()
include(FindSse)
include(FindAvx)
SDTN_CHECK_FOR_SSE()
add_definitions(${SSE_DEFINITIONS})
SDTN_CHECK_FOR_AVX()
string(APPEND SDTN_ARCHITECTURE_FLAGS "${SSE_FLAGS} ${AVX_FLAGS}")
endif()

if (NOT ${SDTN_ARCHITECTURE_FLAGS} STREQUAL "")
string(STRIP ${SDTN_ARCHITECTURE_FLAGS} SDTN_ARCHITECTURE_FLAGS)
message(STATUS "sparse-dot-topn | Enabled arch flags: ${SDTN_ARCHITECTURE_FLAGS}")
if (MSVC)
separate_arguments(SDTN_ARCHITECTURE_FLAGS WINDOWS_COMMAND "${SDTN_ARCHITECTURE_FLAGS}")
else()
separate_arguments(SDTN_ARCHITECTURE_FLAGS UNIX_COMMAND "${SDTN_ARCHITECTURE_FLAGS}")
endif()
target_compile_options(_sparse_dot_topn_core PRIVATE $<$<CONFIG:RELEASE>:${SDTN_ARCHITECTURE_FLAGS}>)
if (NOT ${SDTN_ARCHITECTURE_FLAGS} STREQUAL "")
string(STRIP ${SDTN_ARCHITECTURE_FLAGS} SDTN_ARCHITECTURE_FLAGS)
message(STATUS "sparse-dot-topn | Enabled arch flags: ${SDTN_ARCHITECTURE_FLAGS}")
if (MSVC)
separate_arguments(SDTN_ARCHITECTURE_FLAGS WINDOWS_COMMAND "${SDTN_ARCHITECTURE_FLAGS}")
else()
message(STATUS "sparse-dot-topn | Architecture flags enabled but no valid flags were found")
separate_arguments(SDTN_ARCHITECTURE_FLAGS UNIX_COMMAND "${SDTN_ARCHITECTURE_FLAGS}")
endif()
target_compile_options(_sparse_dot_topn_core PRIVATE $<$<CONFIG:RELEASE>:${SDTN_ARCHITECTURE_FLAGS}>)
else()
message(STATUS "sparse-dot-topn | Architecture flags enabled but no valid flags were found")
endif()
endif()
2 changes: 1 addition & 1 deletion src/sparse_dot_topn_core/cmake/FindAvx.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###############################################################################
# ##############################################################################
# Check for the presence of AVX and figure out the flags to use for it.
# This routine is a modified version of `PCL_CHECK_FOR_AVX`
# Reference: https://github.com/PointCloudLibrary/pcl/blob/master/cmake/pcl_find_avx.cmake
Expand Down
2 changes: 1 addition & 1 deletion src/sparse_dot_topn_core/cmake/FindSse.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###############################################################################
# ##############################################################################
# Check for the presence of SSE and figure out the flags to use for it.
# This routine is a modified version of `PCL_CHECK_FOR_SSE`
# https://github.com/PointCloudLibrary/pcl/blob/master/cmake/pcl_find_sse.cmake
Expand Down

0 comments on commit db04cb8

Please sign in to comment.