0
我有一個CMake的結構:CMake的FindPackage在從父顯示目錄cmake的文件夾add_subdirectory
mainproject/
mainproject/cmake/FindMyPackage.cmake
mainproject/CMakeLists.txt
plugin/
plugin/CMakeLists.txt
和上述CMakeLists.txt
我打電話
add_subdirectory(${LOOP_SUBDIR}/${subdir} examples/${subdir})
其中添加上述定義的目錄外plugin/CMakeLists.txt
子目錄。
在這第二CMakeLists.txt
我打電話FindPackage(MyPackage REQUIRED)
這給錯誤消息:
CMake Error at [...]/plugin/CMakeLists.txt:9 (find_package):
By not providing "FindMyPackage.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "MyPackage", but
CMake did not find one.
有沒有什麼辦法讓它用在mainproject文件夾中的文件的CMake?