FindLpeg.cmake 822 B

12345678910111213141516171819
  1. find_library2(LPEG_LIBRARY NAMES lpeg_a lpeg liblpeg_a lpeg.so lpeg${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
  2. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND LPEG_LIBRARY MATCHES ".so$")
  3. execute_process(
  4. COMMAND otool -hv "${LPEG_LIBRARY}"
  5. OUTPUT_VARIABLE LPEG_HEADER
  6. )
  7. if(LPEG_HEADER MATCHES ".* BUNDLE .*")
  8. message(FATAL_ERROR "lpeg library found at ${LPEG_LIBRARY} but built as a bundle rather than a dylib, please rebuild with `-dynamiclib` rather than `-bundle`")
  9. endif()
  10. endif()
  11. find_package_handle_standard_args(Lpeg DEFAULT_MSG LPEG_LIBRARY)
  12. mark_as_advanced(LPEG_LIBRARY)
  13. # Workaround: use an imported library to prevent cmake from modifying library
  14. # link path. See #23395.
  15. add_library(lpeg UNKNOWN IMPORTED)
  16. set_target_properties(lpeg PROPERTIES IMPORTED_LOCATION ${LPEG_LIBRARY})