diff --git a/cmake/config.cmake b/cmake/config.cmake index a230fe9..9eea611 100644 --- a/cmake/config.cmake +++ b/cmake/config.cmake @@ -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) @@ -56,16 +62,16 @@ 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}) @@ -73,7 +79,7 @@ function(cfs_setup_filters) string(REPLACE ${ARGS_INCLUDE_DIR}/ "" filterName ${directoryName}) set(filterName include/${filterName}) endif() - + if (filterName) string(REPLACE "/" "\\" filterName ${filterName}) source_group(${filterName} FILES ${fileName})