Develop environment:
VTK-8.2.0
Qt Creator 4.9.0
Based on Qt 5.12.2 (MSVC 2017, 32 bit)
CMake 3.14.3
CMake Generator: Visual Studio 16 2019

Configure compilers for my building kit
C compiler:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
CXX compiler:
C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe

More details are in the following image.



We get the error message like CMake Server connection lost sometimes, just delete CMakeCache.txt and open the project by qtcreator.exe which regards CMakeLists.txt as project file again.
We can also configure the project by script if you like a terminal tool.
The generator is Visual Studio 16 2019 for the current section’s scenarios.

"C:\Program Files (x86)\CMake\bin\cmake.exe" ../ -G "Visual Studio 16 2019" \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_CXX_COMPILER:STRING="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe" \
-DCMAKE_C_COMPILER:STRING="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe" \
-DCMAKE_PREFIX_PATH:STRING="C:/Qt/Qt5.12.3/5.12.3/msvc2017_64"\
-DHearderPath:PATH="E:/project/masterBranch/AAA_5.0"\
-DQT_QMAKE_EXECUTABLE:STRING="C:/Qt/Qt5.12.3/5.12.3/msvc2017_64/bin/qmake.exe"\
-DZLibBuildPath:PATH="E:/project/BBB/make"\
-DZLibSrcPath:PATH="E:/project/BBB"

The third library path defined in command can’t be used by cmake directly, we often have to write the values for them in CMakeCache.txt.
It’s not recommended to use the script to build a big project with CMake on cmd, because you may encounter many different weird bugs such as can’t find header files and environment incorrect.

E:\project\masterBranch\MainApp_5.0\Src\build-Src-Release $  "C:\Program Files (x86)\CMake\bin\cmake.exe" --build . --target all
CMake is re-running because E:/project/masterBranch/MainApp_5.0/Src/build-Src-Release/CMakeFiles/generate.stamp is out-of-date.
  the file 'E:/project/masterBranch/MainApp_5.0/Src/build-Src-Release/CMakeFiles/3.14.3/CMakeCCompiler.cmake'
  is newer than 'E:/project/masterBranch/MainApp_5.0/Src/build-Src-Release/CMakeFiles/generate.stamp.depend'
  result='-1'
-- Configuring done
-- Generating done
-- Build files have been written to: E:/project/masterBranch/MainApp_5.0/Src/build-Src-Release
[ 1%] Automatic MOC and UIC for target ULab
[ 1%] Built target ULab_autogen
[ 1%] Building CXX object CMakeFiles/ULab.dir/Module/UModuleManualAdjustToothFeature.cpp.obj
UModuleManualAdjustToothFeature.cpp
C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt.h(10): fatal error C1083: 无法打开包括文件: “vcruntime.h”: No such file or directory
NMAKE : fatal error U1077: 'C:\PROGRA~2\MIB055~1\2019\COMMUN~1\VC\Tools\MSVC\1421~1.277\bin\Hostx64\x64\cl.exe' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

Our IDE is designed for the kind of task, it helps us to configure development environment, compile and link easily.



Categories: Tool

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Content Summary
: Input your strings, the tool can get a brief summary of the content for you.

X
0
Would love your thoughts, please comment.x
()
x