make2cmake.cmake 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # For more information, please see: http://software.sci.utah.edu
  2. #
  3. # The MIT License
  4. #
  5. # Copyright (c) 2007
  6. # Scientific Computing and Imaging Institute, University of Utah
  7. #
  8. # License for the specific language governing rights and limitations under
  9. # Permission is hereby granted, free of charge, to any person obtaining a
  10. # copy of this software and associated documentation files (the "Software"),
  11. # to deal in the Software without restriction, including without limitation
  12. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. # and/or sell copies of the Software, and to permit persons to whom the
  14. # Software is furnished to do so, subject to the following conditions:
  15. #
  16. # The above copyright notice and this permission notice shall be included
  17. # in all copies or substantial portions of the Software.
  18. #
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  20. # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  22. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  24. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  25. # DEALINGS IN THE SOFTWARE.
  26. # Make2cmake CMake Script
  27. # Abe Stephens and James Bigler
  28. # (c) 2007 Scientific Computing and Imaging Institute, University of Utah
  29. # Note that the REGEX expressions may need to be tweaked for different dependency generators.
  30. file(READ ${input_file} depend_text)
  31. if (${depend_text} MATCHES ".+")
  32. # message("FOUND DEPENDS")
  33. # Remember, four backslashes is escaped to one backslash in the string.
  34. string(REGEX REPLACE "\\\\ " " " depend_text ${depend_text})
  35. # This works for the nvcc -M generated dependency files.
  36. string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
  37. string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text})
  38. set(dependency_list "")
  39. foreach(file ${depend_text})
  40. string(REGEX REPLACE "^ +" "" file ${file})
  41. if(NOT IS_DIRECTORY ${file})
  42. # If softlinks start to matter, we should change this to REALPATH. For now we need
  43. # to flatten paths, because nvcc can generate stuff like /bin/../include instead of
  44. # just /include.
  45. get_filename_component(file_absolute "${file}" ABSOLUTE)
  46. list(APPEND dependency_list "${file_absolute}")
  47. endif(NOT IS_DIRECTORY ${file})
  48. endforeach(file)
  49. else()
  50. # message("FOUND NO DEPENDS")
  51. endif()
  52. # Remove the duplicate entries and sort them.
  53. list(REMOVE_DUPLICATES dependency_list)
  54. list(SORT dependency_list)
  55. foreach(file ${dependency_list})
  56. set(cuda_nvcc_depend "${cuda_nvcc_depend} \"${file}\"\n")
  57. endforeach()
  58. file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(CUDA_NVCC_DEPEND\n ${cuda_nvcc_depend})\n\n")