forked from BlueBrain/nmodl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
167 lines (149 loc) · 7.11 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
# =============================================================================
# Copyright (C) 2018-2019 Blue Brain Project
#
# This file is part of NMODL distributed under the terms of the GNU Lesser General Public License.
# See top-level LICENSE file for details.
# =============================================================================
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
project(NMODL CXX)
# =============================================================================
# CMake common project settings
# =============================================================================
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 2)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
# =============================================================================
# Compile static libraries with hidden visibility
# =============================================================================
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# =============================================================================
# Find required packages
# =============================================================================
message(STATUS "CHECKING FOR FLEX/BISON")
find_package(FLEX 2.6 REQUIRED)
find_package(BISON 3.0 REQUIRED)
# =============================================================================
# HPC Coding Conventions
# =============================================================================
set(NMODL_ClangFormat_EXCLUDES_RE ".*/ext/.*$$"
CACHE STRING "list of regular expressions to exclude C/C++ files from formatting"
FORCE)
set(NMODL_CMakeFormat_EXCLUDES_RE ".*/ext/.*$$"
CACHE STRING "list of regular expressions to exclude CMake files from formatting"
FORCE)
set(NMODL_ClangFormat_DEPENDENCIES pyastgen parser-gen
CACHE STRING "list of CMake targets to build before formatting C++ code"
FORCE)
add_subdirectory(cmake/hpc-coding-conventions/cpp)
# =============================================================================
# Format & execute ipynb notebooks in place (pip install nbconvert clean-ipynb)
# =============================================================================
add_custom_target(nb-format
jupyter
nbconvert
--to
notebook
--execute
--inplace
--ExecutePreprocessor.timeout=360
"${CMAKE_SOURCE_DIR}/docs/notebooks/*.ipynb"
&&
clean_ipynb
--keep-output
"${CMAKE_SOURCE_DIR}/docs/notebooks/*.ipynb")
# =============================================================================
# Include cmake modules
# =============================================================================
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(Catch)
include(ClangTidyHelper)
include(CompilerHelper)
include(FindClangFormat)
include(FindPythonModule)
include(FlexHelper)
include(GitRevision)
include(RpathHelper)
# =============================================================================
# Find required python packages
# =============================================================================
message(STATUS "CHECKING FOR PYTHON")
find_package(PythonInterp 3.6 REQUIRED)
find_python_module(jinja2 2.9.3 REQUIRED)
find_python_module(pytest 3.3.0 REQUIRED)
find_python_module(sympy 1.2 REQUIRED)
find_python_module(textwrap 0.9 REQUIRED)
find_python_module(yaml 3.12 REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/src
${PROJECT_BINARY_DIR}/src
${PROJECT_SOURCE_DIR}/ext)
# =============================================================================
# Include pybind11
# =============================================================================
message(STATUS "INCLUDING PYBIND11")
add_subdirectory(ext/pybind11)
# =============================================================================
# Include path from external libraries
# =============================================================================
include_directories(${PROJECT_SOURCE_DIR}/ext/cli11/include)
# =============================================================================
# Project version from git and project directories
# =============================================================================
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
# generate file with version number from git and nrnunits.lib file path
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config/config.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/config.cpp @ONLY)
# generate Doxyfile with correct source paths
configure_file(${PROJECT_SOURCE_DIR}/docs/Doxyfile.in ${PROJECT_SOURCE_DIR}/docs/Doxyfile)
# =============================================================================
# list of autogenerated files
# =============================================================================
set(AUTO_GENERATED_FILES
${PROJECT_BINARY_DIR}/src/ast/ast.hpp
${PROJECT_BINARY_DIR}/src/ast/ast_decl.hpp
${PROJECT_BINARY_DIR}/src/ast/ast.cpp
${PROJECT_BINARY_DIR}/src/pybind/pyast.hpp
${PROJECT_BINARY_DIR}/src/pybind/pyast.cpp
${PROJECT_BINARY_DIR}/src/pybind/pysymtab.cpp
${PROJECT_BINARY_DIR}/src/pybind/pyvisitor.hpp
${PROJECT_BINARY_DIR}/src/pybind/pyvisitor.cpp
${PROJECT_BINARY_DIR}/src/visitors/visitor.hpp
${PROJECT_BINARY_DIR}/src/visitors/ast_visitor.hpp
${PROJECT_BINARY_DIR}/src/visitors/ast_visitor.cpp
${PROJECT_BINARY_DIR}/src/visitors/json_visitor.hpp
${PROJECT_BINARY_DIR}/src/visitors/json_visitor.cpp
${PROJECT_BINARY_DIR}/src/visitors/lookup_visitor.hpp
${PROJECT_BINARY_DIR}/src/visitors/lookup_visitor.cpp
${PROJECT_BINARY_DIR}/src/visitors/symtab_visitor.hpp
${PROJECT_BINARY_DIR}/src/visitors/symtab_visitor.cpp
${PROJECT_BINARY_DIR}/src/visitors/nmodl_visitor.hpp
${PROJECT_BINARY_DIR}/src/visitors/nmodl_visitor.cpp)
add_subdirectory(src/codegen)
add_subdirectory(src/language)
add_subdirectory(src/lexer)
add_subdirectory(src/nmodl)
add_subdirectory(src/parser)
add_subdirectory(src/printer)
add_subdirectory(src/symtab)
add_subdirectory(src/utils)
add_subdirectory(src/visitors)
add_subdirectory(src/pybind)
add_subdirectory(src/solver)
# =============================================================================
# Memory checker options and add tests
# =============================================================================
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes \
--leak-check=full \
--track-origins=yes \
--show-possibly-lost=no")
include(CTest)
add_subdirectory(test)
# =============================================================================
# Install unit database, examples and utility scripts from share
# =============================================================================
install(DIRECTORY share/ DESTINATION share)