forked from AntonioND/ucity-advance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
86 lines (62 loc) · 2.23 KB
/
CMakeLists.txt
File metadata and controls
86 lines (62 loc) · 2.23 KB
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
# SPDX-License-Identifier: GPL-3.0-only
#
# Copyright (c) 2020-2021 Antonio Niño Díaz
cmake_minimum_required(VERSION 3.15)
# Name this project the same way as the folder it's in
get_filename_component(EXECUTABLE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${EXECUTABLE_NAME})
# Set installation settings
# -------------------------
# When invoking cmake install, install binaries to build directory
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install/" CACHE PATH
"Default install path" FORCE)
# Set RPATH so that Linux looks for the libraries in the same folder. This needs
# to go before any add_executable() or add_library()
set(CMAKE_INSTALL_RPATH "$ORIGIN")
# Declare binary
# --------------
add_executable(${EXECUTABLE_NAME})
# Link with libugba
# -----------------
# Get absolute path to default libugba folder
if("${UGBA_PATH}" STREQUAL "")
get_filename_component(UGBA_PATH ../ugba ABSOLUTE)
endif()
if(EXISTS ${UGBA_PATH})
add_subdirectory(${UGBA_PATH} libugba)
else()
message(FATAL_ERROR "ugba folder not found")
endif()
target_link_libraries(${EXECUTABLE_NAME} libugba)
# Link with UMOD Player
# ---------------------
# Feel free to remove the option of the two provided that you don't need.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/audio)
get_filename_component(UMOD_PLAYER_PATH ../umod-player ABSOLUTE)
if(EXISTS ${UMOD_PLAYER_PATH})
add_subdirectory(${UMOD_PLAYER_PATH} umod_player)
else()
message(FATAL_ERROR "UMOD Player repository not found")
endif()
target_link_libraries(${EXECUTABLE_NAME} umod_player)
endif()
# Add source code files
# ---------------------
# Macro that searches all the source files in the specified directory in 'dir'
# and its subdirectories, and saves them in 'var'
macro(search_source_files dir var)
file(GLOB_RECURSE ${var} CONFIGURE_DEPENDS ${dir}/*.c ${dir}/*.h)
endmacro()
search_source_files(source FILES_SOURCE)
search_source_files(built_assets FILES_BUILT_ASSETS)
target_sources(${EXECUTABLE_NAME} PRIVATE
${FILES_SOURCE}
${FILES_BUILT_ASSETS}
)
target_include_directories(${EXECUTABLE_NAME} PRIVATE
source
built_assets
)
# Define install targets
# ----------------------
install(TARGETS ${EXECUTABLE_NAME} libugba DESTINATION .)