target_link_frameworks.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # This file is part of Desktop App Toolkit,
  2. # a set of libraries for developing nice desktop applications.
  3. #
  4. # For license and copyright information please follow this link:
  5. # https://github.com/desktop-app/legal/blob/master/LEGAL
  6. function(target_link_frameworks_generic type target_name)
  7. set(writing_now "")
  8. set(private_frameworks "")
  9. set(public_frameworks "")
  10. set(interface_frameworks "")
  11. foreach (entry ${ARGN})
  12. if (${entry} STREQUAL "PRIVATE" OR ${entry} STREQUAL "PUBLIC" OR ${entry} STREQUAL "INTERFACE")
  13. set(writing_now ${entry})
  14. else()
  15. set(full_argument "${type} ${entry}")
  16. if ("${writing_now}" STREQUAL "PRIVATE")
  17. list(APPEND private_frameworks ${full_argument})
  18. elseif ("${writing_now}" STREQUAL "PUBLIC")
  19. list(APPEND public_frameworks ${full_argument})
  20. elseif ("${writing_now}" STREQUAL "INTERFACE")
  21. list(APPEND interface_frameworks ${full_argument})
  22. else()
  23. message(FATAL_ERROR "Unknown frameworks scope for target ${target_name}")
  24. endif()
  25. endif()
  26. endforeach()
  27. if (NOT "${public_frameworks}" STREQUAL "")
  28. target_link_libraries(${target_name} PUBLIC ${public_frameworks})
  29. endif()
  30. if (NOT "${private_frameworks}" STREQUAL "")
  31. target_link_libraries(${target_name} PRIVATE ${private_frameworks})
  32. endif()
  33. if (NOT "${interface_frameworks}" STREQUAL "")
  34. target_link_libraries(${target_name} INTERFACE ${interface_frameworks})
  35. endif()
  36. endfunction()
  37. function(target_link_frameworks)
  38. target_link_frameworks_generic("-framework" ${ARGN})
  39. endfunction()
  40. function(target_link_frameworks_weak)
  41. target_link_frameworks_generic("-weak_framework" ${ARGN})
  42. endfunction()