-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
290 lines (254 loc) · 9.1 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
cmake_minimum_required(VERSION 3.10)
project(
Dali
LANGUAGES CXX
)
set(CMAKE_CXX_STANDARD 17)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
module/eigen-git-mirror
)
# add sub-cmake files to the search path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
############################################################################
# Detect if $ACT_HOME exits
############################################################################
message(STATUS "Detecting environment variable ACT_HOME...")
if (DEFINED ENV{ACT_HOME})
message(STATUS "Environment variable ACT_HOME detected: " $ENV{ACT_HOME})
else ()
message(FATAL_ERROR "Environment variable ACT_HOME not found")
endif ()
include_directories($ENV{ACT_HOME}/include)
link_directories($ENV{ACT_HOME}/lib)
find_library(ACT_LIBRARY NAMES act PATHS $ENV{ACT_HOME}/lib REQUIRED)
message(STATUS "Found libact.a: " ${ACT_LIBRARY})
find_library(ACTVLSILIB_LIBRARY NAMES vlsilib PATHS $ENV{ACT_HOME}/lib REQUIRED)
message(STATUS "Found libvlsilib.a: " ${ACTVLSILIB_LIBRARY})
find_library(PHYDB_LIBRARY NAMES phydb PATHS $ENV{ACT_HOME}/lib REQUIRED)
message(STATUS "Found libphydb.a: " ${PHYDB_LIBRARY})
find_library(LEF_LIBRARY NAMES lef PATHS $ENV{ACT_HOME}/lib REQUIRED)
message(STATUS "Found liblef.a: " ${LEF_LIBRARY})
find_library(DEF_LIBRARY NAMES def PATHS $ENV{ACT_HOME}/lib REQUIRED)
message(STATUS "Found libdef.a: " ${DEF_LIBRARY})
############################################################################
# Detect if galois_eda library exists
############################################################################
include(cmake/FindGaloisEDA.cmake)
############################################################################
# Detect if OpenMP library exists
############################################################################
include(cmake/FindOpenMPPackage.cmake)
############################################################################
# Detect if Boost library exists
############################################################################
#set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.71.0 COMPONENTS log_setup log REQUIRED)
message(STATUS "Boost library path: ${Boost_LIBRARY_DIRS}")
message(STATUS "Boost include path: ${Boost_INCLUDE_DIR}")
message(STATUS "Boost libs: ${Boost_LIBRARIES}")
include_directories(${Boost_INCLUDE_DIRS})
############################################################################
# Detect if CPLEX library exists
############################################################################
include(cmake/FindCPLEX.cmake)
############################################################################
# Set Git Commit
############################################################################
include(cmake/FindGitCommitVersion.cmake)
############################################################################
# for building a standalone static executable
############################################################################
set(BUILD_STATIC_EXECUTABLES FALSE)
if (BUILD_STATIC_EXECUTABLES)
set(CMAKE_EXE_LINKER_FLAGS -static)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_C_FLAGS) # remove -fPIC
set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) # remove -rdynamic
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
# Maybe this works as well, haven't tried yet.
# set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
else (BUILD_STATIC_EXECUTABLES)
# Set RPATH to use for installed targets; append linker search path
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LOFAR_LIBDIR}")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif (BUILD_STATIC_EXECUTABLES)
# Set C++ compilation flags and options
set(CMAKE_CXX_FLAGS_DEBUG "-g -O3")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
# Set a default build type if none was specified
set(default_build_type "RELEASE")
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}")
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG" "RELEASE")
endif ()
if (CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "DEBUG build type")
else (CMAKE_BUILD_TYPE MATCHES RELEASE)
message(STATUS "RELEASE build type")
endif ()
add_compile_options(-fopenmp)
add_compile_options(-Wall -Wextra -Wshadow -Wnon-virtual-dtor -Werror=return-type -pedantic)
# Set the output directory of static libraries
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
# Set the output directory of executables
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
# All used circuit and placer source code
file(
GLOB_RECURSE SOURCES
dali/dali.cc
dali/circuit/*.cc
dali/common/*.cc
dali/placer/*.cc
dali/timing/*.cc
)
# Create a library, static libraries are controlled by ARCHIVE_OUTPUT_DIRECTORY property
# Shared libraries are controlled by LIBRARY_OUTPUT_DIRECTORY
# This dalilib library is not necessary, this library is created because we need to put it somewhere in $ACT_HOME or $CAD_HOME
add_library(
dalilib
STATIC
${SOURCES}
dali/common/named_instance_collection.h
)
if (DEFINED NEED_LIBCXXFS)
set(LIBCXXFS_LIB "stdc++fs")
else ()
set(LIBCXXFX_LIB "")
endif ()
target_link_libraries(
dalilib
${ACT_LIBRARY} ${ACTVLSILIB_LIBRARY} ${PHYDB_LIBRARY}
${Galois_LIBRARIES}
${LEF_LIBRARY} ${DEF_LIBRARY}
${CPLEX_LIBRARIES} m pthread dl
${Boost_LIBRARIES}
OpenMP::OpenMP_CXX
${LIBCXXFS_LIB}
)
# Stand-alone placer, building from the dalilib library
add_executable(
dali
dali/application/dali_standalone.cc
)
target_link_libraries(
dali
PRIVATE dalilib
)
# Debugging executable, building from the dalilib library
add_executable(
dali-debug
dali/application/debug.cc
)
target_link_libraries(
dali-debug
PRIVATE dalilib
)
# Debugging executable, building from the dalilib library
add_executable(
wellflow
dali/application/wellflow.cc
)
target_link_libraries(
wellflow
PRIVATE dalilib
)
# Debugging executable, building from the dalilib library
add_executable(
adaptec-debug
dali/application/debug-adaptec.cc
)
target_link_libraries(
adaptec-debug
PRIVATE dalilib
)
# Stand-alone hpwl calculator, building from the dalilib library
add_executable(
hpwl
dali/application/hpwl.cc
)
target_link_libraries(
hpwl
PRIVATE dalilib
)
# Stand-alone LEFDEF to Bookshelf format tool, building from the dalilib library
add_executable(
lefdef2bookshelf
dali/application/lefdef2bookshelf.cc
)
target_link_libraries(
lefdef2bookshelf
PRIVATE dalilib
)
# Stand-alone Bookshelf to LEFDEF format tool, building from the dalilib library
add_executable(
bookshelf2def
dali/application/bookshelf2def.cc
)
target_link_libraries(
bookshelf2def
PRIVATE dalilib
)
# Stand-alone custom cell design to standard cell design tool
add_executable(
create_circuit
dali/application/create_circuit.cc
)
target_link_libraries(
create_circuit
PRIVATE dalilib
)
# Mixed-cell-height legalization for standard cells
add_executable(
mhlg
dali/application/mhlg.cc
)
target_link_libraries(
mhlg
PRIVATE dalilib
)
# Unittests
enable_testing()
add_subdirectory(tests/boost_test)
add_subdirectory(tests/ioplacer)
############################################################################
# Configure install destination directory
############################################################################
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(STATUS "Changing default installation directory to $ACT_HOME")
set(CMAKE_INSTALL_PREFIX $ENV{ACT_HOME} CACHE PATH "installation path" FORCE)
endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
message(STATUS "Current installation directory: " ${CMAKE_INSTALL_PREFIX})
############################################################################
# Install header files
############################################################################
set(INCLUDE_DESTIN include)
install(
DIRECTORY dali/
DESTINATION ${INCLUDE_DESTIN}/dali
FILES_MATCHING
PATTERN "*.h"
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/module/eigen-git-mirror/Eigen/
DESTINATION ${INCLUDE_DESTIN}/Eigen
)
############################################################################
# Install binary
############################################################################
install(
TARGETS dali
DESTINATION bin
)
############################################################################
# Install library
############################################################################
install(
TARGETS dalilib
DESTINATION lib
)