1
- # If we are not building as a part of LLVM, build Clang as an
1
+ # If we are not building as a part of LLVM, build LFort as an
2
2
# standalone project, using LLVM as an external library:
3
3
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
4
- project (Clang )
4
+ project (LFort )
5
5
cmake_minimum_required (VERSION 2.8)
6
6
7
- set (CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH
7
+ set (LFORT_PATH_TO_LLVM_SOURCE "" CACHE PATH
8
8
"Path to LLVM source code. Not necessary if using an installed LLVM." )
9
- set (CLANG_PATH_TO_LLVM_BUILD "" CACHE PATH
9
+ set (LFORT_PATH_TO_LLVM_BUILD "" CACHE PATH
10
10
"Path to the directory where LLVM was built or installed." )
11
11
12
- if ( CLANG_PATH_TO_LLVM_SOURCE )
13
- if ( NOT EXISTS "${CLANG_PATH_TO_LLVM_SOURCE } /cmake/config-ix.cmake" )
14
- message (FATAL_ERROR "Please set CLANG_PATH_TO_LLVM_SOURCE to the root directory of LLVM source code." )
12
+ if ( LFORT_PATH_TO_LLVM_SOURCE )
13
+ if ( NOT EXISTS "${LFORT_PATH_TO_LLVM_SOURCE } /cmake/config-ix.cmake" )
14
+ message (FATAL_ERROR "Please set LFORT_PATH_TO_LLVM_SOURCE to the root directory of LLVM source code." )
15
15
else ()
16
- get_filename_component (LLVM_MAIN_SRC_DIR ${CLANG_PATH_TO_LLVM_SOURCE }
16
+ get_filename_component (LLVM_MAIN_SRC_DIR ${LFORT_PATH_TO_LLVM_SOURCE }
17
17
ABSOLUTE )
18
18
list (APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR} /cmake/modules" )
19
19
endif ()
20
20
endif ()
21
21
22
- if ( NOT EXISTS "${CLANG_PATH_TO_LLVM_BUILD } /bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
22
+ if ( NOT EXISTS "${LFORT_PATH_TO_LLVM_BUILD } /bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
23
23
# Looking for bin/Debug/llvm-tblgen is a complete hack. How can we get
24
24
# around this?
25
- if ( NOT EXISTS "${CLANG_PATH_TO_LLVM_BUILD } /bin/Debug/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
26
- message (FATAL_ERROR "Please set CLANG_PATH_TO_LLVM_BUILD to a directory containing a LLVM build." )
25
+ if ( NOT EXISTS "${LFORT_PATH_TO_LLVM_BUILD } /bin/Debug/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
26
+ message (FATAL_ERROR "Please set LFORT_PATH_TO_LLVM_BUILD to a directory containing a LLVM build." )
27
27
endif ()
28
28
endif ()
29
29
30
- list (APPEND CMAKE_MODULE_PATH "${CLANG_PATH_TO_LLVM_BUILD } /share/llvm/cmake" )
30
+ list (APPEND CMAKE_MODULE_PATH "${LFORT_PATH_TO_LLVM_BUILD } /share/llvm/cmake" )
31
31
32
- get_filename_component (PATH_TO_LLVM_BUILD ${CLANG_PATH_TO_LLVM_BUILD }
32
+ get_filename_component (PATH_TO_LLVM_BUILD ${LFORT_PATH_TO_LLVM_BUILD }
33
33
ABSOLUTE )
34
34
35
35
include (AddLLVM)
36
36
include (TableGen)
37
- include ("${CLANG_PATH_TO_LLVM_BUILD } /share/llvm/cmake/LLVMConfig.cmake" )
37
+ include ("${LFORT_PATH_TO_LLVM_BUILD } /share/llvm/cmake/LLVMConfig.cmake" )
38
38
include (HandleLLVMOptions)
39
39
40
40
set (PACKAGE_VERSION "${LLVM_PACKAGE_VERSION} " )
@@ -46,7 +46,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
46
46
include_directories ("${PATH_TO_LLVM_BUILD} /include" "${LLVM_MAIN_INCLUDE_DIR} " )
47
47
link_directories ("${PATH_TO_LLVM_BUILD} /lib" )
48
48
49
- if ( EXISTS "${CLANG_PATH_TO_LLVM_BUILD } /bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
49
+ if ( EXISTS "${LFORT_PATH_TO_LLVM_BUILD } /bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
50
50
set (LLVM_TABLEGEN_EXE "${PATH_TO_LLVM_BUILD} /bin/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX} " )
51
51
else ()
52
52
# FIXME: This is an utter hack.
@@ -65,33 +65,33 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
65
65
set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib )
66
66
set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /lib )
67
67
68
- set ( CLANG_BUILT_STANDALONE 1 )
68
+ set ( LFORT_BUILT_STANDALONE 1 )
69
69
70
70
find_package (LibXml2)
71
71
if (LIBXML2_FOUND)
72
- set (CLANG_HAVE_LIBXML 1)
72
+ set (LFORT_HAVE_LIBXML 1)
73
73
endif ()
74
74
endif ()
75
75
76
- set (CLANG_RESOURCE_DIR "" CACHE STRING
77
- "Relative directory from the Clang binary to its resource files." )
76
+ set (LFORT_RESOURCE_DIR "" CACHE STRING
77
+ "Relative directory from the LFort binary to its resource files." )
78
78
79
79
set (C_INCLUDE_DIRS "" CACHE STRING
80
- "Colon separated list of directories clang will search for headers." )
80
+ "Colon separated list of directories lfort will search for headers." )
81
81
82
82
set (GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." )
83
83
set (DEFAULT_SYSROOT "" CACHE PATH
84
84
"Default <path> to all compiler invocations for --sysroot=<path>." )
85
85
86
- set (CLANG_VENDOR "" CACHE STRING
86
+ set (LFORT_VENDOR "" CACHE STRING
87
87
"Vendor-specific text for showing with version information." )
88
88
89
- if ( CLANG_VENDOR )
90
- add_definitions ( -DCLANG_VENDOR ="${CLANG_VENDOR } " )
89
+ if ( LFORT_VENDOR )
90
+ add_definitions ( -DLFORT_VENDOR ="${LFORT_VENDOR } " )
91
91
endif ()
92
92
93
- set (CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
94
- set (CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
93
+ set (LFORT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
94
+ set (LFORT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
95
95
96
96
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
97
97
message (FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
@@ -104,36 +104,36 @@ endif()
104
104
if ( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
105
105
file (GLOB_RECURSE
106
106
tablegenned_files_on_include_dir
107
- "${CLANG_SOURCE_DIR } /include/clang /*.inc" )
107
+ "${LFORT_SOURCE_DIR } /include/lfort /*.inc" )
108
108
if ( tablegenned_files_on_include_dir )
109
109
message (FATAL_ERROR "Apparently there is a previous in-source build, "
110
110
"probably as the result of running `configure' and `make' on "
111
- "${CLANG_SOURCE_DIR } . This may cause problems. The suspicious files are:\n "
111
+ "${LFORT_SOURCE_DIR } . This may cause problems. The suspicious files are:\n "
112
112
"${tablegenned_files_on_include_dir} \n Please clean the source directory." )
113
113
endif ()
114
114
endif ()
115
115
116
- # Compute the Clang version from the LLVM version.
117
- string (REGEX MATCH "[0-9]+\\ .[0-9]+(\\ .[0-9]+)?" CLANG_VERSION
116
+ # Compute the LFort version from the LLVM version.
117
+ string (REGEX MATCH "[0-9]+\\ .[0-9]+(\\ .[0-9]+)?" LFORT_VERSION
118
118
${PACKAGE_VERSION} )
119
- message (STATUS "Clang version: ${CLANG_VERSION } " )
120
-
121
- string (REGEX REPLACE "([0-9]+)\\ .[0-9]+(\\ .[0-9]+)?" "\\ 1" CLANG_VERSION_MAJOR
122
- ${CLANG_VERSION } )
123
- string (REGEX REPLACE "[0-9]+\\ .([0-9]+)(\\ .[0-9]+)?" "\\ 1" CLANG_VERSION_MINOR
124
- ${CLANG_VERSION } )
125
- if (${CLANG_VERSION } MATCHES "[0-9]+\\ .[0-9]+\\ .[0-9]+" )
126
- set (CLANG_HAS_VERSION_PATCHLEVEL 1)
127
- string (REGEX REPLACE "[0-9]+\\ .[0-9]+\\ .([0-9]+)" "\\ 1" CLANG_VERSION_PATCHLEVEL
128
- ${CLANG_VERSION } )
119
+ message (STATUS "LFort version: ${LFORT_VERSION } " )
120
+
121
+ string (REGEX REPLACE "([0-9]+)\\ .[0-9]+(\\ .[0-9]+)?" "\\ 1" LFORT_VERSION_MAJOR
122
+ ${LFORT_VERSION } )
123
+ string (REGEX REPLACE "[0-9]+\\ .([0-9]+)(\\ .[0-9]+)?" "\\ 1" LFORT_VERSION_MINOR
124
+ ${LFORT_VERSION } )
125
+ if (${LFORT_VERSION } MATCHES "[0-9]+\\ .[0-9]+\\ .[0-9]+" )
126
+ set (LFORT_HAS_VERSION_PATCHLEVEL 1)
127
+ string (REGEX REPLACE "[0-9]+\\ .[0-9]+\\ .([0-9]+)" "\\ 1" LFORT_VERSION_PATCHLEVEL
128
+ ${LFORT_VERSION } )
129
129
else ()
130
- set (CLANG_HAS_VERSION_PATCHLEVEL 0)
130
+ set (LFORT_HAS_VERSION_PATCHLEVEL 0)
131
131
endif ()
132
132
133
133
# Configure the Version.inc file.
134
134
configure_file (
135
- ${CMAKE_CURRENT_SOURCE_DIR} /include /clang /Basic/Version .inc.in
136
- ${CMAKE_CURRENT_BINARY_DIR} /include /clang /Basic/Version .inc)
135
+ ${CMAKE_CURRENT_SOURCE_DIR} /include /lfort /Basic/Version .inc.in
136
+ ${CMAKE_CURRENT_BINARY_DIR} /include /lfort /Basic/Version .inc)
137
137
138
138
# Add appropriate flags for GCC
139
139
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
@@ -145,14 +145,14 @@ if (APPLE)
145
145
endif ()
146
146
147
147
configure_file (
148
- ${CLANG_SOURCE_DIR } /include /clang /Config/config.h.cmake
149
- ${CLANG_BINARY_DIR } /include /clang /Config/config.h)
148
+ ${LFORT_SOURCE_DIR } /include /lfort /Config/config.h.cmake
149
+ ${LFORT_BINARY_DIR } /include /lfort /Config/config.h)
150
150
151
151
include (LLVMParseArguments)
152
152
153
- function (clang_tablegen )
153
+ function (lfort_tablegen )
154
154
# Syntax:
155
- # clang_tablegen output-file [tablegen-arg ...] SOURCE source-file
155
+ # lfort_tablegen output-file [tablegen-arg ...] SOURCE source-file
156
156
# [[TARGET cmake-target-name] [DEPENDS extra-dependency ...]]
157
157
#
158
158
# Generates a custom command for invoking tblgen as
@@ -166,36 +166,36 @@ function(clang_tablegen)
166
166
parse_arguments( CTG "SOURCE;TARGET;DEPENDS" "" ${ARGN} )
167
167
168
168
if ( NOT CTG_SOURCE )
169
- message (FATAL_ERROR "SOURCE source-file required by clang_tablegen " )
169
+ message (FATAL_ERROR "SOURCE source-file required by lfort_tablegen " )
170
170
endif ()
171
171
172
172
set ( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )
173
- tablegen( CLANG ${CTG_DEFAULT_ARGS} )
173
+ tablegen( LFORT ${CTG_DEFAULT_ARGS} )
174
174
175
175
list ( GET CTG_DEFAULT_ARGS 0 output_file )
176
176
if ( CTG_TARGET )
177
177
add_custom_target ( ${CTG_TARGET} DEPENDS ${output_file} ${CTG_DEPENDS} )
178
- set_target_properties ( ${CTG_TARGET} PROPERTIES FOLDER "Clang tablegenning" )
178
+ set_target_properties ( ${CTG_TARGET} PROPERTIES FOLDER "LFort tablegenning" )
179
179
endif ()
180
- endfunction (clang_tablegen )
180
+ endfunction (lfort_tablegen )
181
181
182
- macro (add_clang_library name )
182
+ macro (add_lfort_library name )
183
183
llvm_process_sources(srcs ${ARGN} )
184
184
if (MSVC_IDE OR XCODE)
185
185
# Add public headers
186
186
file (RELATIVE_PATH lib_path
187
- ${CLANG_SOURCE_DIR } /lib/
187
+ ${LFORT_SOURCE_DIR } /lib/
188
188
${CMAKE_CURRENT_SOURCE_DIR}
189
189
)
190
190
if (NOT lib_path MATCHES "^[.][.]" )
191
191
file ( GLOB_RECURSE headers
192
- ${CLANG_SOURCE_DIR } /include /clang /${lib_path} /*.h
193
- ${CLANG_SOURCE_DIR } /include /clang /${lib_path} /*.def
192
+ ${LFORT_SOURCE_DIR } /include /lfort /${lib_path} /*.h
193
+ ${LFORT_SOURCE_DIR } /include /lfort /${lib_path} /*.def
194
194
)
195
195
set_source_files_properties (${headers} PROPERTIES HEADER_FILE_ONLY ON )
196
196
197
197
file ( GLOB_RECURSE tds
198
- ${CLANG_SOURCE_DIR } /include /clang /${lib_path} /*.td
198
+ ${LFORT_SOURCE_DIR } /include /lfort /${lib_path} /*.td
199
199
)
200
200
source_group ("TableGen descriptions" FILES ${tds} )
201
201
set_source_files_properties (${tds} } PROPERTIES HEADER_FILE_ONLY ON )
@@ -223,13 +223,13 @@ macro(add_clang_library name)
223
223
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
224
224
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
225
225
RUNTIME DESTINATION bin)
226
- set_target_properties (${name} PROPERTIES FOLDER "Clang libraries" )
227
- endmacro (add_clang_library )
226
+ set_target_properties (${name} PROPERTIES FOLDER "LFort libraries" )
227
+ endmacro (add_lfort_library )
228
228
229
- macro (add_clang_executable name )
229
+ macro (add_lfort_executable name )
230
230
add_llvm_executable( ${name} ${ARGN} )
231
- set_target_properties (${name} PROPERTIES FOLDER "Clang executables" )
232
- endmacro (add_clang_executable )
231
+ set_target_properties (${name} PROPERTIES FOLDER "LFort executables" )
232
+ endmacro (add_lfort_executable )
233
233
234
234
include_directories (BEFORE
235
235
${CMAKE_CURRENT_BINARY_DIR} /include
@@ -255,16 +255,16 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
255
255
add_definitions ( -D_GNU_SOURCE )
256
256
257
257
# FIXME: They should be options.
258
- add_definitions (-DCLANG_ENABLE_ARCMT -DCLANG_ENABLE_REWRITER -DCLANG_ENABLE_STATIC_ANALYZER )
258
+ add_definitions (-DLFORT_ENABLE_ARCMT -DLFORT_ENABLE_REWRITER -DLFORT_ENABLE_STATIC_ANALYZER )
259
259
260
- # Clang version information
261
- set (CLANG_EXECUTABLE_VERSION
262
- "${CLANG_VERSION_MAJOR } .${CLANG_VERSION_MINOR } " CACHE STRING
263
- "Version number that will be placed into the clang executable, in the form XX.YY" )
264
- set (LIBCLANG_LIBRARY_VERSION
265
- "${CLANG_VERSION_MAJOR } .${CLANG_VERSION_MINOR } " CACHE STRING
266
- "Version number that will be placed into the libclang library , in the form XX.YY" )
267
- mark_as_advanced (CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION )
260
+ # LFort version information
261
+ set (LFORT_EXECUTABLE_VERSION
262
+ "${LFORT_VERSION_MAJOR } .${LFORT_VERSION_MINOR } " CACHE STRING
263
+ "Version number that will be placed into the lfort executable, in the form XX.YY" )
264
+ set (LIBLFORT_LIBRARY_VERSION
265
+ "${LFORT_VERSION_MAJOR } .${LFORT_VERSION_MINOR } " CACHE STRING
266
+ "Version number that will be placed into the liblfort library , in the form XX.YY" )
267
+ mark_as_advanced (LFORT_EXECUTABLE_VERSION LIBLFORT_LIBRARY_VERSION )
268
268
269
269
add_subdirectory (utils/TableGen)
270
270
@@ -273,24 +273,24 @@ add_subdirectory(lib)
273
273
add_subdirectory (tools)
274
274
add_subdirectory (runtime)
275
275
276
- option (CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF )
276
+ option (LFORT_BUILD_EXAMPLES "Build LFORT example programs by default." OFF )
277
277
add_subdirectory (examples)
278
278
279
279
# TODO: docs.
280
280
add_subdirectory (test )
281
281
282
282
if ( LLVM_INCLUDE_TESTS )
283
- if ( NOT CLANG_BUILT_STANDALONE )
283
+ if ( NOT LFORT_BUILT_STANDALONE )
284
284
add_subdirectory (unittests)
285
285
endif ()
286
286
endif ()
287
287
288
288
# Workaround for MSVS10 to avoid the Dialog Hell
289
289
# FIXME: This could be removed with future version of CMake.
290
- if ( CLANG_BUILT_STANDALONE AND MSVC_VERSION EQUAL 1600 )
291
- set (CLANG_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR} /Clang .sln" )
292
- if ( EXISTS "${CLANG_SLN_FILENAME } " )
293
- file (APPEND "${CLANG_SLN_FILENAME } " "\n # This should be regenerated!\n " )
290
+ if ( LFORT_BUILT_STANDALONE AND MSVC_VERSION EQUAL 1600 )
291
+ set (LFORT_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR} /LFort .sln" )
292
+ if ( EXISTS "${LFORT_SLN_FILENAME } " )
293
+ file (APPEND "${LFORT_SLN_FILENAME } " "\n # This should be regenerated!\n " )
294
294
endif ()
295
295
endif ()
296
296
0 commit comments