From d92b0b8177fd53c48afab941c4719c0d83847f7e Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 14 Nov 2020 18:54:10 -0500 Subject: [PATCH] XXX CMakeLists: Always use `zstd::zstd`, not just on Windows This seems to be required in order to actually use the flags for the copy of zstd found by the top-level CMakeLists. Without it, it seems to blindly add -lzstd, which breaks the build for me since my copy of zstd is not in the default library path. Originally this used `zstd`, not `zstd::zstd`, on all platforms. Commit 2cbce77 ("CMakeLists: use system zstd on Linux") made it platform-dependent: despite its title, it changed the behavior on Windows to use `zstd::zstd`, while leaving the behavior on Linux unchanged. I'm pretty sure `zstd::zstd` is the right choice on all platforms, but by accident `zstd` also works on Linux because the library happens to (usually) be installed in /usr/lib. --- CMakeLists.txt | 2 +- externals/find-modules/Findfmt.cmake | 7 +++---- externals/find-modules/Findnlohmann_json.cmake | 3 +-- src/common/CMakeLists.txt | 9 ++------- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2732603789..7df1ace4bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,7 +136,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) # If not found, download any missing through Conan # ======================================================================= set(CONAN_CMAKE_SILENT_OUTPUT TRUE) -set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE) +set(CMAKE_FIND_PACKAGE_PREFER_CONFIG FALSE) if (YUZU_CONAN_INSTALLED) if (IS_MULTI_CONFIG) include(${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake) diff --git a/externals/find-modules/Findfmt.cmake b/externals/find-modules/Findfmt.cmake index 8ba51cbea2..4f81721a11 100644 --- a/externals/find-modules/Findfmt.cmake +++ b/externals/find-modules/Findfmt.cmake @@ -3,9 +3,8 @@ find_package(PkgConfig QUIET) pkg_check_modules(PC_fmt QUIET fmt) find_path(fmt_INCLUDE_DIR - NAMES format.h + NAMES fmt/format.h PATHS ${PC_fmt_INCLUDE_DIRS} ${CONAN_INCLUDE_DIRS_fmt} - PATH_SUFFIXES fmt ) find_library(fmt_LIBRARY @@ -14,9 +13,9 @@ find_library(fmt_LIBRARY ) if(fmt_INCLUDE_DIR) - set(_fmt_version_file "${fmt_INCLUDE_DIR}/core.h") + set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/core.h") if(NOT EXISTS "${_fmt_version_file}") - set(_fmt_version_file "${fmt_INCLUDE_DIR}/format.h") + set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/format.h") endif() if(EXISTS "${_fmt_version_file}") # parse "#define FMT_VERSION 60200" to 6.2.0 diff --git a/externals/find-modules/Findnlohmann_json.cmake b/externals/find-modules/Findnlohmann_json.cmake index b0c5b3e4e6..b5cbb08dec 100644 --- a/externals/find-modules/Findnlohmann_json.cmake +++ b/externals/find-modules/Findnlohmann_json.cmake @@ -36,9 +36,8 @@ if(nlohmann_json_FOUND) endif() if(nlohmann_json_FOUND AND NOT TARGET nlohmann_json::nlohmann_json) - add_library(nlohmann_json::nlohmann_json UNKNOWN IMPORTED) + add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED) set_target_properties(nlohmann_json::nlohmann_json PROPERTIES - IMPORTED_LOCATION "${nlohmann_json_LIBRARY}" INTERFACE_COMPILE_OPTIONS "${PC_nlohmann_json_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${nlohmann_json_INCLUDE_DIR}" ) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 56c7e21f59..f05be4618e 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -209,12 +209,7 @@ else() endif() create_target_directory_groups(common) -find_package(Boost 1.71 COMPONENTS context headers REQUIRED) +find_package(Boost 1.71 REQUIRED) target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile) -target_link_libraries(common PRIVATE lz4::lz4 xbyak) -if (MSVC) - target_link_libraries(common PRIVATE zstd::zstd) -else() - target_link_libraries(common PRIVATE zstd) -endif() +target_link_libraries(common PRIVATE lz4::lz4 xbyak zstd::zstd)