about summary refs log blame commit diff stats
path: root/CMakeLists.txt
blob: df0000af2a88a044aeaa690af419e989c518f904 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                      


                 
                                                                 
 

                                                     
                                                                       






                                                                           

                                                                                     






                                                                            




                                                                                                                                                                                  

                                    
 

                              

                                 

                                    
        
                                                                             
             
                                                                         
      
                                            



                                            
                                                                                                                    
                                                       


                                           
                                        
 






                                        
                           
                           
 
cmake_minimum_required(VERSION 3.26.0)

project(ytcpp
    LANGUAGES CXX
    VERSION 0.0.1
    HOMEPAGE_URL https://crow.port0.org/git/comradecrow/ytcpp.git
)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)

if(WIN32) # Install dlls in the same directory as the executable on Windows
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()

include(FetchContent)
FetchContent_Declare(ftxui GIT_REPOSITORY https://github.com/ArthurSonzogni/ftxui.git
                         GIT_TAG d301fab1f4ecdd3544ed99b9c98e647d5804c341)

FetchContent_GetProperties(ftxui)
if(NOT ftxui_POPULATED)
  FetchContent_Populate(ftxui)
  add_subdirectory(${ftxui_SOURCE_DIR} ${ftxui_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/libcpr/cpr.git
                         GIT_TAG c4713a704ca12237485ecbfec185f76c2a81bd09)

FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
                         URL_HASH SHA256=8c4b26bf4b422252e13f332bc5e388ec0ab5c3443d24399acb675e68278d341f) ##https://github.com/nlohmann/json/releases/latest/download/json.tar.xz

FetchContent_MakeAvailable(json cpr)

find_package(SQLite3 REQUIRED)

add_subdirectory(extern/pybind11)

find_package(Ytdlp REQUIRED RUNTIME)

if(UNIX)
    file(TO_CMAKE_PATH "$ENV{HOME}/.local/share/${PROJECT_NAME}" DEF_APPDATA)
elseif(WIN32)
    file(TO_CMAKE_PATH "$ENV{LOCALAPPDATA}\\${PROJECT_NAME}" DEF_APPDATA)
else()
    message(SEND_ERROR "OS not recognized!")
    file(TO_CMAKE_PATH "./data" DEF_APPDATA)
endif()


add_executable(${PROJECT_NAME} src/main.cpp src/tui.cpp src/invapi.cpp src/YtdlpWrapper.cpp src/sqliteinterface.cpp)
target_include_directories(${PROJECT_NAME} PRIVATE src)

target_compile_definitions(${PROJECT_NAME} 
    PRIVATE DEF_APPDATA="${DEF_APPDATA}"
    PRIVATE VERSION="${PROJECT_VERSION}"
)

target_link_libraries(${PROJECT_NAME} 
    PRIVATE cpr::cpr
    PRIVATE ftxui::screen
    PRIVATE ftxui::dom
    PRIVATE ftxui::component
    PRIVATE nlohmann_json::nlohmann_json
    PRIVATE SQLite::SQLite3
    PRIVATE pybind11::embed
)