sentinal-test/CMakeLists.txt
2024-08-04 18:07:03 -06:00

136 lines
3.4 KiB
CMake

cmake_minimum_required(VERSION 3.24)
set(PROJECT_NAME Sentinal)
project(${PROJECT_NAME} LANGUAGES CXX)
set(project_version_major 0)
set(project_version_minor 0)
set(project_version_patch 1)
set(project_version_tweak 0)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Make sure this is here for nvim and fleet users
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# # # # # # # # # # # #
# Manage Dependencies #
# # # # # # # # # # # #
include(ExternalProject)
ExternalProject_Add(
imgui
GIT_REPOSITORY https://github.com/ocornut/imgui.git
GIT_TAG master
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
ExternalProject_Get_Property(imgui source_dir)
file(GLOB imgui_sources
"${source_dir}/*.cpp"
"${source_dir}/*.h"
)
add_library(imgui STATIC ${imgui_sources})
target_include_directories(imgui PUBLIC ${source_dir})
ExternalProject_Add(
ffmpeg
GIT_REPOSITORY https://github.com/FFmpeg/FFmpeg.git
GIT_TAG master
UPDATE_COMMAND ""
CONFIGURE_COMMAND ./configure --prefix=<INSTALL_DIR> --enable-shared --disable-static
BUILD_COMMAND make
INSTALL_COMMAND make install
BUILD_IN_SOURCE 1
)
ExternalProject_Get_Property(ffmpeg install_dir)
set(FFMPEG_INCLUDE_DIR ${install_dir}/include)
set(FFMPEG_LIB_DIR ${install_dir}/lib)
set(FFMPEG_BIN_DIR ${install_dir}/bin)
add_library(avcodec SHARED IMPORTED)
set_target_properties(avcodec PROPERTIES
IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libavcodec.so
INTERFACE_INCLUDE_DIRECTORIES ${FFMPEG_INCLUDE_DIR}
)
add_library(avformat SHARED IMPORTED)
set_target_properties(avformat PROPERTIES
IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libavformat.so
INTERFACE_INCLUDE_DIRECTORIES ${FFMPEG_INCLUDE_DIR}
)
add_library(avutil SHARED IMPORTED)
set_target_properties(avutil PROPERTIES
IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libavutil.so
INTERFACE_INCLUDE_DIRECTORIES ${FFMPEG_INCLUDE_DIR}
)
add_library(swscale SHARED IMPORTED)
set_target_properties(swscale PROPERTIES
IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libswscale.so
INTERFACE_INCLUDE_DIRECTORIES ${FFMPEG_INCLUDE_DIR}
)
add_library(FFmpeg::avcodec ALIAS avcodec)
add_library(FFmpeg::avformat ALIAS avformat)
add_library(FFmpeg::avutil ALIAS avutil)
add_library(FFmpeg::swscale ALIAS swscale)
# Add GLFW and GLEW as subdirectories if they have their own CMake files
add_subdirectory(thirdparty/glfw)
add_subdirectory(thirdparty/glew-cmake)
# # # # # # # # # # # #
# Dependencies Done #
# # # # # # # # # # # #
if(APPLE)
list(APPEND EXTRA_LIBS "-framework OpenGL")
elseif(WIN32)
find_package(OpenGL REQUIRED)
else()
list(APPEND EXTRA_LIBS "-lGL -lGLU -lX11")
endif()
# ImGui glfw backends (GLFW + OpenGL3)
add_library(imgui_impl STATIC
thirdparty/imgui/backends/imgui_impl_glfw.cpp
thirdparty/imgui/backends/imgui_impl_opengl3.cpp
)
target_include_directories(imgui_impl PRIVATE
thirdparty/imgui
thirdparty/imgui/backends
thirdparty/glfw/include
)
include_directories(
thirdparty/imgui
thirdparty/imgui/backends
thirdparty/glfw/include
thirdparty/glew-cmake/include
)
set(glew-cmake_BUILD_SHARED OFF)
set(glew-cmake_BUILD_STATIC ON)
add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE imgui FFmpeg::avcodec FFmpeg::avformat FFmpeg::avutil FFmpeg::swscale glfw glew)
add_dependencies(${PROJECT_NAME} ffmpeg)
set_target_properties(${PROJECT_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)