aboutsummaryrefslogtreecommitdiff
path: root/ports/forge/cmake_config.patch
blob: eb77265a0e70fc1db6bcbf1d839616145519ae9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
diff --git a/CMakeModules/ForgeConfig.cmake.in b/CMakeModules/ForgeConfig.cmake.in
index e4c7737..5a3b000 100644
--- a/CMakeModules/ForgeConfig.cmake.in
+++ b/CMakeModules/ForgeConfig.cmake.in
@@ -57,16 +57,24 @@ if (NOT TARGET Forge::forge AND
 endif ()
 
 if (TARGET Forge::forge)
-    get_property(config TARGET Forge::forge PROPERTY IMPORTED_CONFIGURATIONS)
-    if(NOT config)
-      set(config "NOCONFIG")
+    get_property(configs TARGET Forge::forge PROPERTY IMPORTED_CONFIGURATIONS)
+    if(NOT configs)
+        set(configs "NOCONFIG")
     endif()
-    get_property(loc TARGET Forge::forge PROPERTY IMPORTED_LOCATION_${config})
+    foreach(config IN LISTS configs)
+        get_property(loc TARGET Forge::forge PROPERTY IMPORTED_LOCATION_${config})
+
+        # break if any of the imported configurations exist. All configs write to the same
+        # location so they are not working as CMake intended. Its fine for single config
+        # installers like ours.
+        if(EXISTS ${loc})
+            set(Forge_BINARY_EXISTS TRUE)
+            break()
+        endif()
+    endforeach()
 endif ()
 
-if ((TARGET Forge::forge AND EXISTS ${loc})
-    OR
-    TARGET forge)
+if ((TARGET Forge::forge AND Forge_BINARY_EXISTS) OR TARGET forge)
     set(Forge_FOUND ON)
     if (TARGET forge AND NOT TARGET Forge::forge)
         add_library(Forge::forge ALIAS forge)
@@ -75,3 +83,22 @@ if ((TARGET Forge::forge AND EXISTS ${loc})
 else ()
     set(Forge_FOUND OFF)
 endif ()
+
+if(Forge_FOUND)
+    # Check for dependencies when Forge binary and cmake files are found
+    include(CMakeFindDependencyMacro)
+
+    find_dependency(glad CONFIG)
+    find_dependency(glfw3 CONFIG)
+    find_dependency(freetype CONFIG)
+    find_dependency(freeimage CONFIG)
+    find_dependency(OpenGL)
+
+    if(NOT WIN32)
+        find_package(PkgConfig REQUIRED)
+        pkg_check_modules(fontconfig REQUIRED)
+        if(NOT fontconfig_FOUND)
+            message(FATAL_ERROR "Please install Fontconfig dependency")
+        endif()
+    endif()
+endif()