[CMake] Running Python unit tests importing modules built in CMake

Lori A. Pritchett-Sheats lpritch at lanl.gov
Wed May 2 17:17:57 EDT 2012


I'm building Python modules using SWIG and CMake, and have run into a 
problem running Python unit tests for these built modules. I can not 
find a slick way to set the Python module search path when running the 
test. The usual trick of setting sys.path in the scripts will not work 
here because I don't know the location of the build directory. I've 
tried updating PYTHONPATH in my CMakeList.txt file but that change isn't 
picked up when the test is executed. I could create the unit test 
modules at build time using CONFIGURE_FILE replacing 
@CMAKE_CURRENT_BINARY_DIR@ in a sys.path line, but that seems 
heavy-handed. Has anyone else run into this problem and found better a 
solution?

-- 
Lori A. Pritchett-Sheats, PhD.
CCS-2, Computational Physics and Methods
Office: 505-665-6675
Fax: 505-665-4972

Los Alamos National Laboratory
P.O. Box 1663
MS D413
Los Alamos, NM 87544



More information about the CMake mailing list