如何在 CMake 中将现有的 QMake 项目(.pro 项目文件)用作 "external project"?
How to use existing QMake project (.pro project file) as "external project" in CMake?
是否有关于如何在 CMake 中将现有 QMake 项目与 .pro 项目文件用作 "external project" 的简明文档或示例?这可以在 qtcreator 中通过将一个项目标记为另一个项目的依赖项来完成,但最好使用 ExternalProject() CMake 语法更明确地定义它。
相关问题:CMake: How to build external projects and include their targets
像这样的东西行得通。然后,您可以从主 CMake 项目树中的任一 qtcreator 编辑文件, 或 打开 .pro 文件;非常适合快速迭代 SomeGarbageApplication 中的 QT 小部件,它是大型 cmake 构建树的一部分。
macro(DeclareProjectFiles Tag Filez)
######### Trick: use this syntax to make arbitrary files
######### appear in IDE project. #######################
### Note: pass in the raw name of a list variable,
### since it will get expanded here in this macro.
add_custom_target(${Tag}_files ALL
pwd
COMMAND ls -ltrh
COMMENT " ${Tag} files thunk... got list: [ ${${Filez}} ]"
VERBATIM
SOURCES ${${Filez}}
)
endmacro()
message(STATUS "QT_QMAKE_EXE is: ${QT_QMAKE_EXECUTABLE}")
set(Z SomeGarbageApplication)
file(GLOB ${Z}_Files
./*.cpp
./*.h
./*.ui
./*.pro
./*.png
./*.jpg)
DeclareProjectFiles( ${Z}_grbg ${Z}_Files )
add_custom_target(${Z}_pro ALL)
set(ExtraQMakeArgs -r -spec linux-g++ CONFIG+=release)
# note: use killall because this can/will fail if the exe is running
# But, need || true to not fail build when it's not running.
add_custom_command(TARGET ${Z}_pro
COMMAND killall
ARGS -q -9 -v ${Z} || true
COMMAND ${QT_QMAKE_EXECUTABLE}
ARGS -query
COMMAND ${QT_QMAKE_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${Z}.pro ${ExtraQMakeArgs}
COMMAND make ${Z}
ARGS -j4
COMMAND cp
ARGS ${Z} ${CMAKE_CURRENT_SOURCE_DIR}/${${Z}_config} ${CMAKE_BINARY_DIR}/bin/
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM
)
#################################################################
是否有关于如何在 CMake 中将现有 QMake 项目与 .pro 项目文件用作 "external project" 的简明文档或示例?这可以在 qtcreator 中通过将一个项目标记为另一个项目的依赖项来完成,但最好使用 ExternalProject() CMake 语法更明确地定义它。
相关问题:CMake: How to build external projects and include their targets
像这样的东西行得通。然后,您可以从主 CMake 项目树中的任一 qtcreator 编辑文件, 或 打开 .pro 文件;非常适合快速迭代 SomeGarbageApplication 中的 QT 小部件,它是大型 cmake 构建树的一部分。
macro(DeclareProjectFiles Tag Filez)
######### Trick: use this syntax to make arbitrary files
######### appear in IDE project. #######################
### Note: pass in the raw name of a list variable,
### since it will get expanded here in this macro.
add_custom_target(${Tag}_files ALL
pwd
COMMAND ls -ltrh
COMMENT " ${Tag} files thunk... got list: [ ${${Filez}} ]"
VERBATIM
SOURCES ${${Filez}}
)
endmacro()
message(STATUS "QT_QMAKE_EXE is: ${QT_QMAKE_EXECUTABLE}")
set(Z SomeGarbageApplication)
file(GLOB ${Z}_Files
./*.cpp
./*.h
./*.ui
./*.pro
./*.png
./*.jpg)
DeclareProjectFiles( ${Z}_grbg ${Z}_Files )
add_custom_target(${Z}_pro ALL)
set(ExtraQMakeArgs -r -spec linux-g++ CONFIG+=release)
# note: use killall because this can/will fail if the exe is running
# But, need || true to not fail build when it's not running.
add_custom_command(TARGET ${Z}_pro
COMMAND killall
ARGS -q -9 -v ${Z} || true
COMMAND ${QT_QMAKE_EXECUTABLE}
ARGS -query
COMMAND ${QT_QMAKE_EXECUTABLE}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${Z}.pro ${ExtraQMakeArgs}
COMMAND make ${Z}
ARGS -j4
COMMAND cp
ARGS ${Z} ${CMAKE_CURRENT_SOURCE_DIR}/${${Z}_config} ${CMAKE_BINARY_DIR}/bin/
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM
)
#################################################################