Skip to content

Commit

Permalink
[docs-integration] Add more documentation about using the CMake toolc…
Browse files Browse the repository at this point in the history
…hain file
  • Loading branch information
ras0219-msft committed Jul 3, 2018
1 parent 2900803 commit 2f50e20
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion docs/users/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,32 @@ See [Example: Using Sqlite](../examples/using-sqlite.md) for a fully worked exam
Note that we do not automatically add ourselves to your compiler include paths. To use a header-only library, simply use `find_path()`, which will correctly work on all platforms:
```cmake
# To find and use catch
find_path(CATCH_INCLUDE_DIR catch.hpp)
find_path(CATCH_INCLUDE_DIR NAMES catch.hpp PATH_SUFFIXES catch2)
include_directories(${CATCH_INCLUDE_DIR})
```

##### Using an environment variable instead of a command line option

The `CMAKE_TOOLCHAIN_FILE` setting simply must be set before the `project()` directive is first called. This means that you can easily read from an environment variable to avoid passing it on the configure line:

```cmake
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
project(myproject CXX)
```

##### Using multiple toolchain files

To use an external toolchain file with a project using vcpkg, you can set the cmake variable `VCPKG_CHAINLOAD_TOOLCHAIN_FILE` on the configure line:
```no-highlight
cmake ../my/project \
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=../my/project/compiler-settings-toolchain.cmake
```

#### Linking NuGet file

We also provide individual VS project integration through a NuGet package. This will modify the project file, so we do not recommend this approach for open source projects.
Expand Down

0 comments on commit 2f50e20

Please sign in to comment.