forked from zhuowei/jiyu
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
102 lines (84 loc) · 2.92 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
cmake_minimum_required(VERSION 2.6)
project(jiyu)
find_package (Threads)
set(LLVM_DIR "${PROJECT_SOURCE_DIR}/llvm/lib/cmake/llvm/")
set(Clang_DIR "${PROJECT_SOURCE_DIR}/llvm/lib/cmake/clang")
find_package(LLVM REQUIRED CONFIG)
find_package(Clang REQUIRED CONFIG)
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
add_definitions(-DENV32)
else()
add_definitions(-DENV64)
endif()
#include_directories()
set (JIYU_SRCS
src/ast.h
src/clang_import.h
src/compiler.h
src/compiler_api.h
src/copier.h
src/compiler.h
src/general.h
src/lexer.h
src/llvm.h
src/meow_hash.h
src/meow_intrinsics.h
src/microprofile.h
src/microprofile_html.h
src/microsoft_craziness.h
src/os_support.h
src/parser.h
src/sema.h
src/parser.cpp
src/lexer.cpp
src/compiler.cpp
src/compiler_api.cpp
src/llvm.cpp
src/sema.cpp
src/copier.cpp
src/os_support.cpp
src/clang_import.cpp
src/microprofile.cpp
)
set (JIYU_DRIVER_SRCS
src/main.cpp
)
if (UNIX AND NOT APPLE)
set(LINUX TRUE)
endif ()
# compiler options
if (WIN32)
# @Cleanup is there an easier way to get the CRT that LLVM was configured to use?
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MT")
else()
add_definitions(-Wno-write-strings --std=c++11 -g -fno-rtti -Wall -Wextra -pedantic -Wno-unused-parameter)
endif()
if (APPLE)
add_definitions(-DMACOSX -DUNIX)
endif()
if (LINUX)
add_definitions(-DLINUX -DUNIX)
endif ()
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
llvm_map_components_to_libnames(LLVM_LIBS ${LLVM_TARGETS_TO_BUILD} asmparser asmprinter passes orcjit)
add_library(libjiyu_static OBJECT ${JIYU_SRCS})
add_library(libjiyu SHARED $<TARGET_OBJECTS:libjiyu_static>)
set_target_properties(libjiyu PROPERTIES OUTPUT_NAME "jiyu")
add_executable(jiyu ${JIYU_DRIVER_SRCS} $<TARGET_OBJECTS:libjiyu_static>)
target_link_libraries(libjiyu ${CMAKE_THREAD_LIBS_INIT} ${LLVM_LIBS} ${Clang_LIBS} libclang)
target_link_libraries(jiyu ${CMAKE_THREAD_LIBS_INIT} ${LLVM_LIBS} ${Clang_LIBS} libclang)
add_custom_command(TARGET libjiyu
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libjiyu> ${CMAKE_SOURCE_DIR}/modules/)
if (WIN32)
add_custom_command(TARGET libjiyu
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_LINKER_FILE:libjiyu> ${CMAKE_SOURCE_DIR}/modules/)
# On Windows, apparently building a static version of libclang is disabled, so copy it to the binary directory so the compiler runs without libclang.dll in PATH.
add_custom_command(TARGET jiyu
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libclang> ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/)
endif ()