-
Notifications
You must be signed in to change notification settings - Fork 55
/
CMakeLists.txt
88 lines (74 loc) · 3.34 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
cmake_minimum_required(VERSION 3.18)
# MinSizeRel is the preferred default for building the SDK.
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type selected, default to MinSizeRel")
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Build type (default MinSizeRel)" FORCE)
endif()
project(llvm-mos-sdk LANGUAGES C CXX ASM)
include(ExternalProject)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
option(LLVM_MOS_BUILD_EXAMPLES "Build examples for all supported platforms." On)
if(NOT CMAKE_CROSSCOMPILING)
# Fetch LLVM-MOS for the host and install it into the prefix.
include(find-mos-compiler)
find_mos_compiler(LLVM_MOS_C_COMPILER mos-clang)
find_mos_compiler(LLVM_MOS_CXX_COMPILER mos-clang++)
find_mos_compiler(LLVM_MOS_ASM_COMPILER mos-clang)
set(bootstrap_compiler Off)
if(NOT LLVM_MOS_BOOTSTRAP_COMPILER AND
LLVM_MOS_C_COMPILER AND LLVM_MOS_CXX_COMPILER AND LLVM_MOS_ASM_COMPILER)
message(STATUS "Found MOS compiler: ${LLVM_MOS_C_COMPILER}")
else()
message(STATUS "Did not find MOS compiler - Enabling bootstrap download.")
set(bootstrap_compiler On)
endif()
option(LLVM_MOS_BOOTSTRAP_COMPILER
"Should I download a working LLVM-MOS compiler for use with this SDK?"
${bootstrap_compiler})
include(bootstrap-compiler)
if(LLVM_MOS_BOOTSTRAP_COMPILER AND llvm-mos_SOURCE_DIR)
unset(LLVM_MOS_C_COMPILER)
unset(LLVM_MOS_CXX_COMPILER)
unset(LLVM_MOS_ASM_COMPILER)
set(LLVM_MOS ${llvm-mos_SOURCE_DIR})
find_mos_compiler(LLVM_MOS_C_COMPILER mos-clang)
find_mos_compiler(LLVM_MOS_CXX_COMPILER mos-clang++)
find_mos_compiler(LLVM_MOS_ASM_COMPILER mos-clang)
if(LLVM_MOS_C_COMPILER AND LLVM_MOS_CXX_COMPILER AND LLVM_MOS_ASM_COMPILER)
message(STATUS "Found MOS compiler: ${LLVM_MOS_C_COMPILER}")
install(DIRECTORY ${llvm-mos_SOURCE_DIR}/ DESTINATION . USE_SOURCE_PERMISSIONS)
else()
message(FATAL_ERROR "Downloaded llvm-mos is not usable.")
endif()
endif()
find_program(EMUTEST_COMMAND NAMES emutest emutest.exe
PATHS ENV EMUTEST_DIR)
message(STATUS "Emutest test runner: ${EMUTEST_COMMAND}")
find_library(LIBRETRO_STELLA_CORE
NAMES
stella2014_libretro.so stella2014_libretro.dylib stella2014_libretro.dll
stella_libretro.so stella_libretro.dylib stella_libretro.dll
PATHS /lib64/libretro ENV LIBRETRO_CORES_DIR)
message(STATUS "Libretro Stella core: ${LIBRETRO_STELLA_CORE}")
find_library(LIBRETRO_MESEN_CORE
NAMES mesen_libretro.so mesen_libretro.dylib mesen_libretro.dll
PATHS /lib64/libretro ENV LIBRETRO_CORES_DIR)
message(STATUS "Libretro MESEN core: ${LIBRETRO_MESEN_CORE}")
# Install toolchain and config file for users of find_package(llvm-mos-sdk).
# CMake's find_package logic will discover
# `$PATH/../lib/cmake/llvm-mos-sdk/llvm-mos-sdk-config.cmake` which in turn
# sets the toolchain file. The project command will then have all information
# to set up the llvm-mos compiler.
install(FILES
cmake/llvm-mos-toolchain.cmake
cmake/llvm-mos-sdk-config.cmake
cmake/find-mos-compiler.cmake
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
# Install example files.
install(DIRECTORY ${CMAKE_SOURCE_DIR}/examples DESTINATION .)
add_subdirectory(utils)
endif()
add_subdirectory(mos-platform)
if(NOT CMAKE_CROSSCOMPILING)
add_subdirectory(test)
endif()