-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
163 lines (140 loc) · 5.08 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/modules/" "${CMAKE_CURRENT_SOURCE_DIR}/modules/")
PROJECT(mathematica++)
MESSAGE(STATUS "MODULE PATH" ${CMAKE_MODULE_PATH})
MACRO(USE_CXX11)
IF(CMAKE_VERSION VERSION_LESS "3.1")
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "--std=gnu++14 ${CMAKE_CXX_FLAGS}")
ENDIF()
ELSE()
SET(CMAKE_CXX_STANDARD 14)
ENDIF()
ENDMACRO(USE_CXX11)
USE_CXX11()
# https://stackoverflow.com/a/19578320/256007
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
SET(CMAKE_CXX_FLAGS "-ftemplate-backtrace-limit=0 ${CMAKE_CXX_FLAGS}")
SET(Mathematica_USE_STATIC_LIBRARIES ON)
FIND_PACKAGE(Boost COMPONENTS filesystem REQUIRED)
FIND_PACKAGE(Mathematica 11.0.0 REQUIRED)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${Mathematica_INCLUDE_DIR})
SET(MATHEMATICAPP_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/includes
)
INCLUDE_DIRECTORIES(${MATHEMATICAPP_INCLUDE_DIRS})
OPTION(WITH_ML "Use MathLink functions insteadof using WSTP" OFF)
OPTION(PRINT_TRACE "Print low level the WS/ML functions that are being used" OFF)
OPTION(WITHOUT_EIGEN "Compile without using eigen even if available" OFF)
IF(WITH_ML)
MESSAGE("${BoldMagenta} Using MathLink instead of WSTP ${ColourReset}")
IF(${CMAKE_VERSION} VERSION_LESS "3.12.0")
ADD_COMPILE_OPTIONS(-D USING_ML)
ELSE()
ADD_COMPILE_DEFINITIONS(USING_ML)
ENDIF()
INCLUDE_DIRECTORIES(${Mathematica_MathLink_INCLUDE_DIR})
ELSE()
IF(${CMAKE_VERSION} VERSION_LESS "3.12.0")
ADD_COMPILE_OPTIONS(-D USING_WS)
ELSE()
ADD_COMPILE_DEFINITIONS(USING_WS)
ENDIF()
INCLUDE_DIRECTORIES(${Mathematica_WSTP_INCLUDE_DIR})
ENDIF()
IF(PRINT_TRACE)
IF(${CMAKE_VERSION} VERSION_LESS "3.12.0")
ADD_COMPILE_OPTIONS(-D USING_DEBUG_TRACE)
ELSE()
ADD_COMPILE_DEFINITIONS(USING_DEBUG_TRACE)
ENDIF()
ENDIF()
IF(NOT WITHOUT_EIGEN)
FIND_PACKAGE(Eigen3 NO_MODULE)
IF(Eigen3_FOUND)
INCLUDE_DIRECTORIES(${EIGEN3_INCLUDE_DIR})
IF(${CMAKE_VERSION} VERSION_LESS "3.12.0")
ADD_COMPILE_OPTIONS(-D USING_LIB_EIGEN)
ELSE()
ADD_COMPILE_DEFINITIONS(USING_LIB_EIGEN)
ENDIF()
MESSAGE("${BoldMagenta} Using Eigen3 library ${ColourReset}")
ENDIF()
ENDIF()
SET(MATHEMATICAPP_HEADERS
includes/mathematica++/scope.h
includes/mathematica++/connector.h
includes/mathematica++/exceptions.h
includes/mathematica++/tokens.h
includes/mathematica++/accessor.h
includes/mathematica++/variant.h
includes/mathematica++/drivers.h
includes/mathematica++/m.h
includes/mathematica++/io.h
includes/mathematica++/symbol.h
includes/mathematica++/rules.h
includes/mathematica++/operators.h
includes/mathematica++/declares.h
includes/mathematica++/connection.h
includes/mathematica++/packet.h
includes/mathematica++/history.h
includes/mathematica++/mhelper.h
includes/mathematica++/association.h
)
SET(MATHEMATICAPP_SOURCES
sources/scope.cpp
sources/connector.cpp
sources/exceptions.cpp
sources/tokens.cpp
sources/accessor.cpp
sources/variant.cpp
sources/drivers.cpp
sources/m.cpp
sources/io.cpp
sources/symbol.cpp
sources/rules.cpp
sources/operators.cpp
sources/declares.cpp
sources/connection.cpp
sources/packet.cpp
sources/history.cpp
sources/mhelper.cpp
sources/association.cpp
)
IF (DEFINED XCODE_VERSION)
ADD_LIBRARY(mathematica++ SHARED ${MATHEMATICAPP_SOURCES} ${MATHEMATICAPP_HEADERS})
ELSE()
ADD_LIBRARY(mathematica++ SHARED ${MATHEMATICAPP_SOURCES})
ENDIF()
TARGET_INCLUDE_DIRECTORIES(mathematica++ PUBLIC ${MATHEMATICAPP_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(mathematica++ ${Boost_LIBRARIES})
IF(WITH_ML)
TARGET_LINK_LIBRARIES(mathematica++ ${Mathematica_MathLink_LIBRARIES})
TARGET_LINK_LIBRARIES(mathematica++ ${Mathematica_WolframLibrary_LIBRARIES})
ELSE()
TARGET_LINK_LIBRARIES(mathematica++ ${Mathematica_WSTP_LIBRARIES})
ENDIF()
SET(M_STORAGE_LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/storage.m)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/includes/mathematica++/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/includes/mathematica++/config.h)
MESSAGE(STATUS "Expecting storage.m in " ${M_STORAGE_LIB_PATH})
ENABLE_TESTING()
ADD_SUBDIRECTORY(tests)