forked from libcpu/libcpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
106 lines (88 loc) · 2.83 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
PROJECT(libcpu)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE(FindThreads)
#
#
#
SET(CMAKE_BUILD_TYPE "Debug")
#
# Add here the architecture you want to support.
#
SET(GUEST_ARCHITECTURES 6502 m68k m88k mips arm x86 fapra)
SET(GUEST_EXTRA_TESTS multi)
IF(APPLE)
SET(GUEST_EXTRA_TESTS ${GUEST_EXTRA_TESTS} next68k)
ENDIF(APPLE)
#
# Build Universal image.
#
IF(APPLE)
OPTION(UNIVERSAL "Build Universal Executable" OFF)
ENDIF(APPLE)
IF(APPLE AND UNIVERSAL)
INCLUDE(CMake/AppleMultiArch.cmake)
ENDIF()
#
# Find LLVM, we need it.
#
SET(LLVM_FIND_REQUIRED TRUE)
INCLUDE(CMake/FindLLVM.cmake)
INCLUDE(CMake/BuildConfigH.cmake)
IF(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -Dinline=__inline)
# disable warnings for LLVM
add_definitions(-wd4146) # unary minus operator applied to unsigned type, result still unsigned
add_definitions(-wd4800) # forcing value to bool 'true' or 'false' (performance warning)
add_definitions(-wd4355) # 'this' : used in base member initializer list
include_directories(libcpu/win32/msvc)
ENDIF()
#
# Find Python.
#
INCLUDE(FindPythonInterp)
IF(NOT PYTHONINTERP_FOUND)
message(FATAL_ERROR "Could not find Python, but Python 2.6 or later is required")
ENDIF()
SET(LIBCPU_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libcpu)
#
#
#
INCLUDE_DIRECTORIES(${LLVM_INCLUDE_DIR} ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/libcpu)
LINK_DIRECTORIES(${LLVM_LIB_DIR})
# Add LLVM flags only to C++.
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_COMPILE_FLAGS}")
MACRO(TARGET_LINK_LLVM TARGET)
TARGET_LINK_LIBRARIES(${TARGET} ${LLVM_LDFLAGS} ${LLVM_LIBS_CORE} ${LLVM_LIBS_JIT} ${LLVM_LIBS_JIT_OBJECTS})
ENDMACRO(TARGET_LINK_LLVM)
#
# Add extra warnings for gcc/g++.
#
IF(CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS(-W -Wall -Wextra -Wno-unused -Wno-unused-parameter -Werror -D__STDC_FORMAT_MACROS=1)
ENDIF()
FOREACH(ARCHITECTURE ${GUEST_ARCHITECTURES})
IF(EXISTS ${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
MESSAGE("** Building Guest Architecture: ${ARCHITECTURE}")
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/arch/${ARCHITECTURE})
IF(EXISTS ${PROJECT_SOURCE_DIR}/test/${ARCHITECTURE})
MESSAGE("** Building Test: ${ARCHITECTURE}")
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/test/${ARCHITECTURE})
ENDIF()
SET(GUEST_ARCHITECTURES_ENABLED "${GUEST_ARCHITECTURES_ENABLED};${ARCHITECTURE}")
ELSE()
MESSAGE("** Disabling Guest Architecture: ${ARCHITECTURE}")
ENDIF()
ENDFOREACH()
FOREACH(TEST ${GUEST_EXTRA_TESTS})
IF(EXISTS ${PROJECT_SOURCE_DIR}/test/${TEST})
MESSAGE("** Building Test: ${TEST}")
ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/test/${TEST})
ENDIF()
ENDFOREACH()
ADD_SUBDIRECTORY(libcpu)
# ADD_SUBDIRECTORY(upcl)
IF(NOT MSVC)
ADD_SUBDIRECTORY(test/libloader)
ADD_SUBDIRECTORY(test/libnix)
ENDIF()