11# Set the minimum cmake version required
22cmake_minimum_required (VERSION 3.18.0)
33
4+ # Tell CMake to re-run configuration when these files change (get around Qt issues with stale CMake files)
5+ set (_cmake_files_to_watch
6+ "${CMAKE_SOURCE_DIR} /CMakeLists.txt"
7+ "${CMAKE_SOURCE_DIR} /CMakePresets.json"
8+ )
9+
10+ # Watch any helper .cmake files under cmake/
11+ file (GLOB_RECURSE _cmake_helper_files "${CMAKE_SOURCE_DIR} /cmake/*.cmake" )
12+ list (APPEND _cmake_files_to_watch ${_cmake_helper_files} )
13+
14+ # Append to the directory property so CMake will reconfigure when these change
15+ set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${_cmake_files_to_watch} )
16+ #message(STATUS "CMake will reconfigure when these change: ${_cmake_files_to_watch}")
17+
418# Set the project name
519project (SerialPrograms)
620
21+ # Enable C++23
22+ set (CMAKE_CXX_STANDARD 23)
23+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
24+
25+ # Produce clang tidy file
26+ set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
727#set(CMAKE_VERBOSE_MAKEFILE ON)
28+
29+ set (CMAKE_AUTOMOC ON )
30+ set (CMAKE_AUTORCC ON )
31+ set (CMAKE_AUTOUIC ON )
32+
833add_custom_target (build -time-make-directory ALL
934 COMMAND ${CMAKE_COMMAND} -E make_directory Assembly/)
1035
@@ -20,19 +45,6 @@ else()
2045 set (REPO_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../../../" )
2146endif ()
2247
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-
3648# Determine environment
3749if (DEFINED ENV{GITHUB_ACTIONS})
3850 message (STATUS "Detected CI environment, skipping file deployment" )
@@ -76,10 +88,12 @@ else()
7688 set (FIRMWARE_DIR "${PACKAGES_DIR} /PABotBase/PABotBase-Switch" )
7789 set (SCRIPTS_DIR "${PACKAGES_DIR} /SerialPrograms/Scripts" )
7890 set (RESOURCES_DIR "${PACKAGES_DIR} /SerialPrograms/Resources" )
79- set (DEST_DIR "$<TARGET_FILE_DIR:SerialPrograms>/Output" )
91+
8092 if (PACKAGE_BUILD)
93+ set (DEST_DIR "$<TARGET_FILE_DIR:SerialPrograms>/Output" )
8194 set (DEPLOY_DIR "${DEST_DIR} /Binaries64" )
8295 else ()
96+ set (DEST_DIR "$<TARGET_FILE_DIR:SerialPrograms>" )
8397 set (DEPLOY_DIR "${DEST_DIR} " )
8498 endif ()
8599
@@ -91,35 +105,36 @@ endif()
91105set (THREADS_PREFER_PTHREAD_FLAG ON )
92106find_package (Threads REQUIRED)
93107
94- # Define the base Qt installation directory
95- set (QT_BASE_DIR "C:/Qt" )
96-
97108# Define the major version of Qt to search for
98109if (NOT QT_MAJOR)
99110 set (QT_MAJOR 6)
100111endif ()
101112
102- # Find all subdirectories in the Qt base directory
103- file (GLOB QT_SUBDIRS LIST_DIRECTORIES true "${QT_BASE_DIR} /${QT_MAJOR} *" )
113+ find_package (Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
104114
105- # Filter and sort the directories to find the latest version
106- list (SORT QT_SUBDIRS)
107- list (REVERSE QT_SUBDIRS)
115+ # Find Qt and windeployqt.exe relative to the Qt bin dir
116+ if (WIN32 AND DEPLOY_FILES)
117+ # Define the base Qt installation directory
118+ set (QT_BASE_DIR "C:/Qt" )
108119
109- # Get the first directory in the sorted list (latest version)
110- list ( GET QT_SUBDIRS 0 QT_LATEST_DIR )
120+ # Find all subdirectories in the Qt base directory
121+ file (GLOB QT_SUBDIRS LIST_DIRECTORIES true " ${QT_BASE_DIR} / ${QT_MAJOR} *" )
111122
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 ()
123+ # Filter and sort the directories to find the latest version
124+ list (SORT QT_SUBDIRS)
125+ list (REVERSE QT_SUBDIRS)
126+
127+ # Get the first directory in the sorted list (latest version)
128+ list (GET QT_SUBDIRS 0 QT_LATEST_DIR)
129+
130+ # Debug message to verify the latest Qt directory
131+ if (QT_LATEST_DIR)
132+ message (STATUS "Latest Qt directory for Qt${QT_MAJOR} : ${QT_LATEST_DIR} " )
133+ set (CMAKE_PREFIX_PATH "${QT_LATEST_DIR} /msvc2022_64/lib/cmake" )
134+ else ()
135+ message (FATAL_ERROR "No Qt${QT_MAJOR} installation found in ${QT_BASE_DIR} " )
136+ endif ()
119137
120- find_package (Qt${QT_MAJOR} COMPONENTS Widgets SerialPort Multimedia MultimediaWidgets REQUIRED)
121- # Find windeployqt.exe relative to the Qt bin dir
122- if (WIN32 AND DEPLOY_FILES)
123138 get_target_property (qt_core_location Qt${QT_MAJOR} ::Core LOCATION )
124139 get_filename_component (qt_bin_dir "${qt_core_location} " DIRECTORY )
125140 find_program (WINDEPLOYQT_EXECUTABLE windeployqt
@@ -2540,12 +2555,23 @@ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Internal/SerialPrograms/Internal0.
25402555 target_sources (SerialPrograms PRIVATE ../../Internal /SerialPrograms/Internal1.cpp)
25412556endif ()
25422557
2543- #extract opencv_world4110d.dll from archive on Windows Debug build
2558+ # Extract opencv_world4110d.dll from archive on Windows Debug build, extract Discord Social SDK for Windows
25442559if (WIN32 )
2560+ message (STATUS "Extracting opencv_world4110d" )
25452561 file (ARCHIVE_EXTRACT
25462562 INPUT ${REPO_ROOT_DIR} /3rdPartyBinaries/opencv_world4110d.zip
25472563 DESTINATION ${REPO_ROOT_DIR} /3rdPartyBinaries/
25482564 )
2565+
2566+ set (DISCORD_SDK_ZIP "${REPO_ROOT_DIR} /3rdPartyBinaries/discord_social_sdk_win.zip" )
2567+ set (DISCORD_SDK_DIR "${REPO_ROOT_DIR} /3rdPartyBinaries/discord_social_sdk_win" )
2568+ if (EXISTS "${DISCORD_SDK_ZIP} " AND NOT EXISTS "${DISCORD_SDK_DIR} " )
2569+ message (STATUS "Extracting Social SDK" )
2570+ file (ARCHIVE_EXTRACT
2571+ INPUT "${DISCORD_SDK_ZIP} "
2572+ DESTINATION "${REPO_ROOT_DIR} /3rdPartyBinaries"
2573+ )
2574+ endif ()
25492575endif ()
25502576
25512577#add include directory
0 commit comments