summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-11-18 02:56:32 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2021-11-18 02:56:32 +0100
commit6f59f190031f5c760ed505b1a4b79f92036a2b7e (patch)
treed5965c8462ddd838410f1c892cc5445a92405d1e
parentUpdate bundled deps (diff)
downloadnheko-6f59f190031f5c760ed505b1a4b79f92036a2b7e.tar.xz
Fix hunter messing with pkg-config
-rw-r--r--CMakeLists.txt64
1 files changed, 56 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 42c04cdd..6340fc3c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -23,6 +23,23 @@ HunterGate(
 	LOCAL
 	)
 
+macro(hunter_add_package_safe)
+	set(pkg_temp_backup_libdir "$ENV{PKG_CONFIG_LIBDIR}")
+	set(pkg_temp_backup_path "$ENV{PKG_CONFIG_PATH}")
+	hunter_add_package(${ARGV})
+	if("${pkg_temp_backup_path}" STREQUAL "")
+		unset(ENV{PKG_CONFIG_PATH})
+	else()
+		set(ENV{PKG_CONFIG_PATH} "${pkg_temp_backup_path}")
+	endif()
+	if("${pkg_temp_backup_libdir}" STREQUAL "")
+		unset(ENV{PKG_CONFIG_LIBDIR})
+	else()
+		set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup_libdir}")
+	endif()
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+endmacro()
+
 option(USE_BUNDLED_SPDLOG "Use the bundled version of spdlog." ${HUNTER_ENABLED})
 option(USE_BUNDLED_OLM "Use the bundled version of libolm." ${HUNTER_ENABLED})
 option(USE_BUNDLED_GTEST "Use the bundled version of Google Test." ${HUNTER_ENABLED})
@@ -120,10 +137,16 @@ endif()
 #
 ## Need to repeat all libevent deps?!?
 if (USE_BUNDLED_LIBEVENT)
-	hunter_add_package(Libevent)
+	hunter_add_package_safe(Libevent)
 	find_package(Libevent CONFIG REQUIRED)
 else()
 	find_package(PkgConfig REQUIRED) 
+if (HUNTER_ENABLED)
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+	set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_LIBDIR}")
+	set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup}")
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+endif()
 	pkg_check_modules(libevent_core REQUIRED IMPORTED_TARGET libevent_core)
 	if (WIN32)
 		pkg_check_modules(libevent_windows REQUIRED IMPORTED_TARGET libevent_windows)
@@ -135,16 +158,22 @@ endif()
 
 # curl
 if (USE_BUNDLED_LIBCURL)
-	hunter_add_package(CURL)
+	hunter_add_package_safe(CURL)
 	find_package(CURL CONFIG REQUIRED)
 else()
 	find_package(PkgConfig REQUIRED) 
+if (HUNTER_ENABLED)
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+	set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_LIBDIR}")
+	set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup}")
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+endif()
 	pkg_check_modules(libcurl REQUIRED IMPORTED_TARGET libcurl)
 endif()
 
 # spdlog
 if(USE_BUNDLED_SPDLOG)
-	hunter_add_package(spdlog)
+	hunter_add_package_safe(spdlog)
 endif()
 find_package(spdlog 1.0.0 CONFIG REQUIRED)
 
@@ -153,7 +182,7 @@ find_package(spdlog 1.0.0 CONFIG REQUIRED)
 #
 #include(LMDB)
 if(USE_BUNDLED_LMDB)
-	hunter_add_package(lmdb)
+	hunter_add_package_safe(lmdb)
 	find_package(liblmdb CONFIG REQUIRED)
 
 	target_include_directories(liblmdb::lmdb INTERFACE
@@ -170,6 +199,12 @@ find_package(Qt5QuickCompiler)
 find_package(Qt5DBus)
 
 if (USE_BUNDLED_QTKEYCHAIN)
+if (HUNTER_ENABLED)
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+	set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_LIBDIR}")
+	set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup}")
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+endif()
 	include(FetchContent)
 	FetchContent_Declare(
 		qt5keychain
@@ -380,7 +415,7 @@ include(FeatureSummary)
 
 
 if(USE_BUNDLED_OPENSSL)
-	hunter_add_package(OpenSSL)
+	hunter_add_package_safe(OpenSSL)
 endif()
 find_package(OpenSSL 1.1.0 REQUIRED)
 if(USE_BUNDLED_MTXCLIENT)
@@ -414,7 +449,7 @@ else()
 		)
 endif()
 if(USE_BUNDLED_SPDLOG)
-	hunter_add_package(spdlog)
+	hunter_add_package_safe(spdlog)
 endif()
 find_package(spdlog 1.0.0 CONFIG REQUIRED)
 
@@ -437,7 +472,7 @@ else()
 endif()
 
 if(USE_BUNDLED_JSON)
-	hunter_add_package(nlohmann_json)
+	hunter_add_package_safe(nlohmann_json)
 endif()
 find_package(nlohmann_json 3.2.0)
 set_package_properties(nlohmann_json PROPERTIES
@@ -474,8 +509,15 @@ else()
 	add_library(lmdbxx::lmdbxx ALIAS lmdbxx)
 endif()
 
+if (HUNTER_ENABLED)
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+	set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_LIBDIR}")
+	set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup}")
+	unset(ENV{PKG_CONFIG_LIBDIR})
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+endif()
 include(FindPkgConfig)
-pkg_check_modules(GSTREAMER IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18)
+pkg_check_modules(GSTREAMER NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18)
 if (TARGET PkgConfig::GSTREAMER)
 	add_feature_info(voip ON "GStreamer found. Call support is enabled automatically.")
 	pkg_check_modules(XCB IMPORTED_TARGET xcb xcb-ewmh)
@@ -700,6 +742,12 @@ elseif(coeurl_DIR)
 	target_link_libraries(nheko PUBLIC coeurl::coeurl)
 else()
 	find_package(PkgConfig REQUIRED)
+if (HUNTER_ENABLED)
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+	set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_LIBDIR}")
+	set(ENV{PKG_CONFIG_LIBDIR} "${pkg_temp_backup}")
+	message("pkg_conf_path: '$ENV{PKG_CONFIG_PATH}', pkg_conf_libdir: '$ENV{PKG_CONFIG_LIBDIR}'")
+endif()
 	pkg_check_modules(coeurl REQUIRED IMPORTED_TARGET coeurl)
 	target_link_libraries(nheko PUBLIC PkgConfig::coeurl)
 endif()