Skip to content Skip to sidebar Skip to footer

How To Set Environment Variable For Build Time In Cmake?

I have a python script that generates .cpp sources that are used in consequent compilation. The script uses some 3rd-party modules, and I'm trying to set PYTHONPATH to modules loca

Solution 1:

You can use CMake's Command-Line Tool Mode:

add_custom_command(
    ... 
    COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH="/path/to/modules" python the_script.py
)

Post a Comment for "How To Set Environment Variable For Build Time In Cmake?"