CMakeLists.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. # Source files and their filters
  2. include(CMakeSources.cmake)
  3. # Target
  4. if(WIN32)
  5. add_executable(Game WIN32 ${BS_GAME_SRC} Game.rc)
  6. else()
  7. add_executable(Game ${BS_GAME_SRC})
  8. endif()
  9. # Common flags
  10. add_common_flags(Game)
  11. # Includes
  12. target_include_directories(Game PRIVATE "./")
  13. # Post-build step
  14. # TODO: Use CMAKE_SYSTEM_NAME and BS_64BIT?
  15. if(WIN32)
  16. if(BS_64BIT)
  17. set(BS_COPY_FOLDER Win64)
  18. else()
  19. set(BS_COPY_FOLDER Win32)
  20. endif()
  21. elseif(LINUX)
  22. if(BS_64BIT)
  23. set(BS_COPY_FOLDER Linux64)
  24. else()
  25. set(BS_COPY_FOLDER Linux32)
  26. endif()
  27. else()
  28. # TODO_OTHER_PLATFORMS_GO_HERE
  29. endif()
  30. if (BS_COPY_FOLDER)
  31. set(DST_FOLDER ${PROJECT_SOURCE_DIR}/Data/Binaries/${BS_COPY_FOLDER})
  32. add_custom_command(
  33. TARGET Game POST_BUILD
  34. COMMAND ${CMAKE_COMMAND} -E make_directory "${DST_FOLDER}"
  35. COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:Game>" "${DST_FOLDER}")
  36. endif()
  37. # Libraries
  38. ## Local libs
  39. target_link_libraries(Game bsfScript bsfMono bsf)
  40. # IDE specific
  41. set_property(TARGET Game PROPERTY FOLDER Executable)
  42. # Plugin dependencies
  43. add_engine_dependencies(Game)
  44. # Compiler flags
  45. if(MSVC)
  46. target_compile_options(Game PUBLIC /wd4509)
  47. endif()
  48. # Install
  49. set(PLATFORM_PATH_PREFIX "")
  50. if(WIN32)
  51. set(PLATFORM_PATH_PREFIX "Win")
  52. elseif(LINUX)
  53. set(PLATFORM_PATH_PREFIX "Linux")
  54. elseif(APPLE)
  55. set(PLATFORM_PATH_PREFIX "macOS")
  56. else()
  57. message(FATAL "Unsupported platform.")
  58. endif()
  59. if(BS_64BIT)
  60. set(PLATFORM_PATH_PREFIX "${PLATFORM_PATH_PREFIX}64")
  61. endif()
  62. install(
  63. TARGETS Game
  64. RUNTIME DESTINATION EditorData/Binaries/${PLATFORM_PATH_PREFIX}
  65. )