DetectMachine.cmake 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. # LMMS_BUILD_MSYS also set in build_winXX.sh
  15. IF(LMMS_BUILD_WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND DEFINED ENV{MSYSCON})
  16. SET(LMMS_BUILD_MSYS TRUE)
  17. ENDIF()
  18. MESSAGE("PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
  19. SET(LMMS_HOST_X86 FALSE)
  20. SET(LMMS_HOST_X86_64 FALSE)
  21. IF(NOT DEFINED WIN64 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
  22. SET(WIN64 ON)
  23. ENDIF()
  24. IF(WIN32)
  25. IF(WIN64)
  26. SET(IS_X86_64 TRUE)
  27. SET(LMMS_BUILD_WIN64 TRUE)
  28. ELSE(WIN64)
  29. SET(IS_X86 TRUE)
  30. ENDIF(WIN64)
  31. if(MSVC)
  32. SET(MSVC_VER ${CMAKE_CXX_COMPILER_VERSION})
  33. IF(MSVC_VER VERSION_GREATER 19.20 OR MSVC_VER VERSION_EQUAL 19.20)
  34. SET(LMMS_MSVC_GENERATOR "Visual Studio 16 2019")
  35. SET(LMMS_MSVC_YEAR 2019) # Qt only provides binaries for MSVC 2017, but 2019 is binary compatible
  36. ELSEIF(MSVC_VER VERSION_GREATER 19.10 OR MSVC_VER VERSION_EQUAL 19.10)
  37. SET(LMMS_MSVC_GENERATOR "Visual Studio 15 2017")
  38. SET(LMMS_MSVC_YEAR 2017)
  39. ELSEIF(MSVC_VER VERSION_GREATER 19.0 OR MSVC_VER VERSION_EQUAL 19.0)
  40. SET(LMMS_MSVC_GENERATOR "Visual Studio 14 2015")
  41. SET(LMMS_MSVC_YEAR 2015)
  42. ELSE()
  43. MESSAGE(SEND_WARNING "Can't detect MSVC version: ${MSVC_VER}")
  44. ENDIF()
  45. unset(MSVC_VER)
  46. endif()
  47. ELSE(WIN32)
  48. EXEC_PROGRAM( ${CMAKE_C_COMPILER} ARGS "-dumpmachine ${CMAKE_C_FLAGS}" OUTPUT_VARIABLE Machine )
  49. MESSAGE("Machine: ${Machine}")
  50. STRING(REGEX MATCH "i.86" IS_X86 "${Machine}")
  51. STRING(REGEX MATCH "86_64|amd64" IS_X86_64 "${Machine}")
  52. ENDIF(WIN32)
  53. IF(IS_X86)
  54. MESSAGE("-- Target host is 32 bit")
  55. SET(LMMS_HOST_X86 TRUE)
  56. ELSEIF(IS_X86_64)
  57. MESSAGE("-- Target host is 64 bit")
  58. SET(LMMS_HOST_X86_64 TRUE)
  59. ELSE(IS_X86)
  60. MESSAGE("Can't identify target host. Assuming 32 bit platform.")
  61. ENDIF(IS_X86)
  62. IF(CMAKE_INSTALL_LIBDIR)
  63. SET(LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
  64. ELSE(CMAKE_INSTALL_LIBDIR)
  65. SET(LIB_DIR lib)
  66. ENDIF(CMAKE_INSTALL_LIBDIR)
  67. IF(LMMS_BUILD_WIN32)
  68. SET(BIN_DIR .)
  69. SET(PLUGIN_DIR plugins)
  70. SET(DATA_DIR data)
  71. SET(LMMS_DATA_DIR data)
  72. ELSE(LMMS_BUILD_WIN32)
  73. SET(BIN_DIR bin)
  74. SET(PLUGIN_DIR ${LIB_DIR}/lmms)
  75. SET(DATA_DIR share)
  76. SET(LMMS_DATA_DIR ${DATA_DIR}/lmms)
  77. ENDIF(LMMS_BUILD_WIN32)
  78. IF(LMMS_BUILD_APPLE)
  79. # Detect Homebrew versus Macports environment
  80. EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_HOMEBREW OUTPUT_VARIABLE HOMEBREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  81. EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  82. IF(${DETECT_HOMEBREW} EQUAL 0)
  83. SET(HOMEBREW 1)
  84. SET(APPLE_PREFIX "${HOMEBREW_PREFIX}")
  85. ELSEIF(${DETECT_MACPORTS} EQUAL 0)
  86. SET(MACPORTS 1)
  87. GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
  88. GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
  89. SET(APPLE_PREFIX "${MACPORTS_PREFIX}")
  90. LINK_DIRECTORIES(${LINK_DIRECTORIES} ${APPLE_PREFIX}/lib)
  91. ENDIF()
  92. # Detect OS Version
  93. EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE APPLE_OS_VER ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
  94. STRING(REGEX REPLACE "\\.[0-9]*$" "" APPLE_OS_VER "${APPLE_OS_VER}")
  95. SET(CMAKE_MACOSX_RPATH 1)
  96. ENDIF()