122 lines
3.6 KiB
CMake
122 lines
3.6 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
|
|
project(EISConfigurator VERSION 1.0 LANGUAGES CXX C)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_AUTOMOC ON)
|
|
set(CMAKE_AUTORCC ON)
|
|
set(CMAKE_AUTOUIC ON)
|
|
|
|
# Added PrintSupport and OpenGLWidgets which are often needed by QCustomPlot
|
|
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets SerialPort PrintSupport OpenGLWidgets)
|
|
|
|
# --- QCustomPlot Integration ---
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
QCustomPlot
|
|
URL https://www.qcustomplot.com/release/2.1.1/QCustomPlot.tar.gz
|
|
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
|
)
|
|
|
|
FetchContent_GetProperties(QCustomPlot)
|
|
if(NOT qcustomplot_POPULATED)
|
|
FetchContent_Populate(QCustomPlot)
|
|
# QCustomPlot source distribution doesn't have a CMakeLists.txt
|
|
add_library(QCustomPlot
|
|
${qcustomplot_SOURCE_DIR}/qcustomplot.cpp
|
|
${qcustomplot_SOURCE_DIR}/qcustomplot.h
|
|
)
|
|
# Link required Qt modules to the library
|
|
target_link_libraries(QCustomPlot PUBLIC Qt6::Core Qt6::Gui Qt6::Widgets Qt6::PrintSupport)
|
|
target_include_directories(QCustomPlot PUBLIC ${qcustomplot_SOURCE_DIR})
|
|
endif()
|
|
|
|
# --- Icon Generation ---
|
|
|
|
set(ICON_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/assets/icon_source.png")
|
|
set(ICON_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_icons.sh")
|
|
set(MACOS_ICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/app_icon.icns")
|
|
set(WINDOWS_ICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/app_icon.ico")
|
|
|
|
# Find ImageMagick 'magick' executable
|
|
find_program(MAGICK_EXECUTABLE NAMES magick)
|
|
if(NOT MAGICK_EXECUTABLE)
|
|
message(WARNING "ImageMagick 'magick' not found. Icons will not be generated.")
|
|
endif()
|
|
|
|
if(EXISTS "${ICON_SOURCE}" AND MAGICK_EXECUTABLE)
|
|
execute_process(COMMAND chmod +x "${ICON_SCRIPT}")
|
|
|
|
add_custom_command(
|
|
OUTPUT "${MACOS_ICON}" "${WINDOWS_ICON}"
|
|
COMMAND "${ICON_SCRIPT}" "${MAGICK_EXECUTABLE}"
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
DEPENDS "${ICON_SOURCE}" "${ICON_SCRIPT}"
|
|
COMMENT "Generating icons from source using ${MAGICK_EXECUTABLE}..."
|
|
VERBATIM
|
|
)
|
|
|
|
add_custom_target(GenerateIcons DEPENDS "${MACOS_ICON}" "${WINDOWS_ICON}")
|
|
endif()
|
|
|
|
# --- Sources ---
|
|
|
|
set(PROJECT_SOURCES
|
|
src/main.cpp
|
|
src/MainWindow.cpp
|
|
src/GraphWidget.cpp
|
|
)
|
|
|
|
if(EXISTS "${ICON_SOURCE}")
|
|
list(APPEND PROJECT_SOURCES ${MACOS_ICON} ${WINDOWS_ICON})
|
|
endif()
|
|
|
|
set(PROJECT_HEADERS
|
|
src/MainWindow.h
|
|
src/GraphWidget.h
|
|
)
|
|
|
|
if(ANDROID)
|
|
add_library(EISConfigurator SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
|
|
else()
|
|
# Removed MANUAL_FINALIZATION keyword as add_executable does not support it
|
|
add_executable(EISConfigurator ${PROJECT_SOURCES} ${PROJECT_HEADERS})
|
|
endif()
|
|
|
|
if(EXISTS "${ICON_SOURCE}" AND MAGICK_EXECUTABLE)
|
|
add_dependencies(EISConfigurator GenerateIcons)
|
|
endif()
|
|
|
|
target_link_libraries(EISConfigurator PRIVATE
|
|
Qt6::Core Qt6::Gui Qt6::Widgets Qt6::SerialPort
|
|
QCustomPlot
|
|
)
|
|
|
|
if(ANDROID)
|
|
set_target_properties(EISConfigurator PROPERTIES QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android)
|
|
endif()
|
|
|
|
if(APPLE)
|
|
set_target_properties(EISConfigurator PROPERTIES
|
|
MACOSX_BUNDLE TRUE
|
|
MACOSX_BUNDLE_BUNDLE_NAME "EIS Configurator"
|
|
MACOSX_BUNDLE_GUI_IDENTIFIER "com.eis.configurator"
|
|
MACOSX_BUNDLE_ICON_FILE "app_icon.icns"
|
|
RESOURCE "${MACOS_ICON}"
|
|
)
|
|
elseif(WIN32)
|
|
set_target_properties(EISConfigurator PROPERTIES
|
|
WIN32_EXECUTABLE TRUE
|
|
)
|
|
if(EXISTS "${WINDOWS_ICON}")
|
|
set_target_properties(EISConfigurator PROPERTIES
|
|
WIN32_ICON "${WINDOWS_ICON}"
|
|
)
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT ANDROID)
|
|
qt_finalize_executable(EISConfigurator)
|
|
endif() |