summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-02-14 22:51:31 +0800
committerruki <[email protected]>2019-02-14 11:09:10 +0800
commit2b25d1300333ad47706fbcdcab4665abf6785ff1 (patch)
tree5e91e3663ee7bf978d7da170eeefbffce1af0520
parentae1d10255b58e88ab9b687c333654cf4eb32e2d3 (diff)
support some deprecated api for cmakelists
-rw-r--r--xmake/core/project/target.lua2
-rw-r--r--xmake/plugins/project/cmake/cmakelists.lua27
-rw-r--r--xmake/plugins/project/make/makefile.lua5
3 files changed, 27 insertions, 7 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 43ebb8c23..c80a83c10 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -1542,7 +1542,7 @@ function target:configprefix()
return configprefix
end
--- get the config header files
+-- get the config header files (deprecated)
function target:configheader(outputdir)
-- get config header
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua
index 728277eed..ada9f155b 100644
--- a/xmake/plugins/project/cmake/cmakelists.lua
+++ b/xmake/plugins/project/cmake/cmakelists.lua
@@ -115,6 +115,11 @@ function _add_target_include_directories(cmakelists, target)
end
cmakelists:print(")")
end
+ -- export config header directory (deprecated)
+ local configheader = target:configheader()
+ if configheader then
+ cmakelists:print("target_include_directories(%s PUBLIC %s)", target:name(), path.directory(configheader))
+ end
end
-- add target compile definitions
@@ -211,8 +216,23 @@ function _add_target_link_options(cmakelists, target)
end
end
+-- TODO export target headers (deprecated)
+function _export_target_headers(target)
+ local srcheaders, dstheaders = target:headers()
+ if srcheaders and dstheaders then
+ local i = 1
+ for _, srcheader in ipairs(srcheaders) do
+ local dstheader = dstheaders[i]
+ if dstheader then
+ os.cp(srcheader, dstheader)
+ end
+ i = i + 1
+ end
+ end
+end
+
-- add target
-function _add_target(cmakelists, target, targetflags)
+function _add_target(cmakelists, target)
-- add comment
cmakelists:print("# target")
@@ -231,6 +251,9 @@ function _add_target(cmakelists, target, targetflags)
raise("unknown target kind %s", target:targetkind())
end
+ -- TODO export target headers (deprecated)
+ _export_target_headers(target)
+
-- add target dependencies
_add_target_dependencies(cmakelists, target)
@@ -267,7 +290,7 @@ function _generate_cmakelists(cmakelists)
-- add targets
for _, target in pairs(project.targets()) do
- _add_target(cmakelists, target, targetflags)
+ _add_target(cmakelists, target)
end
end
diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua
index e5aaaa201..82a49c220 100644
--- a/xmake/plugins/project/make/makefile.lua
+++ b/xmake/plugins/project/make/makefile.lua
@@ -35,7 +35,6 @@ end
-- mkdir directory
function _mkdir(makefile, dir)
-
if is_plat("windows") then
makefile:print("\t-@mkdir %s > NUL 2>&1", dir)
else
@@ -45,8 +44,6 @@ end
-- copy file
function _cp(makefile, sourcefile, targetfile)
-
- -- copy file
if is_plat("windows") then
makefile:print("\t@copy /Y %s %s > NUL 2>&1", sourcefile, targetfile)
else
@@ -343,7 +340,7 @@ function _make_target(makefile, target, targetflags)
-- TODO make header directories (deprecated)
local dstheaderdirs = {}
- local srcheaders, dstheaders = target:headerfiles()
+ local srcheaders, dstheaders = target:headers()
for _, dstheader in ipairs(dstheaders) do
dstheaderdirs[path.directory(dstheader)] = true
end