-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
145 lines (119 loc) · 4.17 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
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
cmake_minimum_required(VERSION 3.25)
set(PLATFORM "win" CACHE STRING "Platform")
set(ARCH "x64" CACHE STRING "Arch")
option(BUILD_SHARED "Option to build shared library" ON)
option(BUILD_STATIC "Option to build static library" ON)
message(STATUS "PLATFORM: ${PLATFORM}")
message(STATUS "ARCH: ${ARCH}")
message(STATUS "BUILD_SHARED: ${BUILD_SHARED}")
message(STATUS "BUILD_STATIC: ${BUILD_STATIC}")
if(PLATFORM STREQUAL "macos")
set(CMAKE_OSX_DEPLOYMENT_TARGET 14.0)
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator")
set(CMAKE_SYSTEM_NAME iOS)
if (PLATFORM STREQUAL "ios-simulator")
set(CMAKE_OSX_SYSROOT iphonesimulator)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 17.0)
elseif(PLATFORM STREQUAL "tvos")
set(CMAKE_SYSTEM_NAME tvOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET 17.0)
elseif(PLATFORM STREQUAL "android")
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_SYSTEM_VERSION 30)
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
endif()
file(READ src/serum-version.h version)
string(REGEX MATCH "SERUM_VERSION_MAJOR[ ]+([0-9]+)" _tmp ${version})
set(VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "SERUM_VERSION_MINOR[ ]+([0-9]+)" _tmp ${version})
set(VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "SERUM_VERSION_PATCH[ ]+([0-9]+)" _tmp ${version})
set(VERSION_PATCH "${CMAKE_MATCH_1}")
project(serum VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
DESCRIPTION "Cross-platform library for decoding Serum files, a colorization format for pinball ROMs.")
if(PLATFORM STREQUAL "win")
if(ARCH STREQUAL "x86")
add_compile_definitions(WIN32)
endif()
elseif(PLATFORM STREQUAL "macos")
if (ARCH STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES arm64)
elseif(ARCH STREQUAL "x64")
set(CMAKE_OSX_ARCHITECTURES x86_64)
endif()
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "@executable_path")
elseif(PLATFORM STREQUAL "ios" OR PLATFORM STREQUAL "ios-simulator" OR PLATFORM STREQUAL "tvos")
set(CMAKE_OSX_DEPLOYMENT_TARGET 16.0)
set(CMAKE_OSX_ARCHITECTURES arm64)
elseif(PLATFORM STREQUAL "linux" OR PLATFORM STREQUAL "android")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(SERUM_SOURCES
src/serum-decode.h
src/serum-decode.cpp
third-party/include/miniz/miniz.h
third-party/include/miniz/miniz.c
)
set(SERUM_INCLUDE_DIRS
src
third-party/include
)
if(BUILD_SHARED)
add_library(serum_shared SHARED ${SERUM_SOURCES})
target_include_directories(serum_shared PUBLIC ${SERUM_INCLUDE_DIRS})
if(PLATFORM STREQUAL "win" AND ARCH STREQUAL "x64")
set(SERUM_OUTPUT_NAME "serum64")
else()
set(SERUM_OUTPUT_NAME "serum")
endif()
set_target_properties(serum_shared PROPERTIES
OUTPUT_NAME ${SERUM_OUTPUT_NAME}
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
)
install(TARGETS serum_shared
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
install(FILES
src/serum.h
src/serum-decode.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")
add_executable(serum_test
src/test.cpp
)
target_link_libraries(serum_test PUBLIC serum_shared)
endif()
endif()
if(BUILD_STATIC)
add_library(serum_static STATIC ${SERUM_SOURCES})
target_include_directories(serum_static PUBLIC ${SERUM_INCLUDE_DIRS})
if(PLATFORM STREQUAL "win")
set_target_properties(serum_static PROPERTIES
OUTPUT_NAME "serum_static"
)
else()
set_target_properties(serum_static PROPERTIES
OUTPUT_NAME "serum"
)
endif()
install(TARGETS serum_static
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)
install(FILES
src/serum.h
src/serum-decode.h
DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")
add_executable(serum_test_s
src/test.cpp
)
target_link_libraries(serum_test_s PUBLIC serum_static)
endif()
endif()