forked from MaxXSoft/YuLang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
55 lines (46 loc) · 1.63 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
cmake_minimum_required(VERSION 3.13)
project(YuLang VERSION "0.0.7")
# # set compiler path
# set(CMAKE_C_COMPILER "/usr/local/opt/gcc/bin/gcc-13")
# set(CMAKE_CXX_COMPILER "/usr/local/opt/gcc/bin/g++-13")
# set(CMAKE_CXX_COMPILER_ID "GNU")
# C++17 standard support
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# enable all warnings and treat them as errors
if(MSVC)
add_compile_options(/W3 /WX)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wno-init-list-lifetime -Werror)
else()
add_compile_options(-Wall -Werror)
endif()
# some definitions
add_compile_definitions(APP_NAME="YuLang Compiler")
add_compile_definitions(APP_VERSION="${PROJECT_VERSION}")
add_compile_definitions(APP_VERSION_MAJOR=${PROJECT_VERSION_MAJOR})
add_compile_definitions(APP_VERSION_MINOR=${PROJECT_VERSION_MINOR})
add_compile_definitions(APP_VERSION_PATCH=${PROJECT_VERSION_PATCH})
# find LLVM
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
# project include directories
include_directories(src)
include_directories(3rdparty/xstl)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# all of C++ source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
# executable
add_executable(yuc ${SOURCES})
link_directories(${LLVM_LIBRARY_DIRS})
# CentOS 8 need stdc++fs option
target_link_libraries(yuc LLVM stdc++fs)
# build Yu standard library and examples after generation
add_custom_command(
TARGET yuc
POST_BUILD
COMMAND make -C ${CMAKE_SOURCE_DIR} BUILD_DIR=${CMAKE_BINARY_DIR}
)