-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
59 lines (46 loc) · 1.85 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
cmake_minimum_required(VERSION 3.00)
project(LMVM C)
set(CMAKE_C_STANDARD 99)
# scan source files
file(GLOB_RECURSE ASM_SOURCES ${PROJECT_SOURCE_DIR}/src/assembler/*.c)
file(GLOB_RECURSE VM_SOURCES ${PROJECT_SOURCE_DIR}/src/vm/*.c)
file(GLOB_RECURSE COMMON_SOURCES ${PROJECT_SOURCE_DIR}/src/common/*.c)
# add icon resource if windows
IF (WIN32)
set(ASM_SOURCES ${ASM_SOURCES} ${PROJECT_SOURCE_DIR}/src/assembler/icon.rc)
set(VM_SOURCES ${VM_SOURCES} ${PROJECT_SOURCE_DIR}/src/vm/icon.rc)
ENDIF ()
# include header files
include_directories(${PROJECT_SOURCE_DIR}/include)
# set version here
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
MESSAGE(STATUS "Version v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# add LMASM executable
add_executable(lmasm ${ASM_SOURCES} ${COMMON_SOURCES})
# add regex library for windows
IF (WIN32)
target_link_libraries(lmasm regex)
ENDIF ()
# add LMVM executable
add_executable(lmvm ${VM_SOURCES} ${COMMON_SOURCES})
# add version info to build definitions
target_compile_definitions(lmasm PRIVATE -DVERSION_MAJOR=${VERSION_MAJOR} -DVERSION_MINOR=${VERSION_MINOR} -DVERSION_PATCH=${VERSION_PATCH})
target_compile_definitions(lmvm PRIVATE -DVERSION_MAJOR=${VERSION_MAJOR} -DVERSION_MINOR=${VERSION_MINOR} -DVERSION_PATCH=${VERSION_PATCH})
# use harsh flags
if (MSVC)
MESSAGE(STATUS "MSVC is not a supported compiler and may fail!")
target_compile_options(lmasm PRIVATE /W4 /WX)
target_compile_options(lmvm PRIVATE /W4 /WX)
else ()
target_compile_options(lmasm PRIVATE -Wall -Wextra -pedantic -Werror)
target_compile_options(lmvm PRIVATE -Wall -Wextra -pedantic -Werror)
endif ()
# check if installers are enabled
if (INSTALLER STREQUAL OFF)
MESSAGE(STATUS "Installer disabled, skipping installer generation")
else ()
# make installer
include(scripts/make_installer.cmake)
endif ()