FindWine.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # - Try to find the wine libraries
  2. # Once done this will define
  3. #
  4. # WINE_FOUND - System has wine
  5. # WINE_INCLUDE_DIRS - The wine include directories
  6. # WINE_LIBRARIES - The libraries needed to use wine
  7. # WINE_DEFINITIONS - Compiler switches required for using wine
  8. #
  9. LIST(APPEND CMAKE_PREFIX_PATH /opt/wine-stable /opt/wine-devel /opt/wine-staging)
  10. FIND_PATH(WINE_INCLUDE_DIR windows/windows.h PATH_SUFFIXES wine wine/wine)
  11. FIND_LIBRARY(WINE_LIBRARY NAMES wine PATH_SUFFIXES wine i386-linux-gnu/wine)
  12. FIND_PROGRAM(WINE_CXX NAMES wineg++ winegcc winegcc64 winegcc32)
  13. set(WINE_INCLUDE_DIRS ${WINE_INCLUDE_DIR} )
  14. set(WINE_LIBRARIES ${WINE_LIBRARY} )
  15. # Handle wine linking problems
  16. EXEC_PROGRAM(${WINE_CXX} ARGS "-v -m32 /dev/zero" OUTPUT_VARIABLE WINEBUILD_OUTPUT)
  17. STRING(REPLACE " " ";" WINEBUILD_FLAGS "${WINEBUILD_OUTPUT}")
  18. FOREACH(FLAG ${WINEBUILD_FLAGS})
  19. IF("${FLAG}" MATCHES "libwinecrt0.a.*")
  20. # Debian systems
  21. STRING(REPLACE "/lib/x86_64-" "/lib/i386-" FLAG "${FLAG}")
  22. # Fedora systems
  23. STRING(REPLACE "/lib/lib64" "/lib/i386" FLAG "${FLAG}")
  24. # Gentoo systems
  25. STRING(REPLACE "/lib/wine-" "/lib32/wine-" FLAG "${FLAG}")
  26. # WineHQ (/opt/wine-stable, /opt/wine-devel, /opt/wine-staging)
  27. STRING(REPLACE "/lib64/wine/" "/lib/wine/" FLAG "${FLAG}")
  28. STRING(REGEX REPLACE "/wine/libwinecrt0.a.*" "" WINE_LIBRARY_FIX "${FLAG}")
  29. SET(WINE_LIBRARY_FIX "${WINE_LIBRARY_FIX}/")
  30. ENDIF()
  31. ENDFOREACH()
  32. include(FindPackageHandleStandardArgs)
  33. find_package_handle_standard_args(Wine DEFAULT_MSG WINE_LIBRARIES WINE_INCLUDE_DIRS)
  34. mark_as_advanced(WINE_INCLUDE_DIR WINE_LIBRARY)