Skip to content

Commit 65cb7fc

Browse files
committed
fix cmake conan; fix qt program; update version of some dep packages
1 parent 546eddc commit 65cb7fc

File tree

4 files changed

+28
-9
lines changed

4 files changed

+28
-9
lines changed

CMakeLists.txt

+11-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ macro(setup_conan)
2323
message(WARNING "conan is not found!" )
2424
else()
2525
message("Found conan: ${V_conan_cmd}")
26-
set(V_conan_gen_files
27-
"${CMAKE_BINARY_DIR}/build/generators/conan_toolchain.cmake")
26+
if(CMAKE_CONFIGURATION_TYPES) # Multi-configuration
27+
set(V_conan_gen_files "${CMAKE_BINARY_DIR}/build/generators/conan_toolchain.cmake")
28+
else() # Single-configuration
29+
set(V_conan_gen_files "${CMAKE_BINARY_DIR}/build/${CMAKE_BUILD_TYPE}/generators/conan_toolchain.cmake")
30+
endif()
31+
message("Conan toolchain file: ${V_conan_gen_files}")
2832
set(V_conanfile
2933
"${PROJECT_SOURCE_DIR}/${GV_extra_dir}/conanfile.txt")
3034
if (NOT EXISTS ${V_conanfile})
@@ -60,9 +64,9 @@ macro(setup_conan)
6064

6165
# Set up build type
6266
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
63-
set(V_conan_s_build_type "-sbuild_type=Debug")
67+
set(V_conan_s_build_type "-s:a" "build_type=Debug")
6468
else()
65-
set(V_conan_s_build_type "-sbuild_type=Release")
69+
set(V_conan_s_build_type "-s:a" "build_type=Release")
6670
endif()
6771

6872
# Prepare the conan install command
@@ -88,7 +92,9 @@ macro(setup_conan)
8892

8993
## Required by conan
9094
cmake_policy(SET CMP0091 NEW)
95+
set(CMAKE_OSX_SYSROOT_RIGHT "${CMAKE_OSX_SYSROOT}")
9196
include(${V_conan_gen_files})
97+
set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_RIGHT}" CACHE PATH "Sysroot for macOS" FORCE)
9298
endif()
9399
endif()
94100
endmacro()
@@ -107,7 +113,7 @@ macro(setup_build_environment)
107113
find_package(httplib REQUIRED)
108114
find_package(nlohmann_json REQUIRED)
109115
find_package(OpenSSL REQUIRED)
110-
find_package(Qt5 REQUIRED)
116+
find_package(Qt6 REQUIRED)
111117

112118
## Setup product options
113119
### set_product_options()

extra/conanfile.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[requires]
2-
json-c/0.16
2+
json-c/0.18
33
openssl/3.3.2
44
zlib/1.2.13
55
grpc/1.67.1
66
boost/1.81.0
7-
ftxui/3.0.0
7+
ftxui/4.1.1
88
cpp-httplib/0.11.2
99
nlohmann_json/3.11.2
1010
qt/6.7.3

src/exec_test_qt/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ add_executable(${V_program_name} exec_main.cpp)
77
if(WIN32)
88
target_link_options(${V_program_name} PRIVATE /SUBSYSTEM:WINDOWS)
99
endif()
10-
target_link_libraries(${V_program_name} qt::qt cpp_toolkit ${PLATFORM_LINK_LIB})
10+
target_link_libraries(${V_program_name} PRIVATE qt::qt cpp_toolkit ${PLATFORM_LINK_LIB})
11+
if(APPLE)
12+
target_link_libraries(${V_program_name} PRIVATE "-framework UniformTypeIdentifiers")
13+
endif()

src/exec_test_qt/exec_main.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@
2020
#include <QMessageBox>
2121
#include <QtPlugin>
2222

23-
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
23+
24+
#ifdef Q_OS_MAC
25+
Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) // macOS 平台
26+
#elif defined(Q_OS_WIN)
27+
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) // Windows 平台
28+
#elif defined(Q_OS_LINUX)
29+
Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) // Linux 平台
30+
#else
31+
#error "Unsupported platform!"
32+
#endif
33+
2434

2535
class MainWindow : public QMainWindow {
2636
Q_OBJECT

0 commit comments

Comments
 (0)