DetectMachine.cmake 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. IF(WIN32)
  2. SET(LMMS_BUILD_WIN32 1)
  3. ELSEIF(APPLE)
  4. SET(LMMS_BUILD_APPLE 1)
  5. ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
  6. SET(LMMS_BUILD_OPENBSD 1)
  7. ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
  8. SET(LMMS_BUILD_FREEBSD 1)
  9. ELSEIF(HAIKU)
  10. SET(LMMS_BUILD_HAIKU 1)
  11. ELSE()
  12. SET(LMMS_BUILD_LINUX 1)
  13. ENDIF(WIN32)
  14. # See build_mingwXX.sh for LMMS_BUILD_MSYS
  15. MESSAGE("PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
  16. SET(LMMS_HOST_X86 FALSE)
  17. SET(LMMS_HOST_X86_64 FALSE)
  18. IF(WIN32)
  19. IF(WIN64)
  20. SET(IS_X86_64 TRUE)
  21. SET(LMMS_BUILD_WIN64 TRUE)
  22. ELSE(WIN64)
  23. SET(IS_X86 TRUE)
  24. ENDIF(WIN64)
  25. ELSE(WIN32)
  26. EXEC_PROGRAM( ${CMAKE_C_COMPILER} ARGS "-dumpmachine ${CMAKE_C_FLAGS}" OUTPUT_VARIABLE Machine )
  27. MESSAGE("Machine: ${Machine}")
  28. STRING(REGEX MATCH "i.86" IS_X86 "${Machine}")
  29. STRING(REGEX MATCH "86_64|amd64" IS_X86_64 "${Machine}")
  30. ENDIF(WIN32)
  31. IF(IS_X86)
  32. MESSAGE("-- Target host is 32 bit")
  33. SET(LMMS_HOST_X86 TRUE)
  34. ELSEIF(IS_X86_64)
  35. MESSAGE("-- Target host is 64 bit")
  36. SET(LMMS_HOST_X86_64 TRUE)
  37. ELSE(IS_X86)
  38. MESSAGE("Can't identify target host. Assuming 32 bit platform.")
  39. ENDIF(IS_X86)
  40. IF(CMAKE_INSTALL_LIBDIR)
  41. SET(LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
  42. ELSE(CMAKE_INSTALL_LIBDIR)
  43. SET(LIB_DIR lib)
  44. ENDIF(CMAKE_INSTALL_LIBDIR)
  45. IF(LMMS_BUILD_WIN32)
  46. SET(BIN_DIR .)
  47. SET(PLUGIN_DIR plugins)
  48. SET(DATA_DIR data)
  49. SET(LMMS_DATA_DIR data)
  50. ELSE(LMMS_BUILD_WIN32)
  51. SET(BIN_DIR bin)
  52. SET(PLUGIN_DIR ${LIB_DIR}/lmms)
  53. SET(DATA_DIR share)
  54. SET(LMMS_DATA_DIR ${DATA_DIR}/lmms)
  55. ENDIF(LMMS_BUILD_WIN32)
  56. IF(LMMS_BUILD_APPLE)
  57. # Detect Homebrew versus Macports environment
  58. EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_HOMEBREW OUTPUT_VARIABLE HOMEBREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  59. EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  60. IF(${DETECT_HOMEBREW} EQUAL 0)
  61. SET(HOMEBREW 1)
  62. SET(APPLE_PREFIX "${HOMEBREW_PREFIX}")
  63. ELSEIF(${DETECT_MACPORTS} EQUAL 0)
  64. SET(MACPORTS 1)
  65. GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
  66. GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
  67. SET(APPLE_PREFIX "${MACPORTS_PREFIX}")
  68. LINK_DIRECTORIES(${LINK_DIRECTORIES} ${APPLE_PREFIX}/lib)
  69. ENDIF()
  70. # Detect OS Version
  71. EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE APPLE_OS_VER ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  72. STRING(REGEX REPLACE "\\.[0-9]*$" "" APPLE_OS_VER "${APPLE_OS_VER}")
  73. SET(CMAKE_MACOSX_RPATH 1)
  74. ENDIF()