You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
2.2 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. # Needs CMake 3.28 for module
  2. cmake_minimum_required(VERSION 3.28)
  3. message(STATUS "Create project")
  4. project(ffmpegraph CXX)
  5. set(CMAKE_CXX_STANDARD 26)
  6. # Use mold as the default linker, if it exists.
  7. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  8. find_program(MOLD_LINKER "mold")
  9. if (MOLD_LINKER)
  10. add_link_options(-fuse-ld=mold)
  11. message(STATUS "Setting linker to mold")
  12. endif()
  13. endif()
  14. include(FetchContent)
  15. message(STATUS "Fetching raylib")
  16. FetchContent_Declare(raylib
  17. GIT_REPOSITORY https://github.com/raysan5/raylib
  18. GIT_TAG 5.0
  19. SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/raylib"
  20. )
  21. FetchContent_MakeAvailable(raylib)
  22. message(STATUS "Fetching clopts")
  23. FetchContent_Declare(clopts
  24. GIT_REPOSITORY https://github.com/Sirraide/clopts.git
  25. GIT_TAG master
  26. SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/clopts"
  27. )
  28. FetchContent_MakeAvailable(clopts)
  29. FetchContent_Declare(json
  30. URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
  31. SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/json"
  32. )
  33. FetchContent_MakeAvailable(json)
  34. message(STATUS "Looking for files")
  35. file(GLOB_RECURSE modules src/*.cppm)
  36. file(GLOB_RECURSE headers src/*.hpp)
  37. file(GLOB_RECURSE impls src/*.cpp)
  38. message(STATUS "Create target")
  39. add_executable(ffmpegraph ${impls})
  40. target_sources(ffmpegraph PUBLIC
  41. FILE_SET CXX_MODULES FILES ${modules}
  42. FILE_SET HEADERS FILES ${headers}
  43. )
  44. target_compile_options(ffmpegraph PRIVATE
  45. -Wall -Wextra # Standard screaming
  46. -Wconversion -Wsign-conversion # Scream about accidentally converting stuff
  47. -Werror=return-type # Scream extra hard at not returning when you should.
  48. # Target detection black magic
  49. $<$<CONFIG:DEBUG>:-O0 -g3 -glldb>
  50. $<$<CONFIG:RELEASE>:-O3 -march=native>
  51. )
  52. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  53. target_compile_options(ffmpegraph PRIVATE -fdiagnostics-color=always)
  54. elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  55. target_compile_options(ffmpegraph PRIVATE -fcolor-diagnostics)
  56. endif()
  57. target_link_libraries(ffmpegraph PRIVATE raylib m nlohmann_json::nlohmann_json)
  58. target_include_directories(ffmpegraph PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libs/clopts/include")