summaryrefslogtreecommitdiffstats
path: root/mmc_updater/src/CMakeLists.txt
blob: d27fbe0044c7949a6c46b4045b6e3acbf24ea115 (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

add_subdirectory(tests)

find_package(Threads REQUIRED)
include(GenerateCppResourceFile)

set(UPDATER_SOURCES
 AppInfo.cpp
 AppInfo.h
 DirIterator.cpp
 DirIterator.h
 FileUtils.cpp
 FileUtils.h
 Log.cpp
 Log.h
 ProcessUtils.cpp
 ProcessUtils.h
 StandardDirs.cpp
 StandardDirs.h
 UpdateDialog.cpp
 UpdateInstaller.cpp
 UpdateInstaller.h
 UpdateScript.cpp
 UpdateScript.h
 UpdaterOptions.cpp
 UpdaterOptions.h
)

add_definitions(-DTIXML_USE_STL)

if(WIN32)
	set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogWin32.cpp UpdateDialogWin32.h)
endif()

if(UNIX)
	set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogAscii.cpp UpdateDialogAscii.h)
	add_definitions(-Wall -Wconversion)
	if(APPLE)
		set(MAC_DOCK_ICON_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_dock_icon.cpp)
		set(MAC_INFO_PLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_info_plist.cpp)
		generate_cpp_resource_file(resource_macdockicon ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac.icns ${MAC_DOCK_ICON_CPP_FILE})
		generate_cpp_resource_file(resource_macplist ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist ${MAC_INFO_PLIST_FILE})
		set(UPDATER_SOURCES ${UPDATER_SOURCES}
		 MacBundle.h
		 MacBundle.cpp
		 StandardDirs.mm
		 StlSymbolsLeopard.cpp
		 UpdateDialogCocoa.mm
		 UpdateDialogCocoa.h
		 mac_dock_icon.cpp
		 mac_info_plist.cpp
		)
	else() # linuxes and other similar systems
		find_package(GTK2 REQUIRED gtk)
		include_directories(${GTK2_INCLUDE_DIRS})
		add_library(updatergtk SHARED UpdateDialogGtk.cpp UpdateDialogGtk.h)
		target_link_libraries(updatergtk ${GTK2_LIBRARIES})

		# embed the GTK helper library into the updater binary.
		# At runtime it will be extracted and loaded if the
		# GTK libraries are available
		get_property(GTK_UPDATER_LIB TARGET updatergtk PROPERTY LOCATION)
		set(GTK_BIN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp)
		generate_cpp_resource_file(resource_updatergtk ${GTK_UPDATER_LIB} ${GTK_BIN_CPP_FILE})
		add_dependencies(resource_updatergtk updatergtk)

		set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogGtkFactory.cpp UpdateDialogGtkFactory.h ${GTK_BIN_CPP_FILE})
	endif()
endif()

add_library(updatershared STATIC ${UPDATER_SOURCES})

target_link_libraries(updatershared anyoption tinyxml)

if(UNIX)
	if(APPLE)
		find_library(COCOA_LIBRARY Cocoa)
		find_library(SECURITY_LIBRARY Security)
		target_link_libraries(updatershared ${SECURITY_LIBRARY} ${COCOA_LIBRARY})
	else()
		add_dependencies(updatershared resource_updatergtk)
	endif()
	target_link_libraries(updatershared pthread dl)
endif()

if(WIN32)
	set(EXE_FLAGS WIN32 resources/updater.rc)
endif()

add_executable(updater ${EXE_FLAGS} main.cpp)

target_link_libraries(updater updatershared)


#### Updater Executable ####
if(WIN32)
	install(TARGETS updater
	 BUNDLE DESTINATION . COMPONENT Runtime
	 LIBRARY DESTINATION . COMPONENT Runtime
	 RUNTIME DESTINATION . COMPONENT Runtime
	)
endif()
if(UNIX)
	if(APPLE)
		install(TARGETS updater
		 BUNDLE DESTINATION . COMPONENT Runtime
		 RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime
		)
	else()
		install(TARGETS updater
		 BUNDLE DESTINATION . COMPONENT Runtime
		 RUNTIME DESTINATION bin COMPONENT Runtime
		)
	endif()
endif()