Skip to content

Commit 6fe49c0

Browse files
committed
fix: mirror tool qt framework headers build issue on macOS
1 parent c81ab5e commit 6fe49c0

File tree

6 files changed

+32
-8
lines changed

6 files changed

+32
-8
lines changed

CMake/Target.cmake

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ function(exp_get_target_include_dirs_recurse)
238238
endfunction()
239239

240240
function(exp_add_mirror_info_source_generation_target)
241-
cmake_parse_arguments(PARAMS "DYNAMIC" "NAME;OUTPUT_SRC;OUTPUT_TARGET_NAME" "SEARCH_DIR;PUBLIC_INC;PRIVATE_INC;LIB" ${ARGN})
241+
cmake_parse_arguments(PARAMS "DYNAMIC" "NAME;OUTPUT_SRC;OUTPUT_TARGET_NAME" "SEARCH_DIR;PUBLIC_INC;PRIVATE_INC;LIB;FRAMEWORK_DIR" ${ARGN})
242242

243243
if (DEFINED PARAMS_PUBLIC_INC)
244244
list(APPEND INC ${PARAMS_PUBLIC_INC})
@@ -262,10 +262,20 @@ function(exp_add_mirror_info_source_generation_target)
262262
list(APPEND INC_ARGS "-I")
263263
foreach (I ${INC})
264264
get_filename_component(ABSOLUTE_I ${I} ABSOLUTE)
265-
list(APPEND ABSOLUTE_INC ${ABSOLUTE_I})
266265
list(APPEND INC_ARGS ${ABSOLUTE_I})
267266
endforeach()
268267

268+
if (DEFINED PARAMS_FRAMEWORK_DIR)
269+
list(APPEND FWK_DIR ${PARAMS_FRAMEWORK_DIR})
270+
list(APPEND FWK_DIR_ARGS "-F")
271+
endif ()
272+
list(REMOVE_DUPLICATES FWK_DIR)
273+
274+
foreach (F ${FWK_DIR})
275+
get_filename_component(ABSOLUTE_F ${F} ABSOLUTE)
276+
list(APPEND FWK_DIR_ARGS ${ABSOLUTE_F})
277+
endforeach ()
278+
269279
if (${PARAMS_DYNAMIC})
270280
list(APPEND DYNAMIC_ARG "-d")
271281
endif ()
@@ -282,7 +292,7 @@ function(exp_add_mirror_info_source_generation_target)
282292

283293
add_custom_command(
284294
OUTPUT ${OUTPUT_SOURCE}
285-
COMMAND "$<TARGET_FILE:MirrorTool>" ${DYNAMIC_ARG} "-i" ${INPUT_HEADER_FILE} "-o" ${OUTPUT_SOURCE} ${INC_ARGS}
295+
COMMAND "$<TARGET_FILE:MirrorTool>" ${DYNAMIC_ARG} "-i" ${INPUT_HEADER_FILE} "-o" ${OUTPUT_SOURCE} ${INC_ARGS} ${FWK_DIR_ARGS}
286296
DEPENDS MirrorTool ${INPUT_HEADER_FILE}
287297
)
288298
endforeach()

Editor/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ qt_standard_project_setup(REQUIRES ${QT_VERSION})
1010
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
1111
set(PLATFORM_EXECUTABLE_HINT MACOSX_BUNDLE)
1212
set(BUNDLE_INSTALL_DESTINATION BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/Engine/Binaries)
13+
set(PLATFORM_FRAMEWORK_DIR ${QT_LIB_PREFIX}/lib)
1314
endif ()
1415

1516
set(EDITOR_INCLUDES Include)
@@ -28,6 +29,7 @@ exp_add_mirror_info_source_generation_target(
2829
SEARCH_DIR Include
2930
PRIVATE_INC ${EDITOR_INCLUDES}
3031
LIB ${EDITOR_LIBS}
32+
FRAMEWORK_DIR ${PLATFORM_FRAMEWORK_DIR}
3133
)
3234

3335
file(GLOB_RECURSE SOURCES Src/*.cpp)

Tool/MirrorTool/ExeSrc/Main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ int main(int argc, char* argv[]) // NOLINT
3131
std::string inputFile;
3232
std::string outputFile;
3333
std::vector<std::string> headerDirs;
34+
std::vector<std::string> frameworkDirs;
3435
bool dynamic = false;
3536

3637
if (const auto cli = (
3738
clipp::required("-i").doc("input header file") & clipp::value("input header file", inputFile),
3839
clipp::required("-o").doc("output file") & clipp::value("output file", outputFile),
3940
clipp::option("-I").doc("header search dirs") & clipp::values("header search dirs", headerDirs),
41+
clipp::option("-F").doc("framework search dirs") & clipp::values("framework search dirs", frameworkDirs),
4042
clipp::option("-d").set(dynamic).doc("used for dynamic library (auto unload some metas)"));
4143
!clipp::parse(argc, argv, cli)) {
4244
std::cout << clipp::make_man_page(cli, argv[0]);
@@ -58,7 +60,7 @@ int main(int argc, char* argv[]) // NOLINT
5860
return 1;
5961
}
6062

61-
MirrorTool::Parser parser(inputFile, headerDirs);
63+
MirrorTool::Parser parser(inputFile, headerDirs, frameworkDirs);
6264
auto [parseSuccess, parseResultOrError] = parser.Parse();
6365

6466
if (!parseSuccess) {

Tool/MirrorTool/Include/MirrorTool/Parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ namespace MirrorTool {
9494
using Result = std::pair<bool, std::variant<std::string, MetaInfo>>;
9595

9696
NonCopyable(Parser)
97-
explicit Parser(std::string inSourceFile, std::vector<std::string> inHeaderDirs);
97+
explicit Parser(std::string inSourceFile, std::vector<std::string> inHeaderDirs, std::vector<std::string> inFrameworkDirs);
9898
~Parser();
9999

100100
Result Parse() const;
@@ -105,5 +105,6 @@ namespace MirrorTool {
105105

106106
std::string sourceFile;
107107
std::vector<std::string> headerDirs;
108+
std::vector<std::string> frameworkDirs;
108109
};
109110
}

Tool/MirrorTool/Src/Parser.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,10 @@ namespace MirrorTool {
413413
}
414414

415415
namespace MirrorTool {
416-
Parser::Parser(std::string inSourceFile, std::vector<std::string> inHeaderDirs) : sourceFile(std::move(inSourceFile)), headerDirs(std::move(inHeaderDirs))
416+
Parser::Parser(std::string inSourceFile, std::vector<std::string> inHeaderDirs, std::vector<std::string> inFrameworkDirs)
417+
: sourceFile(std::move(inSourceFile))
418+
, headerDirs(std::move(inHeaderDirs))
419+
, frameworkDirs(std::move(inFrameworkDirs))
417420
{
418421
}
419422

@@ -451,6 +454,12 @@ namespace MirrorTool {
451454
for (const std::string& headerDir : headerDirs) {
452455
argumentStrs.emplace_back(std::string("-I") + headerDir);
453456
}
457+
#if PLATFORM_MACOS
458+
for (const std::string& frameworkDir : frameworkDirs) {
459+
argumentStrs.emplace_back("-iframework");
460+
argumentStrs.emplace_back(frameworkDir);
461+
}
462+
#endif
454463

455464
std::vector<const char*> arguments(argumentStrs.size());
456465
for (auto i = 0; i < arguments.size(); i++) {

Tool/MirrorTool/Test/Main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void AssertNamespaceInfoEqual(const NamespaceInfo& lhs, const NamespaceInfo& rhs
120120

121121
TEST(MirrorTest, ParserTest)
122122
{
123-
const Parser parser("../Test/Resource/Mirror/MirrorToolInput.h", { "../Test/Resource/Mirror" });
123+
const Parser parser("../Test/Resource/Mirror/MirrorToolInput.h", { "../Test/Resource/Mirror" }, {});
124124
auto [parseSuccess, parseResultOrError] = parser.Parse();
125125
ASSERT_TRUE(parseSuccess);
126126

@@ -160,7 +160,7 @@ TEST(MirrorTest, ParserTest)
160160

161161
TEST(MirrorTest, GeneratorTest)
162162
{
163-
const Parser parser("../Test/Resource/Mirror/MirrorToolInput.h", { "../Test/Resource/Mirror" });
163+
const Parser parser("../Test/Resource/Mirror/MirrorToolInput.h", { "../Test/Resource/Mirror" }, {});
164164
auto [parseSuccess, parseResultOrError] = parser.Parse();
165165
ASSERT_TRUE(parseSuccess);
166166

0 commit comments

Comments
 (0)