Skip to content

Commit

Permalink
Added -faligned-new to compilers that allow it.
Browse files Browse the repository at this point in the history
This allows for aligned allocations in cases where AVX is enabled with
compiler flags, which requests 32-bit alignment.
  • Loading branch information
akb825 committed Jan 18, 2021
1 parent 74d0102 commit 820978c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ else()
add_compile_options(-Wall -Werror -Wconversion -Wno-sign-conversion -fno-strict-aliasing)
if (CMAKE_C_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wno-comment)
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
add_compile_options(-faligned-new)
endif()
elseif (CMAKE_C_COMPILER_ID MATCHES "Clang" AND
CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0)
add_compile_options(-faligned-new)
endif()
# Behavior for VISIBILITY_PRESET variables are inconsistent between CMake versions.
if (CUTTLEFISH_SHARED)
Expand Down Expand Up @@ -56,24 +62,24 @@ function(cfs_setup_filters)
set(oneValueArgs SRC_DIR INCLUDE_DIR)
set(multiValueArgs FILES)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

foreach (fileName ${ARGS_FILES})
# Get the directory name. Make sure there's a trailing /.
get_filename_component(directoryName ${fileName} DIRECTORY)
set(directoryName ${directoryName}/)

set(filterName)
string(REGEX MATCH ${ARGS_SRC_DIR}/.* matchSrc ${directoryName})
string(REGEX MATCH ${ARGS_INCLUDE_DIR}/.* matchInclude ${directoryName})

if (matchSrc)
string(REPLACE ${ARGS_SRC_DIR}/ "" filterName ${directoryName})
set(filterName src/${filterName})
elseif (matchInclude)
string(REPLACE ${ARGS_INCLUDE_DIR}/ "" filterName ${directoryName})
set(filterName include/${filterName})
endif()

if (filterName)
string(REPLACE "/" "\\" filterName ${filterName})
source_group(${filterName} FILES ${fileName})
Expand Down

0 comments on commit 820978c

Please sign in to comment.