11cmake_minimum_required (VERSION 3.10)
2- set (CMAKE_EXPORT_COMPILE_COMMANDS 1)
2+
3+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
34set (CMAKE_CXX_STANDARD 17)
45set (CMAKE_CXX_STANDARD_REQUIRED ON )
56set (CMAKE_CXX_EXTENSIONS OFF )
67
8+ set (ASCII_VIDEO_VERSION_STRING "0.4.0" )
9+ set (ASCII_VIDEO_VERSION_MAJOR 0)
10+ set (ASCII_VIDEO_VERSION_MINOR 4)
11+ set (ASCII_VIDEO_VERSION_PATCH 0)
12+
13+ set (ASCII_VIDEO_SUPPORTED_LANGUAGES CXX C)
14+ if (APPLE )
15+ list (APPEND ASCII_VIDEO_SUPPORTED_LANGUAGES OBJC OBJCXX)
16+ endif ()
17+
718if (NOT CMAKE_BUILD_TYPE )
819 set (CMAKE_BUILD_TYPE Release)
920 message ("No Build Type Given, setting build type to Release" )
1021endif ()
11- message ("Building Build Type \" ${CMAKE_BUILD_TYPE} \" " )
22+ message ("Building Build Type: " ${CMAKE_BUILD_TYPE} )
1223
1324if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
1425 message (FATAL_ERROR "Building in-source is not supported! Create a build dir and run cmake from there" )
1526endif ()
1627
28+ project (ascii_video
29+ VERSION 0.4.0
30+ LANGUAGES ${ASCII_VIDEO_SUPPORTED_LANGUAGES}
31+ DESCRIPTION "Terminal video media player" )
32+
1733option (ASCII_VIDEO_BUILD_TESTS "Build Testing Executable for ascii_video" OFF )
34+ option (FALLBACK_BUILD_FROM_SHARED "Will build dependencies if the shared version is requested but is not found" ON )
35+ option (USE_SHARED_NCURSES "Use globally detected NCurses build" OFF )
36+ option (USE_SHARED_FFMPEG "Use globally detected FFmpeg" OFF )
37+ option (USE_SHARED_ALL "Use All Globally detected libraries" OFF )
38+
39+ option (BUILD_FFMPEG_AS_SHARED "Build FFmpeg Library as a shared library. " OFF )
40+ option (BUILD_NCURSES_AS_SHARED "Build NCurses as a shared library." OFF )
1841
1942if (ASCII_VIDEO_BUILD_TESTS)
2043 message ("Configured to build testing executable" )
2144else ()
2245 message ("Configured to NOT build testing executable" )
2346endif ()
2447
25- if (MSVC )
26- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17 /W4" )
27- endif (MSVC )
28-
29- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra" )
30- set (CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra" )
31- set (CMAKE_CXX_FLAGS_RELEASE "-O3" )
32-
33- project (ascii_video
34- VERSION 0.4.0
35- LANGUAGES CXX C
36- DESCRIPTION "Terminal video media player" )
37-
38- file (COPY assets DESTINATION ${CMAKE_BINARY_DIR} )
39- set (LOCAL_NCURSES_LIBRARIES_PATH ${CMAKE_SOURCE_DIR} /lib/build /ncurses-6.4/lib)
40- set (LOCAL_NCURSES_INCLUDE_PATH ${CMAKE_SOURCE_DIR} /lib/build /ncurses-6.4/include )
41-
42- if (EXISTS ${LOCAL_NCURSES_LIBRARIES_PATH} )
43- message ("FOUND LOCAL NCURSES MODULE" )
44- set (CURSES_LIBRARIES ${LOCAL_NCURSES_LIBRARIES_PATH} /libncurses.a)
45- set (CURSES_INCLUDE_DIR ${LOCAL_NCURSES_INCLUDE_PATH} ${LOCAL_NCURSES_INCLUDE_PATH} /ncurses)
48+ if (NOT USE_SHARED_ALL)
49+ add_subdirectory (${CMAKE_SOURCE_DIR} /lib)
4650else ()
4751 find_package (Curses REQUIRED)
52+ find_package (PkgConfig REQUIRED)
53+ pkg_check_modules(
54+ LIBAV REQUIRED IMPORTED_TARGET
55+ libavformat
56+ libavcodec
57+ libswresample
58+ libswscale
59+ libavutil
60+ )
4861endif ()
4962
50- find_package (PkgConfig REQUIRED)
51-
52- set (LOCAL_FFMPEG ${CMAKE_SOURCE_DIR} /lib/build /ffmpeg-6.0)
53- set (LOCAL_FFMPEG_LIB ${LOCAL_FFMPEG} /lib)
54- set (LOCAL_FFMPEG_INCLUDE ${LOCAL_FFMPEG} /include )
55- set (LOCAL_FFMPEG_PKG_CONFIG ${LOCAL_FFMPEG_LIB} /pkgconfig)
56-
57- if (EXISTS ${LOCAL_FFMPEG_PKG_CONFIG} )
58- message ("FOUND LOCAL FFMPEG PKG CONFIG" )
59- set (ENV{PKG_CONFIG_PATH} ${LOCAL_FFMPEG_PKG_CONFIG} )
60- endif ()
61-
62- pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET
63- libavformat
64- libavcodec
65- libswresample
66- libswscale
67- libavutil
68- )
69-
70- if (ASCII_VIDEO_BUILD_TESTS)
63+ if (ASCII_VIDEO_BUILD_TESTS)
7164 add_subdirectory (./lib/Catch2)
7265endif ()
7366
74- include_directories ( ${CURSES_INCLUDE_DIR} ./include ./lib/miniaudio ./lib/argparse )
75-
67+ add_library (miniaudio STATIC ./lib/miniaudio/miniaudio.c)
68+ target_include_directories (miniaudio PRIVATE ./lib/miniaudio)
69+
7670set (COMMON_SOURCE_FILES
77- ./lib/miniaudio/miniaudio.c
7871./src/audioresampler.cpp
7972./src/videoconverter.cpp
8073./src/streamdata.cpp
@@ -100,6 +93,20 @@ set(COMMON_SOURCE_FILES
10093./src/termcolor.cpp
10194)
10295
96+ message ("Curses Libraries found at " ${CURSES_LIBRARIES} )
97+
98+ add_executable (ascii_video ${COMMON_SOURCE_FILES} ./src/main.cpp)
99+ target_compile_features (ascii_video PRIVATE cxx_std_17)
100+ target_include_directories (ascii_video PRIVATE ${CURSES_INCLUDE_DIR} ./include ./lib/miniaudio ./lib/argparse )
101+ target_link_libraries (ascii_video PRIVATE PkgConfig::LIBAV ${CURSES_LIBRARIES} miniaudio)
102+ add_dependencies (ascii_video PkgConfig::LIBAV)
103+
104+ if (MSVC )
105+ target_compile_options (ascii_video PRIVATE /std:c++17 /W4 /WX)
106+ else ()
107+ target_compile_options (ascii_video PRIVATE -Wall -Wextra -Wpedantic) # Consider adding -Werror back
108+ endif ()
109+
103110set (TEST_SOURCE_FILES
104111./src/tests/test_audiobuffer.cpp
105112./src/tests/test_playback.cpp
@@ -110,12 +117,14 @@ set(TEST_SOURCE_FILES
110117./src/tests/test_formatting.cpp
111118)
112119
113- add_executable (ascii_video ${COMMON_SOURCE_FILES} ./src/main.cpp)
114- target_compile_features (ascii_video PRIVATE cxx_std_17)
115- target_link_libraries (ascii_video PkgConfig::LIBAV ${CURSES_LIBRARIES} )
116-
117120if (ASCII_VIDEO_BUILD_TESTS)
118- add_executable (tests ${COMMON_SOURCE_FILES} ${TEST_SOURCE_FILES} )
119- target_compile_features (tests PRIVATE cxx_std_17)
120- target_link_libraries (tests PRIVATE Catch2::Catch2WithMain ${CURSES_LIBRARIES} PkgConfig::LIBAV)
121+ add_executable (ascii_tests ${COMMON_SOURCE_FILES} ${TEST_SOURCE_FILES} )
122+ if (MSVC )
123+ target_compile_options (ascii_tests PRIVATE /std:c++17 /W4 /WX)
124+ else ()
125+ target_compile_options (ascii_tests PRIVATE -Wall -Wextra -Wpedantic)# Consider adding -Werror back
126+ endif ()
127+ target_include_directories (ascii_tests PRIVATE ${CURSES_INCLUDE_DIR} ./include ./lib/miniaudio ./lib/argparse )
128+ target_compile_features (ascii_tests PRIVATE cxx_std_17)
129+ target_link_libraries (ascii_tests PRIVATE Catch2::Catch2WithMain ${CURSES_LIBRARIES} PkgConfig::LIBAV miniaudio)
121130endif ()
0 commit comments