Compare commits

...

4 Commits

Author SHA1 Message Date
Markus Wick
e123521a3e externals: Use the conan helper for boost.
This partially reverts 292dd642ce.
The real issue was the missing components in the find_package(boost) call.
This is now fixed here.
2021-04-11 08:15:28 +02:00
Markus Wick
39d9bc15e9 externals: Move qt to yuzu_find_package 2021-04-11 07:52:30 +02:00
Markus Wick
7dff41bf48 externals: Provide an optional Components selection. 2021-04-11 07:52:30 +02:00
Markus Wick
b95a65d150 externals: Implement SDL check with yuzu_find_package 2021-04-11 07:52:30 +02:00
2 changed files with 46 additions and 81 deletions

View File

@@ -163,7 +163,8 @@ macro(yuzu_find_packages)
# Cmake has a *serious* lack of 2D array or associative array... # Cmake has a *serious* lack of 2D array or associative array...
# Capitalization matters here. We need the naming to match the generated paths from Conan # Capitalization matters here. We need the naming to match the generated paths from Conan
set(REQUIRED_LIBS set(REQUIRED_LIBS
# Cmake Pkg Prefix Version Conan Pkg # Cmake Pkg Prefix Version Conan Pkg Components
"Boost 1.73 boost/1.73.0 context headers"
"Catch2 2.13 catch2/2.13.0" "Catch2 2.13 catch2/2.13.0"
"fmt 7.1 fmt/7.1.2" "fmt 7.1 fmt/7.1.2"
# can't use until https://github.com/bincrafters/community/issues/1173 # can't use until https://github.com/bincrafters/community/issues/1173
@@ -176,58 +177,11 @@ macro(yuzu_find_packages)
#"opus 1.3 opus/1.3.1" #"opus 1.3 opus/1.3.1"
) )
foreach(PACKAGE ${REQUIRED_LIBS}) if(ENABLE_SDL2)
string(REGEX REPLACE "[ \t\r\n]+" ";" PACKAGE_SPLIT ${PACKAGE}) list(APPEND REQUIRED_LIBS "SDL2 2.0.10 sdl2/2.0.14@bincrafters/stable")
list(GET PACKAGE_SPLIT 0 PACKAGE_PREFIX)
list(GET PACKAGE_SPLIT 1 PACKAGE_VERSION)
list(GET PACKAGE_SPLIT 2 PACKAGE_CONAN)
# This function is called twice, once to check if the packages exist on the system already
# and a second time to check if conan installed them properly. The second check passes in FORCE_REQUIRED
if (NOT ${PACKAGE_PREFIX}_FOUND)
if (FN_FORCE_REQUIRED)
find_package(${PACKAGE_PREFIX} ${PACKAGE_VERSION} REQUIRED)
else()
find_package(${PACKAGE_PREFIX} ${PACKAGE_VERSION})
endif() endif()
endif()
if (NOT ${PACKAGE_PREFIX}_FOUND)
list(APPEND CONAN_REQUIRED_LIBS ${PACKAGE_CONAN})
else()
# Set a legacy findPackage.cmake style PACKAGE_LIBRARIES variable for subprojects that rely on this
set(${PACKAGE_PREFIX}_LIBRARIES "${PACKAGE_PREFIX}::${PACKAGE_PREFIX}")
endif()
endforeach()
unset(FN_FORCE_REQUIRED)
endmacro()
find_package(Boost 1.73.0 COMPONENTS context headers QUIET) if(ENABLE_QT)
if (Boost_FOUND)
set(Boost_LIBRARIES Boost::boost)
# Conditionally add Boost::context only if the active version of the Conan or system Boost package provides it
# The old version is missing Boost::context, so we want to avoid adding in that case
# The new version requires adding Boost::context to prevent linking issues
#
# This one is used by Conan on subsequent CMake configures, not the first configure.
if (TARGET Boost::context)
list(APPEND Boost_LIBRARIES Boost::context)
endif()
else()
message(STATUS "Boost 1.73.0 or newer not found, falling back to Conan")
list(APPEND CONAN_REQUIRED_LIBS "boost/1.73.0")
endif()
# Attempt to locate any packages that are required and report the missing ones in CONAN_REQUIRED_LIBS
yuzu_find_packages()
# Qt5 requires that we find components, so it doesn't fit our pretty little find package function
if(ENABLE_QT)
# We want to load the generated conan qt config so that we get the QT_ROOT var so that we can use the official
# Qt5Config inside the root folder instead of the conan generated one.
if(EXISTS ${CMAKE_BINARY_DIR}/qtConfig.cmake)
include(${CMAKE_BINARY_DIR}/qtConfig.cmake)
list(APPEND CMAKE_MODULE_PATH "${CONAN_QT_ROOT_RELEASE}")
list(APPEND CMAKE_PREFIX_PATH "${CONAN_QT_ROOT_RELEASE}")
endif()
# Workaround for an issue where conan tries to build Qt from scratch instead of download prebuilt binaries # Workaround for an issue where conan tries to build Qt from scratch instead of download prebuilt binaries
set(QT_PREFIX_HINT) set(QT_PREFIX_HINT)
if(YUZU_USE_BUNDLED_QT) if(YUZU_USE_BUNDLED_QT)
@@ -243,31 +197,48 @@ if(ENABLE_QT)
set(QT_PREFIX_HINT HINTS "${QT_PREFIX}") set(QT_PREFIX_HINT HINTS "${QT_PREFIX}")
endif() endif()
find_package(Qt5 5.9 COMPONENTS Widgets ${QT_PREFIX_HINT})
set(QT_ADDITIONAL_COMPONENTS)
if (YUZU_USE_QT_WEB_ENGINE) if (YUZU_USE_QT_WEB_ENGINE)
find_package(Qt5 COMPONENTS WebEngineCore WebEngineWidgets) set(QT_ADDITIONAL_COMPONENTS "WebEngineCore WebEngineWidgets")
endif() endif()
if (ENABLE_QT_TRANSLATION) if (ENABLE_QT_TRANSLATION)
find_package(Qt5 REQUIRED COMPONENTS LinguistTools ${QT_PREFIX_HINT}) set(QT_ADDITIONAL_COMPONENTS "${QT_ADDITIONAL_COMPONENTS} LinguistTools")
endif() endif()
if (NOT Qt5_FOUND)
list(APPEND CONAN_REQUIRED_LIBS "qt/5.14.1@bincrafters/stable") list(APPEND REQUIRED_LIBS "Qt5 5.11 qt/5.14.1@bincrafters/stable Widgets ${QT_ADDITIONAL_COMPONENTS} ${QT_PREFIX_HINT}")
endif() endif()
endif()
# find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the yuzu_find_package foreach(PACKAGE ${REQUIRED_LIBS})
if(ENABLE_SDL2) string(REGEX REPLACE "[ \t\r\n]+" ";" PACKAGE_SPLIT ${PACKAGE})
if(EXISTS ${CMAKE_BINARY_DIR}/sdl2Config.cmake) list(GET PACKAGE_SPLIT 0 PACKAGE_PREFIX)
include(${CMAKE_BINARY_DIR}/sdl2Config.cmake) list(GET PACKAGE_SPLIT 1 PACKAGE_VERSION)
list(APPEND CMAKE_MODULE_PATH "${CONAN_SDL2_ROOT_RELEASE}") list(GET PACKAGE_SPLIT 2 PACKAGE_CONAN)
list(APPEND CMAKE_PREFIX_PATH "${CONAN_SDL2_ROOT_RELEASE}") list(REMOVE_AT PACKAGE_SPLIT 0 1 2)
set(PACKAGE_COMPONENTS ${PACKAGE_SPLIT})
# This function is called twice, once to check if the packages exist on the system already
# and a second time to check if conan installed them properly. The second check passes in FORCE_REQUIRED
if (NOT ${PACKAGE_PREFIX}_FOUND)
if (FN_FORCE_REQUIRED)
find_package(${PACKAGE_PREFIX} ${PACKAGE_VERSION} REQUIRED COMPONENTS ${PACKAGE_COMPONENTS})
else()
find_package(${PACKAGE_PREFIX} ${PACKAGE_VERSION} COMPONENTS ${PACKAGE_COMPONENTS})
endif() endif()
find_package(SDL2)
if (NOT SDL2_FOUND)
# otherwise add this to the list of libraries to install
list(APPEND CONAN_REQUIRED_LIBS "sdl2/2.0.14@bincrafters/stable")
endif() endif()
endif() if (NOT ${PACKAGE_PREFIX}_FOUND)
list(APPEND CONAN_REQUIRED_LIBS ${PACKAGE_CONAN})
else()
# Set a legacy findPackage.cmake style PACKAGE_LIBRARIES variable for subprojects that rely on this
set(${PACKAGE_PREFIX}_LIBRARIES "${PACKAGE_PREFIX}::${PACKAGE_PREFIX}")
endif()
endforeach()
unset(FN_FORCE_REQUIRED)
endmacro()
# Attempt to locate any packages that are required and report the missing ones in CONAN_REQUIRED_LIBS
yuzu_find_packages()
# Install any missing dependencies with conan install # Install any missing dependencies with conan install
if (CONAN_REQUIRED_LIBS) if (CONAN_REQUIRED_LIBS)
@@ -320,17 +291,6 @@ if (CONAN_REQUIRED_LIBS)
# this time with required, so we bail if its not found. # this time with required, so we bail if its not found.
yuzu_find_packages(FORCE_REQUIRED) yuzu_find_packages(FORCE_REQUIRED)
if (NOT Boost_FOUND)
find_package(Boost 1.73.0 REQUIRED COMPONENTS context headers)
set(Boost_LIBRARIES Boost::boost)
# Conditionally add Boost::context only if the active version of the Conan Boost package provides it
# The old version is missing Boost::context, so we want to avoid adding in that case
# The new version requires adding Boost::context to prevent linking issues
if (TARGET Boost::context)
list(APPEND Boost_LIBRARIES Boost::context)
endif()
endif()
# Due to issues with variable scopes in functions, we need to also find_package(qt5) outside of the function # Due to issues with variable scopes in functions, we need to also find_package(qt5) outside of the function
if(ENABLE_QT) if(ENABLE_QT)
list(APPEND CMAKE_MODULE_PATH "${CONAN_QT_ROOT_RELEASE}") list(APPEND CMAKE_MODULE_PATH "${CONAN_QT_ROOT_RELEASE}")
@@ -360,6 +320,11 @@ elseif (TARGET Boost::boost)
add_library(boost ALIAS Boost::boost) add_library(boost ALIAS Boost::boost)
endif() endif()
# Some boost packages lack the context target, so let's just alias it from the global boost target.
if (NOT TARGET Boost::context)
add_library(Boost::context ALIAS Boost::boost)
endif()
if (TARGET sdl2::sdl2) if (TARGET sdl2::sdl2)
# imported from the conan generated sdl2Config.cmake # imported from the conan generated sdl2Config.cmake
set_target_properties(sdl2::sdl2 PROPERTIES IMPORTED_GLOBAL TRUE) set_target_properties(sdl2::sdl2 PROPERTIES IMPORTED_GLOBAL TRUE)

View File

@@ -215,7 +215,7 @@ endif()
create_target_directory_groups(common) create_target_directory_groups(common)
target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile) target_link_libraries(common PUBLIC Boost::boost Boost::context fmt::fmt microprofile)
target_link_libraries(common PRIVATE lz4::lz4 xbyak) target_link_libraries(common PRIVATE lz4::lz4 xbyak)
if (MSVC) if (MSVC)
target_link_libraries(common PRIVATE zstd::zstd) target_link_libraries(common PRIVATE zstd::zstd)