CMakeLists.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. cmake_minimum_required(VERSION 3.1)
  2. project(RemoteVstPlugin
  3. LANGUAGES CXX)
  4. set(CMAKE_CXX_STANDARD 11)
  5. include(CheckCXXPreprocessor)
  6. include(CheckCXXSourceCompiles)
  7. CHECK_CXX_DEFINE(IS_WIN "_WIN32")
  8. CHECK_CXX_DEFINE(IS_WIN64 "_WIN64")
  9. CHECK_CXX_DEFINE(IS_MINGW "__MINGW32__")
  10. if(NOT IS_WIN)
  11. message(FATAL_ERROR "Toolchain used does not target windows.")
  12. ENDIF()
  13. if(IS_WIN64 OR CMAKE_SIZEOF_VOID_P EQUAL 8)
  14. set(BITNESS 64)
  15. else()
  16. set(BITNESS 32)
  17. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/32")
  18. endif()
  19. FOREACH( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
  20. STRING(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
  21. SET("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
  22. ENDFOREACH()
  23. set(EXE_NAME RemoteVstPlugin${BITNESS})
  24. add_executable(${EXE_NAME} WIN32
  25. ../RemoteVstPlugin.cpp
  26. )
  27. target_link_libraries(${EXE_NAME} ole32)
  28. target_include_directories(${EXE_NAME}
  29. PRIVATE
  30. "${LMMS_SOURCE_DIR}/plugins/vst_base/common"
  31. "${LMMS_SOURCE_DIR}/include"
  32. "${LMMS_BINARY_DIR}"
  33. )
  34. # Workaround for missing WinMain
  35. if(MSVC)
  36. set_property(TARGET ${EXE_NAME}
  37. APPEND
  38. PROPERTY LINK_FLAGS "/entry:mainCRTStartup"
  39. )
  40. endif()
  41. if(WIN32)
  42. find_package(Qt5Core REQUIRED)
  43. target_link_libraries(${EXE_NAME} Qt5::Core)
  44. endif()
  45. if(IS_MINGW)
  46. SET(CMAKE_REQUIRED_FLAGS "-std=c++14")
  47. CHECK_CXX_SOURCE_COMPILES("
  48. #include <mutex>
  49. int main(int argc, const char* argv[]) {
  50. std::mutex m;
  51. return 0;
  52. }
  53. " HAS_STD_MUTEX)
  54. if(NOT HAS_STD_MUTEX)
  55. target_include_directories(${EXE_NAME} PRIVATE
  56. "${LMMS_SOURCE_DIR}/src/3rdparty/mingw-std-threads")
  57. target_compile_definitions(${EXE_NAME} PRIVATE
  58. -DUSE_MINGW_THREADS_REPLACEMENT)
  59. endif()
  60. endif()
  61. IF(STRIP)
  62. ADD_CUSTOM_COMMAND(TARGET ${EXE_NAME} POST_BUILD COMMAND "${STRIP}" "$<TARGET_FILE:${EXE_NAME}>")
  63. ENDIF()
  64. if(BITNESS EQUAL 32)
  65. INSTALL(TARGETS ${EXE_NAME} RUNTIME DESTINATION "${PLUGIN_DIR}/32")
  66. else()
  67. INSTALL(TARGETS ${EXE_NAME} RUNTIME DESTINATION "${PLUGIN_DIR}")
  68. endif()
  69. if(BUILD_WITH_EXTERNALPROJECT)
  70. include(InstallTargetDependencies)
  71. INSTALL_TARGET_DEPENDENCIES(TARGETS ${EXE_NAME}
  72. DESTINATION "${PLUGIN_DIR}/32")
  73. else()
  74. # Needed to deploy dependencies of RemoteVstPlugin
  75. SET_PROPERTY(GLOBAL APPEND PROPERTY PLUGINS_BUILT "${EXE_NAME}")
  76. endif()