1- #set the minimum cmake version required
1+ # Set the minimum cmake version required
22cmake_minimum_required (VERSION 3.18.0)
33
4- #set the name of the project
4+ # Set the project name
55project (SerialPrograms)
66
7- #enable c++ 23
8- set (CMAKE_CXX_STANDARD 23)
9- set (CMAKE_CXX_STANDARD_REQUIRED ON )
10-
11- #produce clang tidy file
12- set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
137#set(CMAKE_VERBOSE_MAKEFILE ON)
14-
15- set (CMAKE_AUTOMOC ON )
16- set (CMAKE_AUTORCC ON )
17- set (CMAKE_AUTOUIC ON )
18-
198add_custom_target (build -time-make-directory ALL
209 COMMAND ${CMAKE_COMMAND} -E make_directory Assembly/)
2110
2211# Find repo root folder path
2312string (FIND "${CMAKE_CURRENT_SOURCE_DIR} " "Arduino-Source-Internal" internal_repo_position)
2413
2514# Determine if this is an internal repo and normalize REPO_ROOT_DIR
26- if (internal_repo_position EQUAL -1)
15+ if (internal_repo_position EQUAL -1)
2716 # We are building the public repo
2817 set (REPO_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../" )
2918else ()
3019 # We are building the internal repo
3120 set (REPO_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../../../" )
3221endif ()
3322
23+ # Extract Discord Social SDK
24+ if (WIN32 )
25+ message (STATUS "Extracting Social SDK" )
26+ set (DISCORD_SDK_ZIP "${REPO_ROOT_DIR} /3rdPartyBinaries/discord_social_sdk_win.zip" )
27+ set (DISCORD_SDK_DIR "${REPO_ROOT_DIR} /3rdPartyBinaries/discord_social_sdk_win" )
28+ if (EXISTS "${DISCORD_SDK_ZIP} " AND NOT EXISTS "${DISCORD_SDK_DIR} " )
29+ file (ARCHIVE_EXTRACT
30+ INPUT "${DISCORD_SDK_ZIP} "
31+ DESTINATION "${REPO_ROOT_DIR} /3rdPartyBinaries"
32+ )
33+ endif ()
34+ endif ()
35+
3436# Determine environment
3537if (DEFINED ENV{GITHUB_ACTIONS})
3638 message (STATUS "Detected CI environment, skipping file deployment" )
3739 set (DEPLOY_FILES FALSE )
3840else ()
3941 message (STATUS "Detected local dev environment" )
4042 set (PACKAGES_DIR "${REPO_ROOT_DIR} /Packages" )
41- message (STATUS "Packages directory: ${PACKAGES_DIR} " )
4243
4344 # Clone or update the Packages repo
4445 if (NOT EXISTS "${PACKAGES_DIR} /.git" )
5152 OUTPUT_STRIP_TRAILING_WHITESPACE
5253 ERROR_STRIP_TRAILING_WHITESPACE
5354 )
55+
5456 if (NOT result EQUAL 0)
5557 message (FATAL_ERROR "Failed to clone Packages repo:\n ${err} " )
5658 endif ()
6466 OUTPUT_STRIP_TRAILING_WHITESPACE
6567 ERROR_STRIP_TRAILING_WHITESPACE
6668 )
69+
6770 if (NOT result EQUAL 0)
6871 message (WARNING "Failed to update Packages repo:\n ${err} " )
6972 endif ()
@@ -73,8 +76,13 @@ else()
7376 set (FIRMWARE_DIR "${PACKAGES_DIR} /PABotBase/PABotBase-Switch" )
7477 set (SCRIPTS_DIR "${PACKAGES_DIR} /SerialPrograms/Scripts" )
7578 set (RESOURCES_DIR "${PACKAGES_DIR} /SerialPrograms/Resources" )
76- set (DEST_DIR "$<TARGET_FILE_DIR:SerialPrograms>" )
77- set (DEPLOY_DIR "$<TARGET_FILE_DIR:SerialPrograms>/Binaries64" )
79+ set (DEST_DIR "$<TARGET_FILE_DIR:SerialPrograms>/Output" )
80+ if (PACKAGE_BUILD)
81+ set (DEPLOY_DIR "${DEST_DIR} /Binaries64" )
82+ else ()
83+ set (DEPLOY_DIR "${DEST_DIR} " )
84+ endif ()
85+
7886 set (DEPLOY_FILES TRUE )
7987 message (STATUS "Packages repo ready for deployment" )
8088endif ()
@@ -83,14 +91,35 @@ endif()
8391set (THREADS_PREFER_PTHREAD_FLAG ON )
8492find_package (Threads REQUIRED)
8593
86- #find Qt
94+ # Define the base Qt installation directory
95+ set (QT_BASE_DIR "C:/Qt" )
96+
97+ # Define the major version of Qt to search for
8798if (NOT QT_MAJOR)
8899 set (QT_MAJOR 6)
89100endif ()
90101
102+ # Find all subdirectories in the Qt base directory
103+ file (GLOB QT_SUBDIRS LIST_DIRECTORIES true "${QT_BASE_DIR} /${QT_MAJOR} *" )
104+
105+ # Filter and sort the directories to find the latest version
106+ list (SORT QT_SUBDIRS)
107+ list (REVERSE QT_SUBDIRS)
108+
109+ # Get the first directory in the sorted list (latest version)
110+ list (GET QT_SUBDIRS 0 QT_LATEST_DIR)
111+
112+ # Debug message to verify the latest Qt directory
113+ if (QT_LATEST_DIR)
114+ message (STATUS "Latest Qt directory for Qt${QT_MAJOR} : ${QT_LATEST_DIR} " )
115+ set (CMAKE_PREFIX_PATH "${QT_LATEST_DIR} /msvc2022_64/lib/cmake" )
116+ else ()
117+ message (FATAL_ERROR "No Qt${QT_MAJOR} installation found in ${QT_BASE_DIR} " )
118+ endif ()
119+
91120find_package (Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
92121# Find windeployqt.exe relative to the Qt bin dir
93- if (WIN32 AND DEPLOY_FILES)
122+ if (WIN32 AND DEPLOY_FILES)
94123 get_target_property (qt_core_location Qt${QT_MAJOR} ::Core LOCATION )
95124 get_filename_component (qt_bin_dir "${qt_core_location} " DIRECTORY )
96125 find_program (WINDEPLOYQT_EXECUTABLE windeployqt
@@ -2511,17 +2540,12 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/Internal0.
25112540 target_sources (SerialPrograms PRIVATE ../../Internal /SerialPrograms/Internal1.cpp)
25122541endif ()
25132542
2514- #extract opencv_world4110d.dll from archive on Windows Debug build, extract Discord Social SDK
2543+ #extract opencv_world4110d.dll from archive on Windows Debug build
25152544if (WIN32 )
25162545 file (ARCHIVE_EXTRACT
25172546 INPUT ${REPO_ROOT_DIR} /3rdPartyBinaries/opencv_world4110d.zip
25182547 DESTINATION ${REPO_ROOT_DIR} /3rdPartyBinaries/
25192548 )
2520-
2521- file (ARCHIVE_EXTRACT
2522- INPUT ${REPO_ROOT_DIR} /3rdPartyBinaries/discord_social_sdk_win.zip
2523- DESTINATION ${REPO_ROOT_DIR} /3rdPartyBinaries/
2524- )
25252549endif ()
25262550
25272551#add include directory
0 commit comments