qt-chat-app

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

CMakeLists.txt (1776B)


      1 cmake_minimum_required(VERSION 3.16)
      2 
      3 project(demo VERSION 1.0.0 LANGUAGES CXX)
      4 
      5 set(CMAKE_CXX_STANDARD 17)
      6 set(CMAKE_CXX_STANDARD_REQUIRED ON)
      7 
      8 set(CMAKE_AUTOMOC ON)
      9 set(CMAKE_AUTORCC ON)
     10 set(CMAKE_AUTOUIC ON)
     11 
     12 # Find Qt components
     13 find_package(Qt6 COMPONENTS Widgets Qml Quick Network REQUIRED)
     14 
     15 # Add the resource file
     16 qt_add_resources(QRC_SOURCES qml.qrc)
     17 
     18 # CXX-Qt CMake integration
     19 include(FetchContent)
     20 FetchContent_Declare(
     21     Corrosion
     22     GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
     23     GIT_TAG v0.5
     24 )
     25 FetchContent_MakeAvailable(Corrosion)
     26 
     27 # Find CxxQt package (provided by cxx-qt-build)
     28 find_package(CxxQt QUIET)
     29 if(NOT CxxQt_FOUND)
     30     # Fall back to FetchContent if not found
     31     FetchContent_Declare(
     32         CxxQtCMake
     33         GIT_REPOSITORY https://github.com/KDAB/cxx-qt-cmake.git
     34         GIT_TAG main
     35     )
     36     FetchContent_MakeAvailable(CxxQtCMake)
     37 endif()
     38 
     39 # Import the Rust crate
     40 cxx_qt_import_crate(
     41     MANIFEST_PATH rust/Cargo.toml
     42     CRATES beegram_network
     43     QT_MODULES Qt6::Core Qt6::Network
     44 )
     45 
     46 # Create executable
     47 add_executable(demo
     48     main.cpp
     49     ${QRC_SOURCES}
     50 )
     51 
     52 # Ensure demo depends on the Rust crate being built first
     53 add_dependencies(demo beegram_network)
     54 
     55 target_link_libraries(demo
     56     Qt6::Widgets
     57     Qt6::Qml
     58     Qt6::Quick
     59     Qt6::Network
     60     beegram_network
     61 )
     62 
     63 # macOS: Link Security and SystemConfiguration frameworks for Rust crate
     64 if(APPLE)
     65     target_link_libraries(demo
     66         "-framework Security"
     67         "-framework SystemConfiguration"
     68         "-framework CoreFoundation"
     69     )
     70 endif()
     71 
     72 # Add CXX-Qt generated include directories
     73 target_include_directories(demo PRIVATE
     74     ${CMAKE_BINARY_DIR}/cargo/build/${Rust_CARGO_TARGET}/cxxbridge
     75 )
     76 
     77 # Install the binary
     78 install(TARGETS demo DESTINATION bin)