大家好,又见面了,我是你们的朋友全栈君。
NMAKE编译CTK
启动编译环境
从VC中启动命令行或通过VC提供的批处理启动命令行,以能运行编译环境。
如果装了多个VC版本,注意使用想要的VC版本启动安装编译环境。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5YlX5Gta-1597631378020)(study/image-20200815174602043.png)]
再启动cmake
d:\soft\Program Files (x86)\Microsoft Visual tudio\2017\Community\Common7\Tools>cmake-gui
打开CMAKE工程
选择CTK的目录和构建目录
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9esbZFaI-1597631378022)(study/image-20200815174935129.png)]
增加安装步骤
用文本编译工具修改CTK目录下的SuperBuild.cmake,以增加安装步骤
添加如下内容:
#add install command
if(WIN32)
set(_INSTALL_CMD nmake install)
else()
set(_INSTALL_CMD make install)
endif()
#...
INSTALL_COMMAND ${_INSTALL_CMD}
添加完后内容如下:
if(NOT EXISTS ${CTK_BINARY_DIR}/CTK-build/bin)
file(MAKE_DIRECTORY ${CTK_BINARY_DIR}/CTK-build/bin)
endif()
#-----------------------------------------------------------------------------
set(proj CTK)
set(ep_cxx_standard_arg)
if(CMAKE_CXX_STANDARD)
set(ep_cxx_standard_arg "-DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD}")
endif()
#add install command
if(WIN32)
set(_INSTALL_CMD nmake install)
else()
set(_INSTALL_CMD make install)
endif()
ExternalProject_Add(${proj}
${${proj}_EP_ARGS}
DOWNLOAD_COMMAND ""
CMAKE_CACHE_ARGS
-DCTK_SUPERBUILD:BOOL=OFF
-DCTK_SUPERBUILD_BINARY_DIR:PATH=${CTK_BINARY_DIR}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS_INIT:STRING=${CMAKE_CXX_FLAGS_INIT}
-DCMAKE_C_FLAGS_INIT:STRING=${CMAKE_C_FLAGS_INIT}
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
-DCMAKE_MACOSX_RPATH:BOOL=${CMAKE_MACOSX_RPATH}
${ep_cxx_standard_arg}
SOURCE_DIR ${CTK_SOURCE_DIR}
BINARY_DIR ${CTK_BINARY_DIR}/CTK-build
INSTALL_COMMAND ${_INSTALL_CMD}
DEPENDS
${CTK_DEPENDENCIES}
)
ExternalProject_AlwaysConfigure(${proj})
打开 cmake工程
点configure,选择创建构建目录,
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-txa2UCXm-1597631378024)(study/image-20200815180036083.png)]
配置工程类型
然后选择工程类型为NMake Makefiles,
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4F4howOv-1597631378031)(study/image-20200815180115749.png)]
然后自动开始配置,有一些错误,正常的,后面接着配置
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VWVPv52F-1597631378033)(study/image-20200815180233507.png)]
配置Qt环境
主要CTK_QT_VERSION和CMAKE_PREFIX_PATH
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-D9w14b0O-1597631378034)(study/image-20200815180607612.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NmaOiHPR-1597631378035)(study/image-20200815181618924.png)]
配置安装位置
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-vHQh5yTI-1597631378037)(study/image-20200815181824640.png)]
配置CTK组件
根据需要配置组件
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-QOUhYxIV-1597631378037)(study/image-20200815182221598.png)]
其他配置
取消测试
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-XMAdyVgC-1597631378039)(study/image-20200815182008087.png)]
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ohI6Q72o-1597631378040)(study/image-20200815182110278.png)]
生成工程
运行配置,如果有错或配置项有红色,多运行几次,检查没有错误后,点生成
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-yH4ycnjE-1597631378040)(study/image-20200815182419997.png)]
编译安装
d:\soft\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools>cd d:\study\framework\ctk\ctk\build2
d:\study\framework\CTK\ctk\build2>nmake
GeneratorHeaderTemplate.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/org.commontk.plugingenerator.core/ctkPluginGeneratorTargetLibraries.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/org.commontk.plugingenerator.core/org_commontk_plugingenerator_core_Export.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/plugins/org_commontk_plugingenerator_ui.lib
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/plugins/liborg_commontk_plugingenerator_ui.dll
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/org.commontk.plugingenerator.ui/ctkPluginGeneratorAbstractUiExtension.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/org.commontk.plugingenerator.ui/ctkPluginGeneratorMainExtension.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/org.commontk.plugingenerator.ui/ctkPluginGeneratorUiPlugin_p.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/org.commontk.plugingenerator.ui/org_commontk_plugingenerator_ui_Export.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/include/ctk-0.1/ctkConfig.h
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/CMake/CTKPluginUseFile.cmake
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/CMake/CTKExports.cmake
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/CMake/CTKExports-debug.cmake
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/CMake/CTKConfig.cmake
-- Installing: D:/study/framework/CTK/ctk/build2/CTK-install/lib/ctk-0.1/CMake/CTKConfigVersion.cmake
[ 44%] Forcing configure step for 'CTK'
[ 55%] Completed 'CTK'
[100%] Built target CTK
d:\study\framework\CTK\ctk\build2>
查看编译安装结果
d:\study\framework\CTK\ctk\build2>tree /f d:\study\framework\ctk\ctk\build2\CTK-install
卷 Data 的文件夹 PATH 列表
卷序列号为 00490055 3414:54C4
D:\STUDY\FRAMEWORK\CTK\CTK\BUILD2\CTK-INSTALL
├─include
│ └─ctk-0.1
│ │ ctkAbstractFactory.h
│ │ ctkAbstractFactory.tpp
│ │ ctkAbstractFileBasedFactory.h
│ │ ctkAbstractFileBasedFactory.tpp
│ │ ctkAbstractLibraryFactory.h
│ │ ctkAbstractLibraryFactory.tpp
│ │ ctkAbstractObjectFactory.h
│ │ ctkAbstractObjectFactory.tpp
│ │ ctkAbstractPluginFactory.h
。。。
│
└─lib
└─ctk-0.1
│ CTKCore.dll
│ CTKCore.lib
│ CTKPluginFramework.dll
│ CTKPluginFramework.lib
│ CTKWidgets.dll
│ CTKWidgets.lib
│
├─CMake
│ │ CMakeFindDependencyMacro.cmake
。。。
│ │ UseCTK.cmake
│ │
│ └─ctkLinkerAsNeededFlagCheck
│ A.cpp
│ B.cpp
│ C.cpp
│ CMakeLists.txt
│
└─plugins
liborg_commontk_configadmin.dll
liborg_commontk_eventadmin.dll
liborg_commontk_log.dll
liborg_commontk_metatype.dll
liborg_commontk_plugingenerator_core.dll
liborg_commontk_plugingenerator_ui.dll
org_commontk_configadmin.lib
org_commontk_eventadmin.lib
org_commontk_log.lib
org_commontk_metatype.lib
org_commontk_plugingenerator_core.lib
org_commontk_plugingenerator_ui.lib
d:\study\framework\CTK\ctk\build2>
org_commontk_log.lib
org_commontk_metatype.lib
org_commontk_plugingenerator_core.lib
org_commontk_plugingenerator_ui.lib
d:\study\framework\CTK\ctk\build2>
编译安装成功。
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/135059.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...