pflagerd / candle2

GRBL control interface in Qt.
GNU General Public License v3.0
0 stars 0 forks source link

Convert from qmake to cmake build #3

Closed pflagerd closed 3 months ago

pflagerd commented 3 months ago

As of 5478ab99031416bf3642e0d437ce11e08be1e1a7

pflagerd commented 3 months ago

Starting from this ChatGPT 4o generated source:

cmake_minimum_required(VERSION 3.14)
project(MyQtProject)

# Enable CMake's AUTOMOC, AUTOUIC, and AUTORCC features
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

# Find the Qt libraries
find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED)

# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add the source files
set(SOURCES
    main.cpp
    mainwindow.cpp
    otherfile.cpp
    resources.qrc # Add the resource file here
)

# Add the header files
set(HEADERS
    mainwindow.h
    otherfile.h
)

# Add the UI files
set(UIS
    mainwindow.ui
)

# Add the executable
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${UIS})

# Link the Qt libraries
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets)

# Include additional directories if necessary
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

# Link additional libraries if needed
find_package(Qt5 COMPONENTS Network REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::Network)
pflagerd commented 3 months ago

As of 0886e07328fdfb7a03cf113fb6927baca8f0a327 it seems to work.

pflagerd commented 3 months ago

Works with clion also.