首页 > 解决方案 > 如何让“make”知道其他目录的变化?

问题描述

makeCython 测试代码中创建文件时,我需要make注意存储在其他目录中的 C++ 头文件中所做的更改。所以我想出了以下make文件

CC=python3

compile: setup.py test.pyx test.pxd test.cpp ../source/test_source.cpp ../headers/test_header.h
    $(CC) setup.py build_ext --inplace 

目录结构如下

/cython
    Makefile
    test.pyx
    test.pxd
    test.cpp
    setup.py  
/headers
    test_header.h
/source
    test_source.cpp

在这里,Cython 文件test.pxd直接包含 ,../source/test_source.cpp其中还包含 header /header/test_header.h

makefile 第一次运行并编译。不幸的是,在我对 进行更改后../header/test_header.h,似乎make根本没有注意到这些更改。(但是,所做的更改../source/test_source.cpp被 . 注意到了make。)我知道这很可能是一个依赖问题。但是,在阅读了一些在线教程之后,我仍然不太明白如何正确设置这个依赖链。

标签: c++makefiledependenciescython

解决方案


好吧,这个问题与 Cython 文件更相关,setup.py并已在此处得到解答


推荐阅读