-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
118 lines (101 loc) · 4.55 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
# This CMakeLists file is modified from the CMake example from Check.
# Copyright (c) 2021, Richard Taylor
# Original licence and copyright notice for Check example below:
#
# Copyright (c) 2017, Branden Archer
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of this project nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL Branden Archer BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
project(Emu8080 C)
#3.12.1 is needed for finding SDL2
cmake_minimum_required(VERSION 3.12.1 FATAL_ERROR)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
###############################################################################
# Set build features
set(CMAKE_BUILD_TYPE Debug)
###############################################################################
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckTypeSize)
###############################################################################
# Check headers
set(INCLUDES "")
macro(ck_check_include_file header var)
check_include_files("${INCLUDES};${header}" ${var})
if(${var})
set(INCLUDES ${INCLUDES} ${header})
endif(${var})
endmacro(ck_check_include_file)
ck_check_include_file("stdlib.h" HAVE_STDLIB_H)
###############################################################################
# Check functions
# (Nothing to check)
###############################################################################
# Check defines
# (Nothing to check)
###############################################################################
# Check struct members
# (Nothing to check)
###############################################################################
# Check for integer types
# (The following are used in check.h. Regardless if they are used in
# the project, they will need to be checked in order to use Check).
check_type_size(intmax_t INTMAX_T)
check_type_size(uintmax_t UINTMAX_T)
check_type_size(pid_t PID_T)
if(NOT HAVE_PID_T)
if(WIN32)
set(pid_t "int")
else(WIN32)
MESSAGE(FATAL_ERROR "pid_t doesn't exist on this platform?")
endif(WIN32)
endif(NOT HAVE_PID_T)
###############################################################################
# Check libraries
###############################################################################
# Generate "config.h" from "cmake/config.h.cmake"
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DHAVE_CONFIG_H)
set(CONFIG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/config.h)
###############################################################################
# find SDL2
find_package(SDL2)
###############################################################################
# Subdirectories
add_subdirectory(src)
add_subdirectory(tests)
###############################################################################
# Unit tests
enable_testing()
add_test(NAME test_cpu COMMAND test_cpu)
# Integration test for CPU instructions
if (EXISTS ${CMAKE_SOURCE_DIR}/tests/cpudiag.bin)
add_test(NAME cpudiag COMMAND cpudiag_shell ${CMAKE_SOURCE_DIR}/tests/cpudiag.bin)
endif (EXISTS ${CMAKE_SOURCE_DIR}/tests/cpudiag.bin)