summaryrefslogtreecommitdiff
blob: d801b08317a394fd57e005f453ffa0a82876646a (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
From ae7349b06f86ff60b0d14dfa01b3fe2163dcfbab Mon Sep 17 00:00:00 2001
From: Rafael Kitover <rkitover@gmail.com>
Date: Wed, 13 Nov 2019 02:56:06 +0000
Subject: [PATCH] cmake: Use list var VBAM_LIBS for link libs.

Accumulate link libraries for wxvbam in the VBAM_LIBS list variable
instead of listing every possible library variable in the
target_link_libraries() call.

This fixes the issue with trying to use OPENAL_LIBRARIES when it's set
to NOTFOUND which generates a cmake error.

Fix #563.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
---
 src/wx/CMakeLists.txt | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt
index 13e0cea7..d37c1cdd 100644
--- a/src/wx/CMakeLists.txt
+++ b/src/wx/CMakeLists.txt
@@ -15,6 +15,8 @@ endif()
 
 include(VbamFunctions)
 
+set(VBAM_LIBS ${VBAMCORE_LIBS})
+
 if(WIN32)
     # not yet implemented
     option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)
@@ -46,6 +48,8 @@ if(ENABLE_OPENAL)
 	if(OPENAL_STATIC OR (WIN32 AND ((NOT (MINGW AND MSYS)) OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)))
 		add_definitions(-DAL_LIBTYPE_STATIC)
 	endif()
+
+        list(APPEND VBAM_LIBS ${OPENAL_LIBRARY})
 else()
     add_definitions(-DNO_OAL)
 endif()
@@ -58,18 +62,15 @@ if(NOT ENABLE_XAUDIO2)
     add_definitions(-DNO_XAUDIO2)
 endif()
 
-if(NOT ENABLE_FAUDIO)
-    add_definitions(-DNO_FAUDIO)
-endif()
-
 if(NOT ENABLE_DIRECT3D)
     add_definitions(-DNO_D3D)
 endif()
 
-unset(FAUDIO_LIBS)
 if(ENABLE_FAUDIO)
     find_package(FAudio REQUIRED)
-    set(FAUDIO_LIBS FAudio)
+    list(APPEND VBAM_LIBS FAudio)
+else()
+    add_definitions(-DNO_FAUDIO)
 endif()
 
 # on unix we have to check for X11 before we overwrite all the compile/link
@@ -79,7 +80,7 @@ if(NOT WIN32 AND NOT APPLE)
 
     if(X11_X11_LIB AND X11_Xscreensaver_LIB)
         include_directories(${X11_INCLUDE_DIR})
-        set(EXTRA_X11_LIBS ${X11_X11_LIB} ${X11_Xscreensaver_LIB})
+        list(APPEND VBAM_LIBS ${X11_X11_LIB} ${X11_Xscreensaver_LIB})
         add_definitions(-DHAVE_XSS)
     endif()
 endif()
@@ -419,7 +420,7 @@ int main(int argc, char** argv) {
             include_directories(${GTK4_INCLUDE_DIRS})
             link_directories(${GTK4_LIBRARY_DIRS})
             add_compile_options(${GTK4_CFLAGS_OTHER})
-            set(GTK_LIBRARIES ${GTK4_LIBRARIES})
+            list(APPEND VBAM_LIBS ${GTK4_LIBRARIES})
         elseif(WX_USING_GTK3)
             pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
             if(NOT GTK3_INCLUDE_DIRS)
@@ -428,7 +429,7 @@ int main(int argc, char** argv) {
             include_directories(${GTK3_INCLUDE_DIRS})
             link_directories(${GTK3_LIBRARY_DIRS})
             add_compile_options(${GTK3_CFLAGS_OTHER})
-            set(GTK_LIBRARIES ${GTK3_LIBRARIES})
+            list(APPEND VBAM_LIBS ${GTK3_LIBRARIES})
         else()
             check_cxx_symbol_exists(__WXGTK20__ ${WX_CONFIG_H} WX_USING_GTK2)
             if(WX_USING_GTK2)
@@ -438,7 +439,7 @@ int main(int argc, char** argv) {
                     include_directories(${GTK2_INCLUDE_DIRS})
                     link_directories(${GTK2_LIBRARY_DIRS})
                     add_compile_options(${GTK2_CFLAGS_OTHER})
-                    set(GTK_LIBRARIES ${GTK2_LIBRARIES})
+                    list(APPEND VBAM_LIBS ${GTK2_LIBRARIES})
                 else()
                     # and if that fails, use the cmake module
                     find_package(GTK2 REQUIRED gtk)
@@ -447,7 +448,7 @@ int main(int argc, char** argv) {
                     endif()
                     include_directories(${GTK2_INCLUDE_DIRS})
                     add_compile_options(${GTK2_DEFINITIONS})
-                    set(GTK_LIBRARIES ${GTK2_LIBRARIES})
+                    list(APPEND VBAM_LIBS ${GTK2_LIBRARIES})
                 endif()
             else()
                 find_package(GTK REQUIRED gtk)
@@ -456,6 +457,7 @@ int main(int argc, char** argv) {
                 endif()
                 include_directories(${GTK_INCLUDE_DIRS})
                 add_compile_options(${GTK_DEFINITIONS})
+                list(APPEND VBAM_LIBS ${GTK_LIBRARIES})
             endif()
         endif()
     endif()
@@ -729,14 +731,14 @@ endif()
 
 if(WIN32)
     set(SRC_WX ${SRC_WX} wxvbam.rc dsound.cpp)
-    set(DIRECTX_LIBRARIES dxguid dsound ws2_32)
+    list(APPEND VBAM_LIBS dxguid dsound ws2_32)
     if(MSVC)
         # workaround for some symbols needed by static SDL2.lib
-        set(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} imm32 version)
+        list(APPEND VBAM_LIBS imm32 version)
     endif()
     # not strictly directx, but win32-related
     if(ENABLE_DEBUGGER)
-        set(DIRECTX_LIBRARIES ${DIRECTX_LIBRARIES} wsock32)
+        list(APPEND VBAM_LIBS wsock32)
     endif()
 endif()
 
@@ -783,19 +785,18 @@ endif()
 
 target_link_libraries(
     visualboyadvance-m
-    ${VBAMCORE_LIBS}
     ${wxWidgets_LIBRARIES}
-    ${FFMPEG_LIBRARIES}
-    ${DIRECTX_LIBRARIES}
-    ${GTK_LIBRARIES}
-    ${OPENAL_LIBRARY}
-    ${FAUDIO_LIBS}
-    ${EXTRA_X11_LIBS}
+    ${VBAM_LIBS}
 )
 
 if(ENABLE_FFMPEG)
     join("${FFMPEG_LDFLAGS}" " " FFMPEG_LDFLAGS_STR)
 
+    target_link_libraries(
+        visualboyadvance-m
+        ${FFMPEG_LIBRARIES}
+    )
+
     set_target_properties(
         visualboyadvance-m
         PROPERTIES LINK_FLAGS ${FFMPEG_LDFLAGS_STR}
-- 
2.24.0