CMakeLists.txt 2.2 KB

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