-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
104 lines (83 loc) · 3.24 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
cmake_minimum_required(VERSION 3.12.0)
project(netlist-paths)
include(ExternalProject)
include(GNUInstallDirs)
option(NETLIST_PATHS_BUILD_DOCS "Create and install HTML documentation" OFF)
option(NETLIST_PATHS_INCLUDE_TESTS "Include test targets in the build" ON)
set(Boost_USE_MULTITHREADED ON)
set(NUM_PARALLEL_JOBS 16)
# Use local find scripts
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
find_package(Python REQUIRED COMPONENTS
Interpreter
Development)
find_package(Boost 1.65.0 REQUIRED COMPONENTS
graph
regex
program_options
system
filesystem
python
unit_test_framework
log
log_setup)
message(STATUS "Python_LIBRARIES = ${Python_LIBRARIES}")
message(STATUS "Python_EXECUTABLE = ${Python_EXECUTABLE}")
message(STATUS "Python_INCLUDE_DIRS = ${Python_INCLUDE_DIRS}")
message(STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}")
# CXX compiler
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
add_compile_options(-Wall -pedantic)
add_definitions(-DBOOST_LOG_DYN_LINK) # Dynamic link option for boost::log
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# Set default install prefix.
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "..." FORCE)
endif()
include_directories(${Boost_INCLUDE_DIRS}
${Python_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include)
# Set the install RPATH
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
# Read the version number.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" ver)
string(REGEX MATCH "VERSION_MAJOR ([0-9]*)" _ ${ver})
set(version_major ${CMAKE_MATCH_1})
string(REGEX MATCH "VERSION_MINOR ([0-9]*)" _ ${ver})
set(version_minor ${CMAKE_MATCH_1})
string(REGEX MATCH "VERSION_PATCH ([0-9]*)" _ ${ver})
set(version_patch ${CMAKE_MATCH_1})
if ("${version_major}" STREQUAL "" OR "${version_minor}" STREQUAL "" OR "${version_patch}" STREQUAL "")
message(FATAL_ERROR, "could not read version number")
endif()
message("Version: ${version_major}.${version_minor}.${version_patch}")
# Verilator
ExternalProject_Add(Verilator
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/verilator
PREFIX verilator
CONFIGURE_COMMAND autoconf && ./configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make -j ${NUM_PARALLEL_JOBS}
BUILD_IN_SOURCE 1
BUILD_ALWAYS 1
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
INSTALL_COMMAND make install)
# Rename Verilator binaries to differentiate from other installed versions.
ExternalProject_Add_Step(Verilator add_executable_prefix
COMMAND ${CMAKE_COMMAND}
-DEXECUTABLE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/bin
-P ${CMAKE_CURRENT_SOURCE_DIR}/add_executable_prefix.cmake
COMMENT "Adding Verilator executable prefix"
DEPENDEES mkdir update patch download configure build install
ALWAYS 1)
add_subdirectory(lib)
add_subdirectory(tools)
if (NETLIST_PATHS_INCLUDE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if (NETLIST_PATHS_BUILD_DOCS)
add_subdirectory(docs)
endif()