Skip to content

Commit

Permalink
chore(cpn): cmake use automoc and autouic (#4258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Horne authored Oct 28, 2023
1 parent e8d555d commit 9dd4a1e
Show file tree
Hide file tree
Showing 11 changed files with 375 additions and 423 deletions.
16 changes: 16 additions & 0 deletions cmake/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,19 @@ function(AddHWGenTarget input template output)
DEPENDS ${INPUT_JSON} ${LEGACY_JSON} ${TEMPLATE}
)
endfunction()

macro(AddHeadersSources)
foreach(name
${${PROJECT_NAME}_NAMES})

set(${PROJECT_NAME}_SRCS
${${PROJECT_NAME}_SRCS}
${name}.cpp
)

set(${PROJECT_NAME}_HDRS
${${PROJECT_NAME}_HDRS}
${name}.h
)
endforeach()
endmacro()
3 changes: 3 additions & 0 deletions cmake/QtDefs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ if(APPLE AND EXISTS /usr/local/opt/qt5)
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt5")
endif()

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)

find_package(Qt5Core)
find_package(Qt5Widgets)
find_package(Qt5Xml)
Expand Down
137 changes: 54 additions & 83 deletions companion/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ qt5_add_resources(common_RCC ${common_RESOURCES})
add_library(common ${common_SRCS} ${common_RCC})

target_link_libraries(common
datamodels
firmwares
storage
shared
simulation
storage
maxLibQt
Qt5::Core
Qt5::Xml
Expand All @@ -188,9 +190,9 @@ include(FetchMaxLibQt)

add_subdirectory(datamodels)
add_subdirectory(firmwares)
add_subdirectory(shared)
add_subdirectory(modeledit)
add_subdirectory(generaledit)
add_subdirectory(modeledit)
add_subdirectory(shared)
add_subdirectory(simulation)
add_subdirectory(storage)
add_subdirectory(thirdparty/qcustomplot)
Expand All @@ -200,96 +202,65 @@ add_subdirectory(updates)

include_directories(${maxLibQt_SOURCE_DIR}/widgets)

set(companion_SRCS
helpers_html.cpp
mdichild.cpp
modelslist.cpp
labels.cpp
apppreferencesdialog.cpp
burnconfigdialog.cpp
multimodelprinter.cpp
comparedialog.cpp
customizesplashdialog.cpp
radiointerface.cpp
progresswidget.cpp
progressdialog.cpp
process_copy.cpp
process_flash.cpp
process_sync.cpp
flashfirmwaredialog.cpp
flasheepromdialog.cpp
printdialog.cpp
modelprinter.cpp
logsdialog.cpp
splashlibrarydialog.cpp
mainwindow.cpp
companion.cpp
radionotfound.cpp
wizarddata.cpp
wizarddialog.cpp
styleeditdialog.cpp
dialogs/filesyncdialog.cpp # TODO move to own lib with other dialogs
profilechooser.cpp
set(companion_NAMES
apppreferencesdialog
burnconfigdialog
comparedialog
customizesplashdialog
flasheepromdialog
flashfirmwaredialog
helpers_html
labels
logsdialog
mainwindow
mdichild
modelprinter
modelslist
multimodelprinter
printdialog
process_copy
process_flash
process_sync
profilechooser
progressdialog
progresswidget
radiointerface
radionotfound
splashlibrarydialog
styleeditdialog
wizarddata
wizarddialog
dialogs/filesyncdialog
)

set(companion_MOC_HDRS
apppreferencesdialog.h
burnconfigdialog.h
comparedialog.h
printdialog.h
logsdialog.h
customizesplashdialog.h
splashlibrarydialog.h
splashlabel.h
progresswidget.h
progressdialog.h
process_copy.h
process_flash.h
process_sync.h
flashfirmwaredialog.h
flasheepromdialog.h
mdichild.h
mainwindow.h
radionotfound.h
wizarddialog.h
modelprinter.h
multimodelprinter.h
modelslist.h
labels.h
styleeditdialog.h
helpers_html.h
dialogs/filesyncdialog.h
profilechooser.h
foreach(name ${companion_NAMES})
set(companion_SRCS
${companion_SRCS}
${name}.cpp
)

set(companion_UIS
mdichild.ui
comparedialog.ui
logsdialog.ui
apppreferencesdialog.ui
burnconfigdialog.ui
printdialog.ui
htmldialog.ui
customizesplashdialog.ui
splashlibrarydialog.ui
progresswidget.ui
progressdialog.ui
flashfirmwaredialog.ui
flasheepromdialog.ui
radionotfound.ui
styleeditdialog.ui
profilechooser.ui
set(companion_HDRS
${companion_HDRS}
${name}.h
)
endforeach()

set(companion_SRCS
${companion_SRCS}
companion.cpp
)

set(companion_HDRS
${companion_HDRS}
splashlabel.h
)

if(WIN32)
set(icon_RC images/winicons/icon.rc)
endif()

qt5_wrap_ui(companion_SRCS ${companion_UIS})
qt5_wrap_cpp(companion_SRCS ${companion_MOC_HDRS})

add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS} ${icon_RC})
target_link_libraries(${COMPANION_NAME} PRIVATE generaledit modeledit qcustomplot miniz shared updates ${CPN_COMMON_LIB})
add_executable(${COMPANION_NAME} MACOSX_BUNDLE ${WIN_EXECUTABLE_TYPE} ${companion_SRCS} ${companion_HDRS} ${icon_RC})
target_link_libraries(${COMPANION_NAME} PRIVATE ${CPN_COMMON_LIB} generaledit modeledit qcustomplot miniz updates)

PrintTargetReport("${COMPANION_NAME}")

Expand Down
26 changes: 15 additions & 11 deletions companion/src/datamodels/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@

set(datamodels_SRCS
compounditemmodels.cpp
filtereditemmodels.cpp
)
project(datamodels)

set(datamodels_HDRS
compounditemmodels.h
filtereditemmodels.h
set(${PROJECT_NAME}_NAMES
compounditemmodels
filtereditemmodels
)

qt5_wrap_cpp(datamodels_SRCS ${datamodels_HDRS})
AddHeadersSources()

add_library(${PROJECT_NAME}
${${PROJECT_NAME}_HDRS}
${${PROJECT_NAME}_SRCS}
)

add_library(datamodels ${datamodels_SRCS} ${datamodels_HDRS})
target_link_libraries(datamodels PRIVATE ${CPN_COMMON_LIB})
target_link_libraries(${PROJECT_NAME}
PRIVATE
${CPN_COMMON_LIB}
)

target_include_directories(datamodels
target_include_directories(${PROJECT_NAME}
PRIVATE
"${CMAKE_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
Expand Down
129 changes: 62 additions & 67 deletions companion/src/firmwares/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,75 +1,70 @@

set(firmwares_SRCS
adjustmentreference.cpp
boards.cpp
curvedata.cpp
curvereference.cpp
customfunctiondata.cpp
eeprominterface.cpp
generalsettings.cpp
gvardata.cpp
input_data.cpp
flightmodedata.cpp
heli_data.cpp
logicalswitchdata.cpp
mixdata.cpp
modeldata.cpp
moduledata.cpp
multiprotocols.cpp
output_data.cpp
radiodata.cpp
radiodataconversionstate.cpp
rawsource.cpp
rawswitch.cpp
sensordata.cpp
telem_data.cpp
timerdata.cpp
ersky9x/ersky9xeeprom.cpp
ersky9x/ersky9xinterface.cpp
opentx/opentxeeprom.cpp
opentx/opentxinterface.cpp
edgetx/edgetxinterface.cpp
edgetx/yaml_ops.cpp
edgetx/yaml_generalsettings.cpp
edgetx/yaml_calibdata.cpp
edgetx/yaml_trainerdata.cpp
edgetx/yaml_switchconfig.cpp
edgetx/yaml_modeldata.cpp
edgetx/yaml_rawswitch.cpp
edgetx/yaml_rawsource.cpp
edgetx/yaml_mixdata.cpp
edgetx/yaml_expodata.cpp
edgetx/yaml_curvedata.cpp
edgetx/yaml_moduledata.cpp
edgetx/yaml_logicalswitchdata.cpp
edgetx/yaml_customfunctiondata.cpp
edgetx/yaml_sensordata.cpp
edgetx/yaml_screendata.cpp
edgetx/yaml_usbjoystickdata.cpp
datahelpers.cpp
customisation_data.cpp
)
project(firmwares)

string(REPLACE ".cpp" ".h" firmwares_HDRS "${firmwares_SRCS}")
set(${PROJECT_NAME}_NAMES
adjustmentreference
boards
curvedata
curvereference
customfunctiondata
customisation_data
datahelpers
eeprominterface
generalsettings
gvardata
input_data
flightmodedata
heli_data
logicalswitchdata
mixdata
modeldata
moduledata
multiprotocols
output_data
radiodata
radiodataconversionstate
rawsource
rawswitch
sensordata
telem_data
timerdata
ersky9x/ersky9xeeprom
ersky9x/ersky9xinterface
opentx/opentxeeprom
opentx/opentxinterface
edgetx/edgetxinterface
edgetx/yaml_calibdata
edgetx/yaml_curvedata
edgetx/yaml_customfunctiondata
edgetx/yaml_expodata
edgetx/yaml_generalsettings
edgetx/yaml_logicalswitchdata
edgetx/yaml_mixdata
edgetx/yaml_modeldata
edgetx/yaml_moduledata
edgetx/yaml_ops
edgetx/yaml_rawsource
edgetx/yaml_rawswitch
edgetx/yaml_screendata
edgetx/yaml_sensordata
edgetx/yaml_switchconfig
edgetx/yaml_trainerdata
edgetx/yaml_usbjoystickdata
)

list(APPEND firmwares_HDRS
eepromimportexport.h
moduledata.h
customisation_data.h
)
AddHeadersSources()

set(firmwares_QT
curvereference.h
)
add_library(${PROJECT_NAME}
${${PROJECT_NAME}_HDRS}
${${PROJECT_NAME}_SRCS}
)

qt5_wrap_cpp(firmwares_SRCS ${firmwares_QT})
target_link_libraries(${PROJECT_NAME}
${CPN_COMMON_LIB}
yaml-cpp
)

add_library(firmwares ${firmwares_SRCS} ${firmwares_HDRS})

target_link_libraries(firmwares ${CPN_COMMON_LIB} datamodels shared Qt5::Core Qt5::Xml Qt5::Widgets)
target_link_libraries(firmwares yaml-cpp)

target_include_directories(firmwares
target_include_directories(${PROJECT_NAME}
PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
Expand All @@ -79,4 +74,4 @@ target_include_directories(firmwares
"${CMAKE_CURRENT_LIST_DIR}/ersky9x"
"${CMAKE_CURRENT_LIST_DIR}/opentx"
"${CMAKE_CURRENT_LIST_DIR}/edgetx"
)
)
Loading

0 comments on commit 9dd4a1e

Please sign in to comment.