default to clang++ on OS X and start reporting CXX compiler used in mapnik-config - closes #1839

This commit is contained in:
Dane Springmeyer 2013-05-10 13:24:41 -07:00
parent d36a7323ac
commit 7518c9c2c2
3 changed files with 21 additions and 8 deletions

View file

@ -35,6 +35,12 @@ except:
LIBDIR_SCHEMA_DEFAULT='lib'
severities = ['debug', 'warn', 'error', 'none']
DEFAULT_CC = "gcc"
DEFAULT_CXX = "g++"
if sys.platform == 'darwin':
DEFAULT_CC = "clang"
DEFAULT_CXX = "clang++"
py3 = None
# local file to hold custom user configuration variables
@ -168,7 +174,7 @@ def shortest_name(libs):
def sort_paths(items,priority):
"""Sort paths such that compiling and linking will globally prefer custom or local libs
over system libraries by fixing up the order libs are passed to gcc and the linker.
over system libraries by fixing up the order libs are passed to the compiler and the linker.
Ideally preference could be by-target instead of global, but our SCons implementation
is not currently utilizing different SCons build env()'s as we should.
@ -253,15 +259,15 @@ opts = Variables()
opts.AddVariables(
# Compiler options
('CXX', 'The C++ compiler to use to compile mapnik (defaults to g++).', 'g++'),
('CC', 'The C compiler used for configure checks of C libs (defaults to gcc).', 'gcc'),
('CXX', 'The C++ compiler to use to compile mapnik', DEFAULT_CXX),
('CC', 'The C compiler used for configure checks of C libs.', DEFAULT_CC),
('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''),
('CUSTOM_DEFINES', 'Custom Compiler DEFINES, e.g. -DENABLE_THIS', ''),
('CUSTOM_CFLAGS', 'Custom C flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> (only used for configure checks)', ''),
('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>', ''),
EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']),
EnumVariable('RUNTIME_LINK', "Set preference for linking dependencies",'shared', ['shared','static']),
EnumVariable('OPTIMIZATION','Set g++ optimization level','3', ['0','1','2','3','4','s']),
EnumVariable('OPTIMIZATION','Set compiler optimization level','3', ['0','1','2','3','4','s']),
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'),
BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'),
@ -1588,11 +1594,11 @@ if not preconfigured:
if not env['SUNCC']:
# Common flags for GCC.
gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread)
common_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread)
if env['DEBUG']:
env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline')
env.Append(CXXFLAGS = common_cxx_flags + '-O0 -fno-inline')
else:
env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -fvisibility-inlines-hidden -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION']))
env.Append(CXXFLAGS = common_cxx_flags + '-O%s -fvisibility-inlines-hidden -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION']))
if env['DEBUG_UNDEFINED']:
env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv')

View file

@ -32,6 +32,7 @@ CONFIG_MAPNIK_LDFLAGS='%(ldflags)s'
CONFIG_MAPNIK_INCLUDE="${CONFIG_PREFIX}/include -I${CONFIG_PREFIX}/include/mapnik/agg"
CONFIG_DEP_INCLUDES='%(dep_includes)s'
CONFIG_CXXFLAGS='%(cxxflags)s'
CONFIG_CXX='%(cxx)s'
'''
@ -107,7 +108,8 @@ configuration = {
"fonts": fontspath,
"input_plugins": inputpluginspath,
"defines":defines,
"cxxflags":cxxflags
"cxxflags":cxxflags,
"cxx":env['CXX']
}
## if we are statically linking depedencies

View file

@ -24,6 +24,7 @@ Known values for OPTION are:
--dep-includes include paths (-I) for Mapnik dependencies (new in 2.2.x)
--cxxflags c++ compiler flags and pre-processor defines (new in 2.2.x)
--cflags all include paths, compiler flags, and pre-processor defines (for back-compatibility)
--cxx c++ compiler used to build mapnik (new in 2.2.x)
EOF
exit $1
@ -113,6 +114,10 @@ while test $# -gt 0; do
echo -I${CONFIG_MAPNIK_INCLUDE} ${CONFIG_DEP_INCLUDES} ${CONFIG_MAPNIK_DEFINES} ${CONFIG_CXXFLAGS}
;;
--cxx)
echo ${CONFIG_CXX}
;;
*)
# push to stderr any invalid options
echo "unknown option $1" 1>&2;