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.

67 lines
2.0 KiB

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. # Find all the modules
  30. file(GLOB_RECURSE modules src/*.cppm)
  31. # Create the executable target
  32. add_executable(ffmpegraph)
  33. # Main file
  34. target_sources(ffmpegraph
  35. PUBLIC
  36. src/main.cpp
  37. )
  38. # The modules
  39. target_sources(ffmpegraph
  40. PUBLIC
  41. FILE_SET CXX_MODULES FILES
  42. ${modules}
  43. )
  44. #Compile flags
  45. target_compile_options(ffmpegraph PRIVATE
  46. -Wall -Wextra # Standard screaming
  47. -Wconversion -Wsign-conversion # Scream about accidentally converting stuff
  48. -Werror=return-type # Scream extra hard at not returning when you should.
  49. # Target detection black magic
  50. $<$<CONFIG:DEBUG>:-O0 -g3 -glldb>
  51. $<$<CONFIG:RELEASE>:-O3 -march=native>
  52. )
  53. # color shit out
  54. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  55. target_compile_options(ffmpegraph PRIVATE -fdiagnostics-color=always)
  56. elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  57. target_compile_options(ffmpegraph PRIVATE -fcolor-diagnostics)
  58. endif()
  59. # Link against exernal libraries
  60. target_link_libraries(ffmpegraph PRIVATE raylib m)
  61. target_include_directories(ffmpegraph PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libs/clopts/include")