You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

make2cmake.cmake 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # This code is licensed under the MIT License. See the FindBANG.cmake script
  2. # for the text of the license.
  3. # The MIT License
  4. #
  5. # License for the specific language governing rights and limitations under
  6. # Permission is hereby granted, free of charge, to any person obtaining a
  7. # copy of this software and associated documentation files (the "Software"),
  8. # to deal in the Software without restriction, including without limitation
  9. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. # and/or sell copies of the Software, and to permit persons to whom the
  11. # Software is furnished to do so, subject to the following conditions:
  12. #
  13. # The above copyright notice and this permission notice shall be included
  14. # in all copies or substantial portions of the Software.
  15. #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17. # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. # DEALINGS IN THE SOFTWARE.
  23. #
  24. #######################################################################
  25. # This converts a file written in makefile syntax into one that can be included
  26. # by CMake.
  27. file(READ ${input_file} depend_text)
  28. if (NOT "${depend_text}" STREQUAL "")
  29. # message("FOUND DEPENDS")
  30. string(REPLACE "\\ " " " depend_text ${depend_text})
  31. # This works for the cncc -M generated dependency files.
  32. string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
  33. string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text})
  34. set(dependency_list "")
  35. foreach(file ${depend_text})
  36. string(REGEX REPLACE "^ +" "" file ${file})
  37. # OK, now if we had a UNC path, cncc has a tendency to only output the first '/'
  38. # instead of '//'. Here we will test to see if the file exists, if it doesn't then
  39. # try to prepend another '/' to the path and test again. If it still fails remove the
  40. # path.
  41. if(NOT EXISTS "${file}")
  42. if (EXISTS "/${file}")
  43. set(file "/${file}")
  44. else()
  45. message(WARNING " Removing non-existent dependency file: ${file}")
  46. set(file "")
  47. endif()
  48. endif()
  49. if(NOT IS_DIRECTORY "${file}")
  50. # If softlinks start to matter, we should change this to REALPATH. For now we need
  51. # to flatten paths, because cncc can generate stuff like /bin/../include instead of
  52. # just /include.
  53. get_filename_component(file_absolute "${file}" ABSOLUTE)
  54. list(APPEND dependency_list "${file_absolute}")
  55. endif()
  56. endforeach()
  57. else()
  58. # message("FOUND NO DEPENDS")
  59. endif()
  60. # Remove the duplicate entries and sort them.
  61. list(REMOVE_DUPLICATES dependency_list)
  62. list(SORT dependency_list)
  63. foreach(file ${dependency_list})
  64. set(bang_cncc_depend "${bang_cncc_depend} \"${file}\"\n")
  65. endforeach()
  66. file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(BANG_CNCC_DEPEND\n ${bang_cncc_depend})\n\n")

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台