-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
117 lines (107 loc) · 4.44 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
# MIT License
#
# Copyright (c) 2022 Asger Gitz-Johansen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
cmake_minimum_required(VERSION 3.18)
project(expr VERSION 3.0.6)
include(cmake/CPM.cmake)
configure_file(src/config.h.in config.h)
set(CMAKE_CXX_STANDARD 20)
set(CXX_STANDARD_REQUIRED ON)
# OPTIONS
option(ENABLE_Z3 "Enables the download and compilation of the expr::z3_driver driver. OFF by default" OFF)
# DEPENDENCIES
# library dependencies
CPMAddPackage("gh:yalibs/[email protected]")
CPMAddPackage("gh:yalibs/[email protected]")
CPMAddPackage("gh:yalibs/[email protected]")
CPMAddPackage("gh:yalibs/[email protected]")
# demo dependencies
CPMAddPackage("gh:yalibs/[email protected]")
CPMAddPackage("gh:sillydan1/[email protected]")
if(ENABLE_Z3)
find_package(Z3 REQUIRED)
if(NOT Z3_FOUND)
include(cmake/Z3.cmake)
set(Z3_VERSION_NUMBER z3-4.13.0)
get_z3_zip_file(${Z3_VERSION_NUMBER})
CPMAddPackage(NAME z3 VERSION ${Z3_VERSION_NUMBER} URL ${z3vstr})
endif()
endif()
set(${PROJECT_NAME}_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "expr_BUILD_DIR" FORCE)
add_library(${PROJECT_NAME} SHARED
src/symbol/clock.cpp
src/symbol/symbol_table.cpp
src/operations/add.cpp
src/operations/subtract.cpp
src/operations/multiply.cpp
src/operations/divide.cpp
src/operations/modulo.cpp
src/operations/pow.cpp
src/operations/boolean.cpp
src/driver/evaluator.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
${yatree_SOURCE_DIR}/include
${yatimer_SOURCE_DIR}/include
${yaoverload_SOURCE_DIR}/include
${yahashcombine_SOURCE_DIR}/include
${yauuid_SOURCE_DIR}/include
${argvparse_SOURCE_DIR}/include
${z3_SOURCE_DIR}/src/api/c++
${z3_SOURCE_DIR}/include
${Z3_CXX_INCLUDE_DIRS}
${Z3_C_INCLUDE_DIRS}
src/symbol
include
src)
add_library(${PROJECT_NAME}_generic_driver SHARED src/generic-driver.cpp)
target_include_directories(${PROJECT_NAME}_generic_driver PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/src
${yatree_SOURCE_DIR}/include
${yatimer_SOURCE_DIR}/include
${yaoverload_SOURCE_DIR}/include
${yahashcombine_SOURCE_DIR}/include
${argvparse_SOURCE_DIR}/include
${Z3_CXX_INCLUDE_DIRS}
${Z3_C_INCLUDE_DIRS}
src/symbol
include
src)
add_subdirectory(src/expr-lang)
if(ENABLE_Z3)
target_sources(${PROJECT_NAME} PUBLIC src/driver/z3/z3-driver.cpp)
target_compile_definitions(${PROJECT_NAME} PUBLIC ENABLE_Z3)
if(NOT Z3_FOUND)
target_link_directories(${PROJECT_NAME} PUBLIC ${z3_SOURCE_DIR}/bin)
target_link_libraries(${PROJECT_NAME} z3)
add_custom_target(copy_z3 COMMAND ${CMAKE_COMMAND} -E copy ${z3_SOURCE_DIR}/bin/libz3.* ${CMAKE_BINARY_DIR})
add_dependencies(${PROJECT_NAME} copy_z3)
else()
target_link_libraries(${PROJECT_NAME} z3::libz3)
endif()
endif()
add_executable(${PROJECT_NAME}_demo src/main.cpp)
set_target_properties(${PROJECT_NAME}_demo PROPERTIES RPATH ${z3_SOURCE_DIR}/bin)
target_link_libraries(${PROJECT_NAME}_demo ${PROJECT_NAME} expr_lang argvparse ${PROJECT_NAME}_generic_driver)
target_link_libraries(${PROJECT_NAME}_generic_driver expr_lang)