-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
97 lines (78 loc) · 2.84 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
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0091 NEW)
project(banjo VERSION 0.1)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
enable_testing()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(TARGET_ARCH "x86_64")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
set(TARGET_ARCH "aarch64")
else()
set(TARGET_ARCH "unknown")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_OS "windows")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(TARGET_OS "linux")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_OS "macos")
else()
set(TARGET_OS "unknown")
endif()
message(STATUS "Target architecture: ${TARGET_ARCH}")
message(STATUS "Target OS: ${TARGET_OS}")
if(MSVC)
add_compile_options(/W2)
else ()
add_compile_options(-Wall -Wno-c++98-compat)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG=1)
else ()
add_compile_definitions(DEBUG=0)
if(MSVC)
string(REGEX REPLACE "/EH[a-z]+|/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(/EHs-c- /GR-)
else()
string(REGEX REPLACE "-fexceptions|frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(-fno-exceptions -fno-rtti)
endif()
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GCC")
message(STATUS "LTO enabled")
add_compile_options(-flto)
add_link_options(-flto)
endif()
endif()
# set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
# add_compile_options(/fsanitize=address -fsanitize=undefined)
# link_libraries(clang_rt.asan-x86_64.lib)
string(TIMESTAMP VERSION "%Y-%m-%d")
add_compile_definitions(BANJO_VERSION="${VERSION}")
if((TARGET_OS STREQUAL "windows" OR TARGET_OS STREQUAL "linux") AND TARGET_ARCH STREQUAL "x86_64")
message(STATUS "Hot reloader enabled")
set(BUILD_HOT_RELOADER ON)
else()
message(STATUS "Hot reloader disabled")
set(BUILD_HOT_RELOADER OFF)
endif()
add_subdirectory(src)
add_subdirectory(test)
install(TARGETS banjo-compiler RUNTIME DESTINATION bin)
install(TARGETS banjo-lsp RUNTIME DESTINATION bin)
install(TARGETS banjo-format RUNTIME DESTINATION bin)
install(TARGETS cli RUNTIME DESTINATION bin)
if(BUILD_HOT_RELOADER)
install(TARGETS banjo-hot-reloader RUNTIME DESTINATION bin)
endif()
if(WIN32)
install(FILES $<TARGET_PDB_FILE:banjo-compiler> DESTINATION bin OPTIONAL)
install(FILES $<TARGET_PDB_FILE:banjo-lsp> DESTINATION bin OPTIONAL)
if(BUILD_HOT_RELOADER)
install(FILES $<TARGET_PDB_FILE:banjo-hot-reloader> DESTINATION bin OPTIONAL)
endif()
endif()
install(DIRECTORY src/cli/python/ DESTINATION scripts/cli)
install(DIRECTORY src/bindgen DESTINATION scripts)
install(DIRECTORY lib/stdlib2 DESTINATION lib)
install(DIRECTORY lib/runtime/bin/ DESTINATION lib/runtime)