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. yuzu.rc
  27. )
  28. create_target_directory_groups(yuzu-cmd)
  29. target_link_libraries(yuzu-cmd PRIVATE common core input_common frontend_common)
  30. target_link_libraries(yuzu-cmd PRIVATE glad)
  31. if (MSVC)
  32. target_link_libraries(yuzu-cmd PRIVATE getopt)
  33. endif()
  34. target_link_libraries(yuzu-cmd PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
  35. create_resource("../../dist/yuzu.bmp" "yuzu_cmd/yuzu_icon.h" "yuzu_icon")
  36. target_include_directories(yuzu-cmd PRIVATE ${RESOURCES_DIR})
  37. target_link_libraries(yuzu-cmd PRIVATE SDL2::SDL2 Vulkan::Headers)
  38. if(UNIX AND NOT APPLE)
  39. install(TARGETS yuzu-cmd)
  40. endif()
  41. if(WIN32)
  42. # compile as a win32 gui application instead of a console application
  43. if(MSVC)
  44. set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
  45. elseif(MINGW)
  46. set_target_properties(yuzu-cmd PROPERTIES LINK_FLAGS_RELEASE "-Wl,--subsystem,windows")
  47. endif()
  48. endif()
  49. if (MSVC)
  50. include(CopyYuzuSDLDeps)
  51. copy_yuzu_SDL_deps(yuzu-cmd)
  52. endif()
  53. if (YUZU_USE_PRECOMPILED_HEADERS)
  54. target_precompile_headers(yuzu-cmd PRIVATE precompiled_headers.h)
  55. endif()