forked from qt-creator/qt-creator
Doc: Polish creator-projects-cmake.qdoc
Consistently use CMake without \c, update examples to current Qt installers. Change-Id: I92759c82af150ca6be32ae67bc9d920e2eff7987 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
This commit is contained in:
@@ -32,8 +32,8 @@
|
||||
|
||||
CMake is an alternative to qmake for automating the generation of build
|
||||
configurations. It controls the software compilation process by using simple
|
||||
configuration files, called \c{CMakeLists.txt} files. CMake generates native
|
||||
build configurations and workspaces that you can use in the compiler
|
||||
configuration files, called \c {CMakeLists.txt} files. CMake generates
|
||||
native build configurations and workspaces that you can use in the compiler
|
||||
environment of your choice.
|
||||
|
||||
Since \QC 1.1, CMake configuration files are supported. Since \QC 1.3, the
|
||||
@@ -41,61 +41,62 @@
|
||||
|
||||
\section1 Setting the Path for CMake
|
||||
|
||||
You can set the path for the \c CMake executable in \uicontrol{Tools} >
|
||||
\uicontrol{Options > Build & Run > CMake}.
|
||||
You can set the path for the CMake executable in \uicontrol Tools >
|
||||
\uicontrol Options > \uicontrol {Build & Run} > \uicontrol CMake.
|
||||
|
||||
\image qtcreator-cmakeexecutable.png
|
||||
|
||||
\note Before you open a \c CMake project, you must modify the \c{PATH}
|
||||
\note Before you open a CMake project, you must modify the \c {PATH}
|
||||
environment variable to include the bin folders of \c mingw and Qt.
|
||||
|
||||
For instance, if the Qt 4 SDK is installed in \c {C:\SDK}, you would use the
|
||||
For instance, if Qt 5.5 is installed in \c {C:\Qt}, you would use the
|
||||
following command to set the environment variables in the command line
|
||||
prompt:
|
||||
\code
|
||||
set PATH=C:\sdk\mingw\bin;C:\sdk\qt\bin;
|
||||
set PATH=C:\Qt\Tools\mingw<VERSION>\bin;C:\Qt\5.5\<TARGET>\bin;
|
||||
\endcode
|
||||
Then start \QC by typing:
|
||||
\code
|
||||
C:\sdk\bin\qtcreator.exe
|
||||
C:\Qt\Tools\QtCreator\qtcreator.exe
|
||||
\endcode
|
||||
|
||||
\section1 Opening CMake Projects
|
||||
|
||||
To open a \c CMake project:
|
||||
To open a CMake project:
|
||||
|
||||
\list 1
|
||||
|
||||
\li Select \uicontrol{File} > \uicontrol{Open File or Project}.
|
||||
\li Select \uicontrol File > \uicontrol {Open File or Project}.
|
||||
|
||||
\li Select the \c{CMakeLists.txt} file from your \c CMake project.
|
||||
\li Select the \c {CMakeLists.txt} file from your CMake project.
|
||||
|
||||
\endlist
|
||||
|
||||
A wizard guides you through the rest of the process.
|
||||
|
||||
\note If the \c CMake project does not have an in-place build, \QC
|
||||
\note If the CMake project does not have an in-place build, \QC
|
||||
lets you specify the directory in which the project is built
|
||||
(\l{glossary-shadow-build}{shadow build}).
|
||||
|
||||
\image qtcreator-cmake-import-wizard1.png
|
||||
|
||||
The screenshot below shows how you can specify command line arguments to
|
||||
\c CMake for your project.
|
||||
CMake for your project.
|
||||
|
||||
\image qtcreator-cmake-import-wizard2.png
|
||||
|
||||
Normally, there is no need to pass any command line arguments for projects
|
||||
that are already built, as \c CMake caches that information.
|
||||
that are already built, as CMake caches that information.
|
||||
|
||||
\section1 Building CMake Projects
|
||||
|
||||
\QC builds \c CMake projects by running \c make, \c mingw32-make, or
|
||||
\c nmake depending on your platform. The build errors and warnings are
|
||||
parsed and displayed in the \uicontrol{Issues} output pane.
|
||||
\QC builds CMake projects by running \c make, \c mingw32-make,
|
||||
\c nmake, or \c ninja depending on your platform. The build errors and
|
||||
warnings are parsed and displayed in the \uicontrol Issues output pane.
|
||||
|
||||
By default, \QC builds the \b{all} target. You can specify which
|
||||
targets to build in \uicontrol{Project} mode, under \uicontrol{Build Settings}.
|
||||
targets to build in \uicontrol Projects mode, under
|
||||
\uicontrol {Build Settings}.
|
||||
|
||||
\image qtcreator-cmake-build-settings.png
|
||||
|
||||
@@ -104,8 +105,8 @@
|
||||
|
||||
\section1 Running CMake Projects
|
||||
|
||||
\QC automatically adds \uicontrol{Run Configurations} for all targets specified
|
||||
in the \c CMake project file.
|
||||
\QC automatically adds \uicontrol {Run Configurations} for all targets
|
||||
specified in the CMake project file.
|
||||
|
||||
For more information about known issues for the current version, see
|
||||
\l{Known Issues}.
|
||||
@@ -114,11 +115,11 @@
|
||||
|
||||
\QC cannot extract files to be installed from a CMake project, and
|
||||
therefore, only executable targets are automatically added to deployment
|
||||
files. You must specify all other files in the \c QtCreatorDeployment.txt
|
||||
files. You must specify all other files in the \c {QtCreatorDeployment.txt}
|
||||
file that you create and place in either the root directory of the CMake
|
||||
project or the build directory of the active build configuration.
|
||||
Currently, Qt Creator first checks the root directory and only if no
|
||||
\c QtCreatorDeployment.txt exists it checks the active build directory.
|
||||
Currently, \QC first checks the root directory and only if no
|
||||
\c {QtCreatorDeployment.txt} exists it checks the active build directory.
|
||||
|
||||
Use the following syntax in the file:
|
||||
|
||||
@@ -133,23 +134,24 @@
|
||||
|
||||
\list
|
||||
|
||||
\li \c{<deployment/prefix>} is the (absolute) path prefix to where files
|
||||
are copied on the remote machine.
|
||||
\li \c {<deployment/prefix>} is the (absolute) path prefix to where
|
||||
files are copied on the remote machine.
|
||||
|
||||
\li \c{<relative/source/file>} is the file path relative to the CMake
|
||||
\li \c {<relative/source/file>} is the file path relative to the CMake
|
||||
project root. No directories or wildcards are allowed in this
|
||||
value.
|
||||
|
||||
\li \c{<relative/destination/dir>} is the destination directory path
|
||||
relative to \c{deployment/prefix}.
|
||||
\li \c {<relative/destination/dir>} is the destination directory path
|
||||
relative to \c {deployment/prefix}.
|
||||
|
||||
\endlist
|
||||
|
||||
To automate the creation of \c QtCreatorDeployment.txt file:
|
||||
To automate the creation of \c {QtCreatorDeployment.txt} file:
|
||||
|
||||
\list 1
|
||||
|
||||
\li Define the following macros in the top level \c CMakeLists.txt file:
|
||||
\li Define the following macros in the top level \c {CMakeLists.txt}
|
||||
file:
|
||||
|
||||
\code
|
||||
file(WRITE "${CMAKE_SOURCE_DIR}/QtCreatorDeployment.txt" "<deployment/prefix>\n")
|
||||
@@ -181,12 +183,12 @@
|
||||
Through external libraries, \QC can support code completion and syntax
|
||||
highlighting as if they were part of the current project or the Qt library.
|
||||
|
||||
\QC detects the external libraries using the \c FIND_PACKAGE()
|
||||
\QC detects the external libraries using the \c {FIND_PACKAGE()}
|
||||
macro. Some libraries come with the CMake installation. You can find those
|
||||
in the \c {Modules} directory of your CMake installation.
|
||||
|
||||
\note If you provide your own libraries, you also need to provide your own
|
||||
\c FindFoo.cmake file. For more information, see
|
||||
\c {FindFoo.cmake} file. For more information, see
|
||||
\l{http://vtk.org/Wiki/CMake_FAQ#Writing_FindXXX.cmake_files}{CMake FAQ}.
|
||||
|
||||
Syntax completion and highlighting work once your project successfully
|
||||
|
||||
Reference in New Issue
Block a user