54 lines
No EOL
1.5 KiB
CMake
54 lines
No EOL
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
project(simulator_qt LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTOUIC ON)
|
|
set(CMAKE_AUTORCC ON)
|
|
|
|
# Prefer Qt6, fall back to Qt5
|
|
find_package(Qt6 COMPONENTS Widgets QUIET)
|
|
if(NOT Qt6_FOUND)
|
|
# Try explicitly the system Qt6 cmake prefix on Debian/Ubuntu
|
|
find_package(Qt6 COMPONENTS Widgets QUIET PATHS /usr/lib/x86_64-linux-gnu)
|
|
endif()
|
|
|
|
if(NOT Qt6_FOUND)
|
|
# Fallback: try Qt5 if Qt6 is unavailable
|
|
find_package(Qt5 COMPONENTS Widgets QUIET)
|
|
endif()
|
|
|
|
if(Qt6_FOUND)
|
|
set(QT_LIB Qt6::Widgets)
|
|
elseif(Qt5_FOUND)
|
|
set(QT_LIB Qt5::Widgets)
|
|
else()
|
|
message(FATAL_ERROR "Qt6 or Qt5 not found. Install Qt development packages or set CMAKE_PREFIX_PATH to your Qt installation.")
|
|
endif()
|
|
|
|
set(GUI_SRCS
|
|
main.cpp
|
|
mainwindow.cpp
|
|
MachineController.cpp
|
|
)
|
|
|
|
set(GUI_HDRS
|
|
mainwindow.h
|
|
MachineController.h
|
|
)
|
|
|
|
add_executable(simulator_qt ${GUI_SRCS} ${GUI_HDRS})
|
|
|
|
# Allow the generated UI headers (from AUTOUIC) to be found in the build dir
|
|
# and also include the top-level include folder (works when added with add_subdirectory)
|
|
target_include_directories(simulator_qt PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/include)
|
|
|
|
# Link to core library target (must be defined by top-level CMake)
|
|
target_link_libraries(simulator_qt PRIVATE simulator_lib ${QT_LIB})
|
|
|
|
# Place runtime binary under repo/target/bin to match project layout
|
|
set_target_properties(simulator_qt PROPERTIES
|
|
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/target/bin
|
|
) |