From a77b361f890ede566c228010518c16ee18f892ae Mon Sep 17 00:00:00 2001 From: Davis King Date: Sun, 14 Nov 2021 14:05:47 -0500 Subject: [PATCH] Make test python builds nice --- tools/python/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/python/CMakeLists.txt b/tools/python/CMakeLists.txt index 0b68f53e4..a67bba8f9 100644 --- a/tools/python/CMakeLists.txt +++ b/tools/python/CMakeLists.txt @@ -82,4 +82,9 @@ endif() pybind11_add_module(_dlib_pybind11 ${python_srcs}) target_link_libraries(_dlib_pybind11 PRIVATE dlib::dlib) -configure_file(${PROJECT_SOURCE_DIR}/dlib/__init__.py.in ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/dlib/__init__.py) +# When invoked from setup.py CMAKE_LIBRARY_OUTPUT_DIRECTORY will be set. But when you are just building via say +# `cd dlib/tools/python; mkdir build; cd build; cmake ..` it won't be set. It only matters for building the actual +# distribution. So skip this for people building directly with cmake (which they might do when testing stuff). +if (CMAKE_LIBRARY_OUTPUT_DIRECTORY) + configure_file(${PROJECT_SOURCE_DIR}/dlib/__init__.py.in ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/dlib/__init__.py) +endif()