Skip to content

Commit

Permalink
Move c(pp) language standard definitions outside Xcode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hsandt committed Sep 29, 2017
1 parent d3d2fbb commit 520a61f
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -980,52 +980,52 @@
end


function xcode.XCBuildConfiguration_CLanguageStandard(settings, cfg)
xcode.cLanguageStandards = {
["Default"] = "compiler-default", -- explicit compiler default
["C89"] = "c89",
["C90"] = "c90",
["C99"] = "c99",
["C11"] = "c11",
["gnu89"] = "gnu89",
["gnu90"] = "gnu90",
["gnu99"] = "gnu99",
["gnu11"] = "gnu11"
}

xcode.setCLanguageStandard = function(settings, cfg)
-- if no cppdialect is provided, don't set C dialect
-- projects without C dialect set will use compiler default
if not cfg.cdialect then
return
end

local cLanguageStandards = {
["Default"] = "compiler-default", -- explicit compiler default
["C89"] = "c89",
["C90"] = "c90",
["C99"] = "c99",
["C11"] = "c11",
["gnu89"] = "gnu89",
["gnu90"] = "gnu90",
["gnu99"] = "gnu99",
["gnu11"] = "gnu11"
}

local cLanguageStandard = cLanguageStandards[cfg.cdialect]
local cLanguageStandard = xcode.cLanguageStandards[cfg.cdialect]
if cLanguageStandard then
settings['GCC_C_LANGUAGE_STANDARD'] = cLanguageStandard
end
end


function xcode.XCBuildConfiguration_CppLanguageStandard(settings, cfg)
xcode.cppLanguageStandards = {
["Default"] = "compiler-default", -- explicit compiler default
["C++98"] = "c++98",
["C++11"] = "c++0x", -- Xcode project GUI uses c++0x, but c++11 also works
["C++14"] = "c++14",
["C++17"] = "c++1z",
["gnu++98"] = "gnu++98",
["gnu++11"] = "gnu++0x", -- Xcode project GUI uses gnu++0x, but gnu++11 also works
["gnu++14"] = "gnu++14",
["gnu++17"] = "gnu++1z"
}

xcode.setCppLanguageStandard = function(settings, cfg)
-- if no cppdialect is provided, don't set C++ dialect
-- projects without C++ dialect set will use compiler default
if not cfg.cppdialect then
return
end

local cppLanguageStandards = {
["Default"] = "compiler-default", -- explicit compiler default
["C++98"] = "c++98",
["C++11"] = "c++0x", -- Xcode project GUI uses c++0x, but c++11 also works
["C++14"] = "c++14",
["C++17"] = "c++1z",
["gnu++98"] = "gnu++98",
["gnu++11"] = "gnu++0x", -- Xcode project GUI uses gnu++0x, but c++11 also works
["gnu++14"] = "gnu++14",
["gnu++17"] = "gnu++1z"
}

local cppLanguageStandard = cppLanguageStandards[cfg.cppdialect]
local cppLanguageStandard = xcode.cppLanguageStandards[cfg.cppdialect]
if cppLanguageStandard then
settings['CLANG_CXX_LANGUAGE_STANDARD'] = cppLanguageStandard
end
Expand Down Expand Up @@ -1060,8 +1060,8 @@
settings['COPY_PHASE_STRIP'] = 'NO'
end

xcode.XCBuildConfiguration_CLanguageStandard(settings, cfg)
xcode.XCBuildConfiguration_CppLanguageStandard(settings, cfg)
xcode.setCLanguageStandard(settings, cfg)
xcode.setCppLanguageStandard(settings, cfg)

if cfg.exceptionhandling == p.OFF then
settings['GCC_ENABLE_CPP_EXCEPTIONS'] = 'NO'
Expand Down

0 comments on commit 520a61f

Please sign in to comment.