FindLpeg.cmake (822B)
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 12 find_package_handle_standard_args(Lpeg DEFAULT_MSG LPEG_LIBRARY) 13 mark_as_advanced(LPEG_LIBRARY) 14 15 # Workaround: use an imported library to prevent cmake from modifying library 16 # link path. See #23395. 17 add_library(lpeg UNKNOWN IMPORTED) 18 set_target_properties(lpeg PROPERTIES IMPORTED_LOCATION ${LPEG_LIBRARY})