CMakeLists.txt 2.88 KB
Newer Older
Anirudh Kaushik's avatar
Anirudh Kaushik committed
1
cmake_minimum_required(VERSION 2.6)
rmrf's avatar
rmrf committed
2
3
4
5
6
project(systemc-clang)
# Use C++ standard version to c++17
set(CMAKE_CXX_STANDARD 17)
# Always keep it on
set(CMAKE_CXX_STANDARD_REQUIRED ON)
rmrf's avatar
rmrf committed
7
8
#  Make verbose on?
#set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "ON")
rmrf's avatar
rmrf committed
9

10
# Required packages
11
12
# TODO: Add the code to find library and/or the specific in-source file.
# find_package(nlohmann_json 3.2.0 REQUIRED)
13
14


15
16
17
18
19
# Include the these flags whenever you compile.
add_definitions (-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS)

#add_definitions (-D_GNU_SOURCE -DHAVE_CLANG_CONFIG_H)

rmrf's avatar
rmrf committed
20
21
22
option (USE_SAUTO
  "Use suspension-automata library." OFF
  )
23
24
25
26
27

option (USE_SILENT_BUILD
  "Silent as many warnings as possible." OFF
  )

rmrf's avatar
rmrf committed
28
29
30
set (ROOT_CPP
  driver-tooling.cpp
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
31

rmrf's avatar
rmrf committed
32
33
34
set (LLVM_BUILD_DIR
  $ENV{LLVM_BUILD_DIR}
  )
35

rmrf's avatar
rmrf committed
36
set (CMAKE_CXX_FLAGS
37
   "$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -Wcovered-switch-default"
rmrf's avatar
rmrf committed
38
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
39
40
41

if (USE_SAUTO)
  set (CMAKE_CXX_FLAGS
42
    "-DUSE_SAUTO ${CMAKE_CXX_FLAGS}"
rmrf's avatar
rmrf committed
43
    )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
44
45
endif(USE_SAUTO)

46
47
48
49
50
51
if (USE_SILENT_BUILD)
  set (CMAKE_CXX_FLAGS
    "-DUSE_SILENT_BUILD=on ${CMAKE_CXX_FLAGS} -Wcovered-switch-default"
    )
endif(USE_SILENT_BUILD)

Anirudh Kaushik's avatar
Anirudh Kaushik committed
52

rmrf's avatar
rmrf committed
53
54
55
set (LLVM_LD_FLAGS
  "$ENV{LLVM_LD_FLAGS} -lpthread"
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
56

rmrf's avatar
rmrf committed
57
58
59
set (LLVM_LIBS
  $ENV{LLVM_LIBS}
  )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
60
61
62
63
64

#set (LLVM_LD_LIBS LLVMCppBackendCodeGen LLVMCppBackendInfo LLVMTarget LLVMCore LLVMMC LLVMObject LLVMSupport)

#LLVMJIT LLVMX86CodeGen LLVMX86AsmParser LLVMX86Disassembler LLVMExecutionEngine LLVMAsmPrinter LLVMSelectionDAG LLVMX86AsmPrinter LLVMX86Info LLVMMCParser LLVMCodeGen LLVMX86Utils LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMTarget LLVMCore LLVMMC LLVMSupport

rmrf's avatar
rmrf committed
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
106
107
108
109
110
111
112
113
set (CLANG_LIBS
  clangTooling
  clangFrontendTool
  clangFrontend
  clangDriver
  clangSerialization
  clangCodeGen
  clangParse
  clangSema
  clangStaticAnalyzerFrontend
  clangStaticAnalyzerCheckers
  clangStaticAnalyzerCore
  clangAnalysis
  clangARCMigrate
  clangRewriteFrontend
  clangRewrite
  clangEdit
  clangAST
  clangLex
  clangBasic
  clangASTMatchers
  )


set (CMAKE_MODULE_LINKER_FLAGS
  $ENV{LLVM_LD_FLAGS}
  )

set (TARGET
  "systemc-clang"
  )


include_directories(
  "${LLVM_BUILD_DIR}/include"
  src
  if (USE_SAUTO)
    sauto
  endif (USE_SAUTO)

  )


link_directories(
  ${LLVM_BUILD_DIR}/lib
  )

add_subdirectory(src)
add_subdirectory(tests)
Anirudh Kaushik's avatar
Anirudh Kaushik committed
114
115
116
117
118
119

if (USE_SAUTO)
  add_subdirectory(sauto)
endif (USE_SAUTO)


rmrf's avatar
rmrf committed
120
set( SRC_LIB libsystemc-clang )
Anirudh Kaushik's avatar
Anirudh Kaushik committed
121
122
123
if (USE_SAUTO)
  set( SAUTO_LIB libsauto )
endif (USE_SAUTO)
rmrf's avatar
rmrf committed
124
125
126
add_executable(
  ${TARGET}
  ${ROOT_CPP} )
rmrf's avatar
rmrf committed
127

128
129
target_link_libraries(${TARGET} ${SRC_LIB}) #nlohmann_json::nlohmann_json)
target_link_libraries(${TARGET} ${SAUTO_LIB}) # nlohmann_json::nlohmann_json)
Anirudh Kaushik's avatar
Anirudh Kaushik committed
130

rmrf's avatar
rmrf committed
131
132
133
foreach (clang_lib ${CLANG_LIBS})
  target_link_libraries( ${TARGET} ${clang_lib} )
endforeach()
Anirudh Kaushik's avatar
Anirudh Kaushik committed
134

rmrf's avatar
rmrf committed
135
136
137
foreach (ld_flag ${LLVM_LD_FLAGS})
  target_link_libraries( ${TARGET} ${ld_flag} )
endforeach()
Anirudh Kaushik's avatar
Anirudh Kaushik committed
138

rmrf's avatar
rmrf committed
139
140
141
foreach (llvm_lib ${LLVM_LIBS})
  target_link_libraries( ${TARGET} ${llvm_lib} )
endforeach()