diff options
| author | ruki <[email protected]> | 2022-02-11 22:30:12 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-02-11 22:30:12 +0800 |
| commit | 85ae6415a9650fe77325a965e76dc0d5984b9430 (patch) | |
| tree | 89c1d35125ca5f680e25b21e85095f52e783ca9b | |
| parent | 8f62958d7fd2c602bd8f0f2d304067d08b3de405 (diff) | |
add cuda for cmakelists
| -rw-r--r-- | xmake/plugins/project/cmake/cmakelists.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/xmake/plugins/project/cmake/cmakelists.lua b/xmake/plugins/project/cmake/cmakelists.lua index 6b0a3d7e3..57a2d283b 100644 --- a/xmake/plugins/project/cmake/cmakelists.lua +++ b/xmake/plugins/project/cmake/cmakelists.lua @@ -103,7 +103,7 @@ function _add_project(cmakelists) if project_version then project_info = project_info .. " VERSION " .. project_version end - cmakelists:print("project(%s%s LANGUAGES C CXX ASM)", project_name, project_info) + cmakelists:print("project(%s%s LANGUAGES C CXX ASM CUDA)", project_name, project_info) end cmakelists:print("") end @@ -162,19 +162,26 @@ end -- add target sources function _add_target_sources(cmakelists, target) + local has_cuda = false cmakelists:print("target_sources(%s PRIVATE", target:name()) for _, sourcebatch in pairs(target:sourcebatches()) do local sourcekind = sourcebatch.sourcekind - if sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as" then + if sourcekind == "cc" or sourcekind == "cxx" or sourcekind == "as" or sourcekind == "cu" then for _, sourcefile in ipairs(sourcebatch.sourcefiles) do cmakelists:print(" " .. _get_unix_path(sourcefile)) end end + if sourcekind == "cu" then + has_cuda = true + end end for _, headerfile in ipairs(target:headerfiles()) do cmakelists:print(" " .. _get_unix_path(headerfile)) end cmakelists:print(")") + if has_cuda then + cmakelists:print("set_target_properties(%s PROPERTIES CUDA_SEPARABLE_COMPILATION ON)", target:name()) + end end -- add target precompilied header |
