diff --git a/CMakeLists.txt b/CMakeLists.txt index 65ac4bdd4..01865fcf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -450,7 +450,17 @@ include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_INCLUDES ${LENSFUN_INCLUDE_DIRS}) set(CMAKE_REQUIRED_LIBRARIES) foreach(l ${LENSFUN_LIBRARIES}) - find_library(_l ${l} PATHS ${LENSFUN_LIBRARY_DIRS} NO_DEFAULT_PATH) + if(LENSFUN_LIBRARY_DIRS) + # the NO_DEFAULT_PATH is to make sure we find the lensfun version we + # want, and not the system's one (e.g. if we have a custom version + # installed in a non-standard location) + find_library(_l ${l} PATHS ${LENSFUN_LIBRARY_DIRS} NO_DEFAULT_PATH) + else() + # LENSFUN_LIBRARY_DIRS can be empty if lensfun is installed in the + # default path. In this case, adding NO_DEFAULT_PATH would make + # find_library fail... + find_library(_l ${l}) + endif() set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${_l}) endforeach() check_cxx_source_compiles(