# CMake command mode help (cmake -E env) (Edit: fixed error on concatenation)

**URL:** https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798
**Category:** Usage
**Created:** [June 5, 2022, 6:44pm UTC](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798 "2022-06-05T18:44:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![lucas-inacio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lucas-inacio/32/2474_2.png) [@lucas-inacio](https://discourse.cmake.org/u/lucas-inacio)
#### Post date: [June 5, 2022, 6:44pm UTC](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798/1 "2022-06-05T18:44:16Z")

</div>

Hello, everyone!

I’m trying to set up an external project. In the CONFIGURE\_COMMAND phase I’m trying to use a modified environment as folows:

```cmake
find_program(nasm NAMES nasm REQUIRED)
find_program(perl NAMES perl REQUIRED)

get_filename_component(nasm_dir ${nasm} DIRECTORY)
set(DIR_LIST $ENV{PATH})
list(APPEND DIR_LIST ${nasm_dir})
list(JOIN DIR_LIST "\;" ALL_PATH)
message(${ALL_PATH})

include(ExternalProject)

ExternalProject_Add(
    openssl_external
    GIT_REPOSITORY https://github.com/openssl/openssl.git
    GIT_TAG openssl-3.0.3

    CONFIGURE_COMMAND ${CMAKE_COMMAND} -E env PATH="${ALL_PATH}" ${perl} ${CMAKE_BINARY_DIR}/openssl_external-prefix/src/openssl_external/Configure
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
)

```

Configure step runs smoothly, but at build time CMake returns an error:

```nohighlight
Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Performing update step for 'openssl_external'
  No patch step for 'openssl_external'
  Performing configure step for 'openssl_external'
  Access is denied
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(245,5): error MSB8066: Custom build for 'E:\Projetos\openssl_cmake\build\CMakeFiles\5
a0dbcb60aa1c22791074824c5fb1c3f\openssl_external-update.rule;E:\Projetos\openssl_cmake\build\CMakeFiles\5a0dbcb60aa1c22791074824c5fb1c3f\openssl_external-patch.rule;E:\Projetos\openssl_cmake\buil 
d\CMakeFiles\5a0dbcb60aa1c22791074824c5fb1c3f\openssl_external-configure.rule;E:\Projetos\openssl_cmake\build\CMakeFiles\5a0dbcb60aa1c22791074824c5fb1c3f\openssl_external-build.rule;E:\Projetos\o 
penssl_cmake\build\CMakeFiles\5a0dbcb60aa1c22791074824c5fb1c3f\openssl_external-install.rule;E:\Projetos\openssl_cmake\build\CMakeFiles\8d46eee9464cb01489224e25d28f93e1\openssl_external-complete. 
rule;E:\Projetos\openssl_cmake\build\CMakeFiles\45483d5c0e89724af3f38f97f3dbb2ab\openssl_external.rule' exited with code 1. [E:\Projetos\openssl_cmake\build\openssl_external.vcxproj]

```

When I use only one path it works. How can I add paths to the system PATH variable without overwriting everything?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [June 5, 2022, 11:52pm UTC](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798/2 "2022-06-05T23:52:35Z")

</div>

I think you want `"PATH=${ALL_PATH}"` rather than `PATH="${ALL_PATH}"`. CMake doesn’t handle quotes within a string the same way as unix shells. In CMake, you must surround the whole thing with quotes for it to do what you intended here.

Regarding the list separators, don’t try to escape them. If you do the quoting as suggested above, CMake should take care of that for you. Note also that the `PATH` environment variable uses `;` as a separator on Windows, but `:` on other platforms. You may want to use `cmake_path(CONVERT ... TO_NATIVE_PATH_LIST)` to get the path value in the right form for the platform.

---

<div class="post-metadata">

### Author: ![lucas-inacio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lucas-inacio/32/2474_2.png) [@lucas-inacio](https://discourse.cmake.org/u/lucas-inacio)
#### Post date: [June 7, 2022, 3:44am UTC](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798/3 "2022-06-07T03:44:43Z")

</div>

Hello, @craig.scott

Sorry for the late reply. I’ll try your suggestions and bring feedback soon. Thanks!

---

<div class="post-metadata">

### Author: ![lucas-inacio](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lucas-inacio/32/2474_2.png) [@lucas-inacio](https://discourse.cmake.org/u/lucas-inacio)
#### Post date: [June 8, 2022, 1:24am UTC](https://discourse.cmake.org/t/cmake-command-mode-help-cmake-e-env-edit-fixed-error-on-concatenation/5798/4 "2022-06-08T01:24:04Z")

</div>

So I managed to get it working after your suggestions! Many thanks!
