Skip to content
Advertisement

Calling pipenv in CMake command ModuleNotFoundError

I am trying to generate C/C++ source files via a Python script using CMake, but am running into an issue where it appears that pipenv is not working as expected.

I’ve attempted to create a simplified version of my real world example on my Github.

JavaScript

The error I am receiving is:

JavaScript

I’ve tried changing the COMMAND arg for add_custom_target() to ${PipEnv} install, but that had no effect. Is there something else I need to be passing to pipenv or the CMake command to get this working?

Advertisement

Answer

Couple of errors here…

  1. Your custom command output and depends of the same file, generate.py
    note: you can see a make error in the trace

  2. By default add_custom_command will the current source dir as working directy while custom target is run in the current build dir.
    i.e. both are running in different directory -> two different pipenv used…

  3. You muse use pipenv run python instead of pipenv run ${Python3_EXECUTABLE}

  4. here my Dockerfile to run some tests

JavaScript

To Build:

JavaScript

To Play (i.e. stop a devel stage then spawn a container to play):

JavaScript

So you modified CMakeLists.txt

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement