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

# Needs CMake 3.28 for module
cmake_minimum_required(VERSION 3.28)
message(STATUS "Create project")
project(ffmpegraph CXX)
set(CMAKE_CXX_STANDARD 26)
# Use mold as the default linker, if it exists.
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
find_program(MOLD_LINKER "mold")
if (MOLD_LINKER)
add_link_options(-fuse-ld=mold)
message(STATUS "Setting linker to mold")
endif()
endif()
include(FetchContent)
message(STATUS "Fetching raylib")
FetchContent_Declare(raylib
GIT_REPOSITORY https://github.com/raysan5/raylib
GIT_TAG 5.0
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/raylib"
)
FetchContent_MakeAvailable(raylib)
message(STATUS "Fetching clopts")
FetchContent_Declare(clopts
GIT_REPOSITORY https://github.com/Sirraide/clopts.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/clopts"
)
FetchContent_MakeAvailable(clopts)
FetchContent_Declare(json
URL https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libs/json"
)
FetchContent_MakeAvailable(json)
message(STATUS "Looking for files")
file(GLOB_RECURSE modules src/*.cppm)
file(GLOB_RECURSE headers src/*.hpp)
file(GLOB_RECURSE impls src/*.cpp)
message(STATUS "Create target")
add_executable(ffmpegraph ${impls})
target_sources(ffmpegraph PUBLIC
FILE_SET CXX_MODULES FILES ${modules}
FILE_SET HEADERS FILES ${headers}
)
target_compile_options(ffmpegraph PRIVATE
-Wall -Wextra # Standard screaming
-Wconversion -Wsign-conversion # Scream about accidentally converting stuff
-Werror=return-type # Scream extra hard at not returning when you should.
# Target detection black magic
$<$<CONFIG:DEBUG>:-O0 -g3 -glldb>
$<$<CONFIG:RELEASE>:-O3 -march=native>
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(ffmpegraph PRIVATE -fdiagnostics-color=always)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(ffmpegraph PRIVATE -fcolor-diagnostics)
endif()
target_link_libraries(ffmpegraph PRIVATE raylib m nlohmann_json::nlohmann_json)
target_include_directories(ffmpegraph PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/libs/clopts/include")