To build with a read-only source directory, the build directory must reside outside of the source directory. For instance, it can be a sibling directory:
cmake -B ../build
cmake --build ../build
Running ctest
is also supported for the read-only source directory:
ctest --test-dir ../build
Note: PR30533 improves this functionality.
To run functional tests with the read-only source directory, choose one of the following options:
- Disable Python bytecode creation:
orpython3 -B ../build/test/functional/test_runner.py
env PYTHONDONTWRITEBYTECODE=1 ../build/test/functional/test_runner.py
UPDATE: Actually, there is no need to force Python to disable bytecode creation. It will skip it automaticaly if filesystem permissions do not allow to write it.
- Specify the Python cache prefix path somewhere outside of the source directory:
orpython3 -X pycache_prefix=$(PWD)/../build ../build/test/functional/test_runner.py
env PYTHONPYCACHEPREFIX=$(PWD)/../build ../build/test/functional/test_runner.py