diff --git a/CMakeLists.txt b/CMakeLists.txt index 589920bc..0e9df4a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,18 +149,33 @@ if(TRACE_IN_RELEASE) endif() find_package(utf8cpp QUIET) -if(NOT utf8cpp_FOUND) - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/utfcpp/CMakeLists.txt) - add_subdirectory("3rdparty/utfcpp") - message(STATUS "Using utfcpp from ${utf8cpp_SOURCE_DIR}") - else() - message(FATAL_ERROR - "utfcpp not found. Either install package (probably utfcpp, utf8cpp, or libutfcpp-dev) " - "or fetch the git submodule using\n" - "git submodule update --init") - endif() -else() +if(utf8cpp_FOUND) message(STATUS "Using utfcpp ${utf8cpp_VERSION} from ${utf8cpp_CONFIG}") +else() + find_path(utf8cpp_INCLUDE_DIR NAMES utf8.h PATH_SUFFIXES utf8cpp + DOC "utf8cpp include directory") + mark_as_advanced(utf8cpp_INCLUDE_DIR) + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(utf8cpp REQUIRED_VARS utf8cpp_INCLUDE_DIR) + if(utf8cpp_FOUND) + set(utf8cpp_INCLUDE_DIRS "${utf8cpp_INCLUDE_DIR}") + if(NOT TARGET utf8::cpp) + add_library(utf8::cpp INTERFACE IMPORTED) + set_target_properties(utf8::cpp PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${utf8cpp_INCLUDE_DIR}") + endif() + message(STATUS "Using utfcpp from ${utf8cpp_INCLUDE_DIR}") + else() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/utfcpp/CMakeLists.txt) + add_subdirectory("3rdparty/utfcpp") + message(STATUS "Using utfcpp from ${utf8cpp_SOURCE_DIR}") + else() + message(FATAL_ERROR + "utfcpp not found. Either install package (probably utfcpp, utf8cpp, or libutfcpp-dev) " + "or fetch the git submodule using\n" + "git submodule update --init") + endif() + endif() endif() add_subdirectory(taglib)