summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2019-02-14 23:57:25 +0800
committerruki <[email protected]>2019-02-14 17:44:31 +0800
commit4595e65797b351755978f0986dcd2649980eccce (patch)
treed4c94c73be4770c4a1d13e86092af3b073396fb9 /xmake/plugins
parent5e8f7e83a6a093d683b189b4feaddde224105e43 (diff)
add languages to cmakelists
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/project/cmake/cmakelists.lua41
1 files changed, 41 insertions, 0 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua
index 661d778c6..fd55fa94e 100644
--- a/xmake/plugins/project/cmake/cmakelists.lua
+++ b/xmake/plugins/project/cmake/cmakelists.lua
@@ -164,6 +164,44 @@ function _add_target_compile_options(cmakelists, target)
end
end
+-- add target language standards
+function _add_target_language_standards(cmakelists, target)
+ local cstds =
+ {
+ c89 = "90"
+ , gnu89 = "90" -- TODO add cflags -std=gnu90 if supported
+ , c99 = "99"
+ , gnu99 = "99" -- TODO
+ , c11 = "11"
+ , gnu11 = "11" -- TODO
+ }
+ local cxxstds =
+ {
+ cxx98 = "98"
+ , gnuxx98 = "98" -- TODO
+ , cxx11 = "11"
+ , gnuxx11 = "11"
+ , cxx14 = "14"
+ , gnuxx14 = "14"
+ , cxx17 = "17"
+ , gnuxx17 = "17"
+ , cxx1z = "17"
+ , gnuxx1z = "17"
+ , cxx2a = "20"
+ , gnuxx2a = "20"
+ }
+ for _, lang in ipairs(target:get("languages")) do
+ local cstd = cstds[lang]
+ if cstd then
+ cmakelists:print("set_property(TARGET %s PROPERTY C_STANDARD %s)", target:name(), cstd)
+ end
+ local cxxstd = cxxstds[lang]
+ if cxxstd then
+ cmakelists:print("set_property(TARGET %s PROPERTY CXX_STANDARD %s)", target:name(), cxxstd)
+ end
+ end
+end
+
-- add target link libraries
function _add_target_link_libraries(cmakelists, target)
local links = target:get("links")
@@ -268,6 +306,9 @@ function _add_target(cmakelists, target)
-- add target compile definitions
_add_target_compile_definitions(cmakelists, target)
+ -- add target language standards
+ _add_target_language_standards(cmakelists, target)
+
-- add target compile options
_add_target_compile_options(cmakelists, target)