Hi,
I’ve this random issue that I don’t really understand why it’s happening. So, while ago, I put some time and improved the mlpack
CMake’s script, and I think for the most part I got everything right. But, every now and then, I see this random error where mlpack-targets.cmake
is not being generated correctly.
I’m using this template to generate the mlpack-targets
@PACKAGE_INIT@
include(${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake)
set_and_check(MLPACK_INCLUDE_DIRS "@PACKAGE_MLPACK_INCS_DIR@")
set(MLPACK_LIBRARIES mlpack::mlpack)
but for some reason, the output file, mlpack-targets.cmake
can end up not being complete,
include(${CMAKE_CURRENT_LIST_DIR}/.cmake) # ← **NOTICE HERE**
set_and_check(MLPACK_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
set(MLPACK_LIBRARIES mlpack::mlpack)
This of course causes CMake to throw and not being able to configure mlpack in my project. I think I did everything correctly, but apparently not. My workaround is to manually change this file, but that’s a horrible solution. I really appreciate if someone could help me track this down.
The parent CMakeLists.txt
is here. And, the only thing I can think of is that since CMakeLists.txt
is not in a parent directly, CMake gets confused and cannot handle the case correctly! The project has two CMakeLists.txt
files, and mlpack-config.cmake.in
is not in the same directory as either of them.
mlpack/CMakeLists.txt
mlpack/src/mlpack/CMakeLists.txt
mlpack/CMake/mlpack-config.cmake.in
and this is the error if mlpack-targets.cmake
is incomplete:
CMake Error at /usr/local/lib/cmake/mlpack/mlpack-config.cmake:27 (include):
include could not find load file:
/usr/local/lib/cmake/mlpack/.cmake
Call Stack (most recent call first):
CMakeLists.txt:40 (find_package)
Thanks in advance,
Amir.