CMakeLists.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # SPDX-FileCopyrightText: 2018 yuzu Emulator Project
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Credits to Samantas5855 and others for this function.
  4. function(create_resource file output filename)
  5. # Read hex data from file
  6. file(READ ${file} filedata HEX)
  7. # Convert hex data for C compatibility
  8. string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})
  9. # Write data to output file
  10. set(RESOURCES_DIR "${PROJECT_BINARY_DIR}/dist" PARENT_SCOPE)
  11. file(WRITE "${PROJECT_BINARY_DIR}/dist/${output}" "const unsigned char ${filename}[] = {${filedata}};\nconst unsigned ${filename}_size = sizeof(${filename});\n")
  12. endfunction()
  13. add_executable(yuzu-cmd
  14. emu_window/emu_window_sdl2.cpp
  15. emu_window/emu_window_sdl2.h
  16. emu_window/emu_window_sdl2_gl.cpp
  17. emu_window/emu_window_sdl2_gl.h
  18. emu_window/emu_window_sdl2_null.cpp
  19. emu_window/emu_window_sdl2_null.h
  20. emu_window/emu_window_sdl2_vk.cpp
  21. emu_window/emu_window_sdl2_vk.h
  22. precompiled_headers.h
  23. sdl_config.cpp
  24. sdl_config.h
  25. yuzu.cpp
  26. suyu.rc
  27. )
  28. target_link_libraries(yuzu-cmd PRIVATE common core input_common frontend_common)
  29. target_link_libraries(yuzu-cmd PRIVATE glad)
  30. if (MSVC)
  31. target_link_libraries(yuzu-cmd PRIVATE getopt)
  32. endif()
  33. target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
  34. create_resource("../../dist/suyu.bmp" "yuzu_cmd/yuzu_icon.h" "yuzu_icon")
  35. target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR})
  36. target_link_libraries(yuzu-cmd PRIVATE SDL2::SDL2 Vulkan::Headers)
  37. if(UNIX AND NOT APPLE)
  38. install(TARGETS yuzu-cmd)
  39. endif()
  40. if(WIN32)
  41. # compile as a win32 gui application instead of a console application
  42. if(MSVC)
  43. set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
  44. elseif(MINGW)
  45. set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "-Wl,--subsystem,windows")
  46. endif()
  47. endif()
  48. if (MSVC)
  49. include(CopyYuzuSDLDeps)
  50. copy_yuzu_SDL_deps(yuzu-cmd)
  51. endif()
  52. if (YUZU_USE_PRECOMPILED_HEADERS)
  53. target_precompile_headers(yuzu-cmd PRIVATE precompiled_headers.h)
  54. endif()
  55. create_target_directory_groups(yuzu-cmd)