1

I am using cmake-conan to call conan during my build (on Ubuntu 16.04). However now I want to test that certain builds do NOT call conan.

cmake-conan calls conan in this fashion:

execute_process(COMMAND ${conan_command} ${conan_args}
                     RESULT_VARIABLE return_code
                     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

Where ${conan_command} resolves to conan.

What I tried is to alias conan to fail in my bash script, however it doesn't seem to be picked up by cmake.

alias conan='fail'

Is there another way to make sure that a program is not found in PATH even though it actually is in PATH?

  • Don't call conan directly, earlier in the process create a link to it that you switch between conan and fail as need, and call conan through that link. – xenoid Sep 26 '18 at 14:48
0

In CMake script run conan_cmake_run macro with params CONAN_COMMAND "fail"

You can pass CONAN_COMMAND as ENVIRNOMENT variable:

…
conan_cmake_run(CONAN_COMMAND $ENV{CONAN_COMMAND)
…

and:

CONAN_COMMAND=fail cmake …

or pass as variable:

…
conan_cmake_run(CONAN_COMMAND ${CONAN_COMMAND)
…

and:

cmake -DCONAN_COMMAND=fail …
  • I solved my issue by injecting a fake conan script in the PATH before the test, your method works only for testing once, not continually. – kutschkem Sep 27 '18 at 13:41

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.