Skip to content

Commit

Permalink
Use -faligned-new if supported. Fixes #21
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Dec 7, 2019
1 parent bf80e22 commit d88fc79
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmake/GtsamBuildTypes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ function(list_append_cache var)
set(${var} "${cur_value}" CACHE STRING "${MYVAR_DOCSTRING}" FORCE)
endfunction()

# Check for optional compiler flags, if supported:
include(CheckCXXCompilerFlag)
# See https://github.com/borglab/gtsam/issues/21
check_cxx_compiler_flag(-faligned-new COMPILER_HAS_FALIGNED_NEW)

# function: append_config_if_not_empty(TARGET_VARIABLE build_type)
# Auxiliary function used to merge configuration-specific flags into the
# global variables that will actually be send to cmake targets.
Expand Down Expand Up @@ -95,7 +100,12 @@ if(MSVC)
else()
# Common to all configurations, next for each configuration:
# "-fPIC" is to ensure proper code generation for shared libraries
set(GTSAM_COMPILE_OPTIONS_PRIVATE_COMMON -Wall -fPIC CACHE STRING "(User editable) Private compiler flags for all configurations.")

set(DEFAULT_COMMON_FLAGS -Wall -fPIC)
if (COMPILER_HAS_FALIGNED_NEW)
list(APPEND DEFAULT_COMMON_FLAGS -faligned-new)
endif()
set(GTSAM_COMPILE_OPTIONS_PRIVATE_COMMON ${DEFAULT_COMMON_FLAGS} CACHE STRING "(User editable) Private compiler flags for all configurations.")
set(GTSAM_COMPILE_OPTIONS_PRIVATE_DEBUG -g -fno-inline CACHE STRING "(User editable) Private compiler flags for Debug configuration.")
set(GTSAM_COMPILE_OPTIONS_PRIVATE_RELWITHDEBINFO -g -O3 CACHE STRING "(User editable) Private compiler flags for RelWithDebInfo configuration.")
set(GTSAM_COMPILE_OPTIONS_PRIVATE_RELEASE -O3 CACHE STRING "(User editable) Private compiler flags for Release configuration.")
Expand Down

0 comments on commit d88fc79

Please sign in to comment.