-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (90 loc) · 3.12 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.5)
# config project
project(sdgbc CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# enable debug symbols if no build type is specified
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Debug)
endif()
# define local include dir
include_directories(include)
# define executable sources
file(GLOB sdgbc_SOURCES
include/*.h
include/audio/*.h
include/debug/*.h
include/hw/*.h
include/hw/apu/*.h
include/hw/cart/*.h
include/hw/cpu/*.h
include/wxui/*.h
include/wxui/winrc/*.rc # windows resource files
include/wxui/xpm/*.h # icon xpms
include/wxui/xpm/*.xpm
src/*.cpp
src/audio/*.cpp
src/debug/*.cpp
src/hw/*.cpp
src/hw/apu/*.cpp
src/hw/cart/*.cpp
src/hw/cpu/*.cpp
src/wxui/*.cpp
)
add_executable(sdgbc WIN32 ${sdgbc_SOURCES})
# macro defs for msvc to disable unsafe warnings from wxWidgets headers
if(MSVC)
target_compile_definitions(sdgbc PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
# setup our modules path
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
# if UNIX, find X11 and also find PkgConfig and use it to find GTK
if(UNIX)
find_package(X11 REQUIRED)
if(X11_FOUND)
message(STATUS "X11 found")
include_directories(${X11_INCLUDE_DIR})
target_link_libraries(sdgbc ${X11_LIBRARIES})
endif()
find_package(PkgConfig REQUIRED)
if(PkgConfig_FOUND)
message(STATUS "PkgConfig found")
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
if(GTK3_FOUND)
message(STATUS "GTK3 found")
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS_OTHER})
target_link_libraries(sdgbc ${GTK3_LIBRARIES})
else()
pkg_check_modules(GTK2 REQUIRED gtk+-2.0)
if(GTK2_FOUND)
message(STATUS "GTK2 found")
include_directories(${GTK2_INCLUDE_DIRS})
link_directories(${GTK2_LIBRARY_DIRS})
add_definitions(${GTK2_CFLAGS_OTHER})
target_link_libraries(sdgbc ${GTK2_LIBRARIES})
endif()
endif()
endif()
endif()
# find wxWidgets
find_package(wxWidgets 3.0 REQUIRED core base)
if(wxWidgets_FOUND)
message(STATUS "wxWidgets found")
include(${wxWidgets_USE_FILE})
target_link_libraries(sdgbc ${wxWidgets_LIBRARIES})
endif()
# find SFML
# NOTE: any version above 2.3.1 causes the program to crash due to an X11
# incompatability for some reason
find_package(SFML 2.3.1 EXACT REQUIRED system window graphics audio)
if(SFML_FOUND)
message(STATUS "SFML found")
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(sdgbc ${SFML_LIBRARIES})
endif()
# install target and extra pre-reqs
install(TARGETS sdgbc DESTINATION bin)
include(InstallRequiredSystemLibraries)