summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2020-04-16 18:17:18 -0400
committerGravatar GitHub2020-04-16 18:17:18 -0400
commit5a067eda843caa3631dcdc96adbb5f77b48af37c (patch)
treecf7d730da6bd222d1244ec6e92b9aa4f391c7777
parentMerge pull request #3659 from bunnei/time-calc-standard-user (diff)
parentexternals: Use shared libraries if possible (diff)
downloadyuzu-5a067eda843caa3631dcdc96adbb5f77b48af37c.tar.gz
yuzu-5a067eda843caa3631dcdc96adbb5f77b48af37c.tar.xz
yuzu-5a067eda843caa3631dcdc96adbb5f77b48af37c.zip
Merge pull request #3675 from degasus/linux_shared_libraries
externals: Use shared libraries if possible
-rw-r--r--externals/CMakeLists.txt83
-rw-r--r--src/core/CMakeLists.txt7
-rw-r--r--src/input_common/CMakeLists.txt2
-rw-r--r--src/web_service/CMakeLists.txt7
4 files changed, 71 insertions, 28 deletions
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index 61ad3487a..d4421f697 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -3,13 +3,27 @@
3set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) 3set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
4include(DownloadExternals) 4include(DownloadExternals)
5 5
6# pkgconfig -- it is used to find shared libraries without cmake modules on linux systems
7find_package(PkgConfig)
8if (NOT PkgConfig_FOUND)
9 function(pkg_check_modules)
10 # STUB
11 endfunction()
12endif()
13
6# Catch 14# Catch
7add_library(catch-single-include INTERFACE) 15add_library(catch-single-include INTERFACE)
8target_include_directories(catch-single-include INTERFACE catch/single_include) 16target_include_directories(catch-single-include INTERFACE catch/single_include)
9 17
10# libfmt 18# libfmt
11add_subdirectory(fmt) 19pkg_check_modules(FMT IMPORTED_TARGET GLOBAL fmt>=6.1.0)
12add_library(fmt::fmt ALIAS fmt) 20if (FMT_FOUND)
21 add_library(fmt::fmt ALIAS PkgConfig::FMT)
22else()
23 message(STATUS "fmt 6.1.0 or newer not found, falling back to externals")
24 add_subdirectory(fmt)
25 add_library(fmt::fmt ALIAS fmt)
26endif()
13 27
14# Dynarmic 28# Dynarmic
15if (ARCHITECTURE_x86_64) 29if (ARCHITECTURE_x86_64)
@@ -30,9 +44,15 @@ add_subdirectory(glad)
30add_subdirectory(inih) 44add_subdirectory(inih)
31 45
32# lz4 46# lz4
33set(LZ4_BUNDLED_MODE ON) 47pkg_check_modules(LIBLZ4 IMPORTED_TARGET GLOBAL liblz4>=1.8.0)
34add_subdirectory(lz4/contrib/cmake_unofficial EXCLUDE_FROM_ALL) 48if (LIBLZ4_FOUND)
35target_include_directories(lz4_static INTERFACE ./lz4/lib) 49 add_library(lz4_static ALIAS PkgConfig::LIBLZ4)
50else()
51 message(STATUS "liblz4 1.8.0 or newer not found, falling back to externals")
52 set(LZ4_BUNDLED_MODE ON)
53 add_subdirectory(lz4/contrib/cmake_unofficial EXCLUDE_FROM_ALL)
54 target_include_directories(lz4_static INTERFACE ./lz4/lib)
55endif()
36 56
37# mbedtls 57# mbedtls
38add_subdirectory(mbedtls EXCLUDE_FROM_ALL) 58add_subdirectory(mbedtls EXCLUDE_FROM_ALL)
@@ -47,15 +67,27 @@ add_library(unicorn-headers INTERFACE)
47target_include_directories(unicorn-headers INTERFACE ./unicorn/include) 67target_include_directories(unicorn-headers INTERFACE ./unicorn/include)
48 68
49# Zstandard 69# Zstandard
50add_subdirectory(zstd/build/cmake EXCLUDE_FROM_ALL) 70pkg_check_modules(LIBZSTD IMPORTED_TARGET GLOBAL libzstd>=1.3.8)
51target_include_directories(libzstd_static INTERFACE ./zstd/lib) 71if (LIBZSTD_FOUND)
72 add_library(libzstd_static ALIAS PkgConfig::LIBZSTD)
73else()
74 message(STATUS "libzstd 1.3.8 or newer not found, falling back to externals")
75 add_subdirectory(zstd/build/cmake EXCLUDE_FROM_ALL)
76 target_include_directories(libzstd_static INTERFACE ./zstd/lib)
77endif()
52 78
53# SoundTouch 79# SoundTouch
54add_subdirectory(soundtouch) 80add_subdirectory(soundtouch)
55 81
56# Opus 82# Opus
57add_subdirectory(opus) 83pkg_check_modules(OPUS IMPORTED_TARGET GLOBAL opus>=1.3.1)
58target_include_directories(opus INTERFACE ./opus/include) 84if (OPUS_FOUND)
85 add_library(opus ALIAS PkgConfig::OPUS)
86else()
87 message(STATUS "opus 1.3.1 or newer not found, falling back to externals")
88 add_subdirectory(opus)
89 target_include_directories(opus INTERFACE ./opus/include)
90endif()
59 91
60# Cubeb 92# Cubeb
61if(ENABLE_CUBEB) 93if(ENABLE_CUBEB)
@@ -75,18 +107,35 @@ if (ENABLE_VULKAN)
75endif() 107endif()
76 108
77# zlib 109# zlib
78add_subdirectory(zlib EXCLUDE_FROM_ALL) 110find_package(ZLIB 1.2.11)
79set(ZLIB_LIBRARIES z) 111if (NOT ZLIB_FOUND)
112 message(STATUS "zlib 1.2.11 or newer not found, falling back to externals")
113 add_subdirectory(zlib EXCLUDE_FROM_ALL)
114 set(ZLIB_LIBRARIES z)
115endif()
80 116
81# libzip 117# libzip
82add_subdirectory(libzip EXCLUDE_FROM_ALL) 118pkg_check_modules(LIBZIP IMPORTED_TARGET GLOBAL libzip>=1.5.3)
119if (LIBZIP_FOUND)
120 add_library(zip ALIAS PkgConfig::LIBZIP)
121else()
122 message(STATUS "libzip 1.5.3 or newer not found, falling back to externals")
123 add_subdirectory(libzip EXCLUDE_FROM_ALL)
124endif()
83 125
84if (ENABLE_WEB_SERVICE) 126if (ENABLE_WEB_SERVICE)
85 # LibreSSL 127 # LibreSSL
86 set(LIBRESSL_SKIP_INSTALL ON CACHE BOOL "") 128 find_package(OpenSSL COMPONENTS Crypto SSL)
87 add_subdirectory(libressl EXCLUDE_FROM_ALL) 129 if (NOT OpenSSL_FOUND)
88 target_include_directories(ssl INTERFACE ./libressl/include) 130 message(STATUS "OpenSSL not found, falling back to externals")
89 target_compile_definitions(ssl PRIVATE -DHAVE_INET_NTOP) 131 set(LIBRESSL_SKIP_INSTALL ON CACHE BOOL "")
132 add_subdirectory(libressl EXCLUDE_FROM_ALL)
133 target_include_directories(ssl INTERFACE ./libressl/include)
134 target_compile_definitions(ssl PRIVATE -DHAVE_INET_NTOP)
135 get_directory_property(OPENSSL_LIBRARIES
136 DIRECTORY libressl
137 DEFINITION OPENSSL_LIBS)
138 endif()
90 139
91 # lurlparser 140 # lurlparser
92 add_subdirectory(lurlparser EXCLUDE_FROM_ALL) 141 add_subdirectory(lurlparser EXCLUDE_FROM_ALL)
@@ -94,6 +143,8 @@ if (ENABLE_WEB_SERVICE)
94 # httplib 143 # httplib
95 add_library(httplib INTERFACE) 144 add_library(httplib INTERFACE)
96 target_include_directories(httplib INTERFACE ./httplib) 145 target_include_directories(httplib INTERFACE ./httplib)
146 target_compile_definitions(httplib INTERFACE -DCPPHTTPLIB_OPENSSL_SUPPORT)
147 target_link_libraries(httplib INTERFACE ${OPENSSL_LIBRARIES})
97 148
98 # JSON 149 # JSON
99 add_library(json-headers INTERFACE) 150 add_library(json-headers INTERFACE)
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 66497a386..c15d9f52f 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -591,11 +591,8 @@ target_link_libraries(core PUBLIC common PRIVATE audio_core video_core)
591target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt json-headers mbedtls opus unicorn) 591target_link_libraries(core PUBLIC Boost::boost PRIVATE fmt json-headers mbedtls opus unicorn)
592 592
593if (YUZU_ENABLE_BOXCAT) 593if (YUZU_ENABLE_BOXCAT)
594 get_directory_property(OPENSSL_LIBS 594 target_compile_definitions(core PRIVATE -DYUZU_ENABLE_BOXCAT)
595 DIRECTORY ${PROJECT_SOURCE_DIR}/externals/libressl 595 target_link_libraries(core PRIVATE httplib json-headers zip)
596 DEFINITION OPENSSL_LIBS)
597 target_compile_definitions(core PRIVATE -DCPPHTTPLIB_OPENSSL_SUPPORT -DYUZU_ENABLE_BOXCAT)
598 target_link_libraries(core PRIVATE httplib json-headers ${OPENSSL_LIBS} zip)
599endif() 596endif()
600 597
601if (ENABLE_WEB_SERVICE) 598if (ENABLE_WEB_SERVICE)
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt
index 2520ba321..a9c2392b1 100644
--- a/src/input_common/CMakeLists.txt
+++ b/src/input_common/CMakeLists.txt
@@ -27,4 +27,4 @@ if(SDL2_FOUND)
27endif() 27endif()
28 28
29create_target_directory_groups(input_common) 29create_target_directory_groups(input_common)
30target_link_libraries(input_common PUBLIC core PRIVATE common ${Boost_LIBRARIES}) 30target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost)
diff --git a/src/web_service/CMakeLists.txt b/src/web_service/CMakeLists.txt
index 01f2d129d..0c9bb0d55 100644
--- a/src/web_service/CMakeLists.txt
+++ b/src/web_service/CMakeLists.txt
@@ -8,9 +8,4 @@ add_library(web_service STATIC
8) 8)
9 9
10create_target_directory_groups(web_service) 10create_target_directory_groups(web_service)
11 11target_link_libraries(web_service PRIVATE common json-headers httplib lurlparser)
12get_directory_property(OPENSSL_LIBS
13 DIRECTORY ${PROJECT_SOURCE_DIR}/externals/libressl
14 DEFINITION OPENSSL_LIBS)
15target_compile_definitions(web_service PRIVATE -DCPPHTTPLIB_OPENSSL_SUPPORT)
16target_link_libraries(web_service PRIVATE common json-headers ${OPENSSL_LIBS} httplib lurlparser)