Common.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. function(generate_output_files)
  2. set(content)
  3. foreach(tgt IN LISTS ARGN)
  4. get_property(type TARGET ${tgt} PROPERTY TYPE)
  5. if(NOT type STREQUAL "OBJECT_LIBRARY")
  6. set(file " [==[$<TARGET_FILE:${tgt}>]==]")
  7. set(filename " [==[$<TARGET_FILE_NAME:${tgt}>]==]")
  8. else()
  9. set(file)
  10. set(filename)
  11. endif()
  12. string(APPEND content "set(TARGET_FILE_${tgt}_$<CONFIG>${file})\n")
  13. string(APPEND content "set(TARGET_FILE_NAME_${tgt}_$<CONFIG>${filename})\n")
  14. if(type MATCHES "^(STATIC|MODULE|SHARED)_LIBRARY$")
  15. set(linker_file " [==[$<TARGET_LINKER_FILE:${tgt}>]==]")
  16. set(linker_filename " [==[$<TARGET_LINKER_FILE_NAME:${tgt}>]==]")
  17. else()
  18. set(linker_file)
  19. set(linker_filename)
  20. endif()
  21. string(APPEND content "set(TARGET_LINKER_FILE_${tgt}_$<CONFIG>${linker_file})\n")
  22. string(APPEND content "set(TARGET_LINKER_FILE_NAME_${tgt}_$<CONFIG>${linker_filename})\n")
  23. if(NOT WIN32 AND NOT CYGWIN AND type MATCHES "^(SHARED_LIBRARY)$")
  24. set(soname_file " [==[$<TARGET_SONAME_FILE:${tgt}>]==]")
  25. set(soname_filename " [==[$<TARGET_SONAME_FILE_NAME:${tgt}>]==]")
  26. else()
  27. set(soname_file)
  28. set(soname_filename)
  29. endif()
  30. string(APPEND content "set(TARGET_SONAME_FILE_${tgt}_$<CONFIG>${soname_file})\n")
  31. string(APPEND content "set(TARGET_SONAME_FILE_NAME_${tgt}_$<CONFIG>${soname_filename})\n")
  32. if(type MATCHES "^(EXECUTABLE)$")
  33. set(exe_file " [==[$<TARGET_FILE_DIR:${tgt}>/$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>$<TARGET_FILE_SUFFIX:${tgt}>]==]")
  34. set(exe_filename " [==[$<TARGET_FILE_PREFIX:${tgt}>$<TARGET_FILE_BASE_NAME:${tgt}>$<TARGET_FILE_SUFFIX:${tgt}>]==]")
  35. else()
  36. set(exe_file)
  37. set(exe_filename)
  38. endif()
  39. string(APPEND content "set(TARGET_EXE_FILE_${tgt}_$<CONFIG>${exe_file})\n")
  40. string(APPEND content "set(TARGET_EXE_FILE_NAME_${tgt}_$<CONFIG>${exe_filename})\n")
  41. string(APPEND content "set(TARGET_OBJECT_FILES_${tgt}_$<CONFIG> [==[$<TARGET_OBJECTS:${tgt}>]==])\n")
  42. endforeach()
  43. file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/target_files_$<CONFIG>.cmake" CONTENT "${content}")
  44. set(content)
  45. foreach(config IN LISTS CMAKE_CONFIGURATION_TYPES)
  46. string(APPEND content "include(\${CMAKE_CURRENT_LIST_DIR}/target_files_${config}.cmake)\n")
  47. endforeach()
  48. file(WRITE "${CMAKE_BINARY_DIR}/target_files.cmake" "${content}")
  49. endfunction()