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

59 lines
2.3 KiB

  1. # copied from CARL
  2. macro(add_imported_library_interface name include)
  3. add_library(${name} INTERFACE IMPORTED)
  4. set_target_properties(${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include}")
  5. endmacro(add_imported_library_interface)
  6. macro(add_imported_library name type lib include)
  7. # Workaround from https://cmake.org/Bug/view.php?id=15052
  8. file(MAKE_DIRECTORY "${include}")
  9. if("${lib}" STREQUAL "")
  10. if("${type}" STREQUAL "SHARED")
  11. add_library(${name} INTERFACE IMPORTED)
  12. set_target_properties(${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include}")
  13. endif()
  14. else()
  15. add_library(${name}_${type} ${type} IMPORTED)
  16. set_target_properties(${name}_${type} PROPERTIES IMPORTED_LOCATION "${lib}")
  17. set_target_properties(${name}_${type} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${include}")
  18. endif()
  19. endmacro(add_imported_library)
  20. macro(export_option name)
  21. list(APPEND EXPORTED_OPTIONS "${name}")
  22. endmacro(export_option)
  23. macro(export_target output TARGET)
  24. get_target_property(TYPE ${TARGET} TYPE)
  25. if(TYPE STREQUAL "SHARED_LIBRARY")
  26. get_target_property(LOCATION ${TARGET} IMPORTED_LOCATION)
  27. get_target_property(INCLUDE ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)
  28. set(${output} "${${output}}
  29. add_library(${TARGET} SHARED IMPORTED)
  30. set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION \"${LOCATION}\")
  31. set_target_properties(${TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${INCLUDE}\")
  32. ")
  33. elseif(TYPE STREQUAL "STATIC_LIBRARY")
  34. get_target_property(LOCATION ${TARGET} IMPORTED_LOCATION)
  35. get_target_property(INCLUDE ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)
  36. set(${output} "${${output}}
  37. add_library(${TARGET} STATIC IMPORTED)
  38. set_target_properties(${TARGET} PROPERTIES IMPORTED_LOCATION \"${LOCATION}\")
  39. set_target_properties(${TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${INCLUDE}\")
  40. ")
  41. if(NOT "${ARGN}" STREQUAL "")
  42. set(${output} "${${output}}set_target_properties(${TARGET} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES \"${ARGN}\")
  43. ")
  44. endif()
  45. elseif(TYPE STREQUAL "INTERFACE_LIBRARY")
  46. get_target_property(INCLUDE ${TARGET} INTERFACE_INCLUDE_DIRECTORIES)
  47. set(${output} "${${output}}
  48. add_library(${TARGET} INTERFACE IMPORTED)
  49. set_target_properties(${TARGET} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"${INCLUDE}\")
  50. ")
  51. else()
  52. message(STATUS "Unknown type ${TYPE}")
  53. endif()
  54. endmacro(export_target)