diff CMakeLists.txt @ 232:ff0061e75f0f

theme: add OS detection with glib
author Paper <mrpapersonic@gmail.com>
date Sat, 13 Jan 2024 11:06:16 -0500
parents f784b5b1914c
children a7d0d543b334
line wrap: on
line diff
--- a/CMakeLists.txt	Sat Jan 13 09:43:41 2024 -0500
+++ b/CMakeLists.txt	Sat Jan 13 11:06:16 2024 -0500
@@ -125,6 +125,8 @@
 	rc/locale/es.ts
 )
 
+set(DEFINES)
+
 set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale")
 
 if(UPDATE_TRANSLATIONS)
@@ -165,6 +167,7 @@
 		src/sys/osx/filesystem.cc
 		${app_icon_osx}
 	)
+	list(APPEND DEFINES MACOSX)
 elseif(WIN32) # Windows
 	configure_file(
 		${CMAKE_CURRENT_SOURCE_DIR}/rc/win32/version.rc.in
@@ -176,17 +179,31 @@
 		rc/win32/resource.rc
 		${CMAKE_CURRENT_BINARY_DIR}/rc/version.rc
 	)
-elseif(LINUX)
-	configure_file(
-		${CMAKE_CURRENT_SOURCE_DIR}/rc/linux/Minori.desktop.in
-		${CMAKE_CURRENT_BINARY_DIR}/rc/Minori.desktop
-		@ONLY
-	)
-	configure_file(
-		${CMAKE_CURRENT_SOURCE_DIR}/rc/favicon256.png
-		${CMAKE_CURRENT_BINARY_DIR}/rc/Minori.png
-		COPYONLY
-	)
+	list(APPEND DEFINES WIN32)
+else()
+	if(LINUX)
+		configure_file(
+			${CMAKE_CURRENT_SOURCE_DIR}/rc/linux/Minori.desktop.in
+			${CMAKE_CURRENT_BINARY_DIR}/rc/Minori.desktop
+			@ONLY
+		)
+		configure_file(
+			${CMAKE_CURRENT_SOURCE_DIR}/rc/favicon256.png
+			${CMAKE_CURRENT_BINARY_DIR}/rc/Minori.png
+			COPYONLY
+		)
+	endif()
+
+	find_package(PkgConfig)
+	if (PKG_CONFIG_FOUND)
+		pkg_check_modules(GLIB gio-2.0 glib-2.0)
+		if (GLIB_FOUND)
+			list(APPEND SRC_FILES src/sys/glib/dark_theme.cc)
+			list(APPEND INCLUDE ${GLIB_INCLUDE_DIRS})
+			list(APPEND LIBRARIES ${GLIB_LINK_LIBRARIES})
+			list(APPEND DEFINES GLIB)
+		endif()
+	endif()
 endif()
 
 add_executable(minori WIN32 MACOSX_BUNDLE ${SRC_FILES})
@@ -194,16 +211,13 @@
 set_property(TARGET minori PROPERTY AUTOMOC ON)
 set_property(TARGET minori PROPERTY AUTORCC ON)
 
-target_include_directories(minori PUBLIC ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} PRIVATE ${INCLUDE})
+target_include_directories(minori PRIVATE ${Qt${QT_VERSION_MAJOR}Widgets_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} PUBLIC ${INCLUDE})
+target_link_libraries(minori PRIVATE ${LIBRARIES})
 target_compile_options(minori PRIVATE -Wall -Wpedantic -Wextra -Wsuggest-override -Wold-style-cast)
+target_compile_definitions(minori PRIVATE ${DEFINES})
+
 if(APPLE)
-	target_compile_definitions(minori PUBLIC MACOSX)
 	set_target_properties(minori PROPERTIES MACOSX_BUNDLE TRUE)
 elseif(WIN32)
-	target_compile_definitions(minori PUBLIC WIN32)
-endif()
-target_link_libraries(minori ${LIBRARIES})
-
-if(WIN32)
 	install(FILES $<TARGET_RUNTIME_DLLS:minori> TYPE BIN)
 endif()