Skip to content

Commit bae67cf

Browse files
committed
Add a ENABLE_SYSTEM_JSONCPP option to link against system-provided JSONCPP.
1 parent 7c35964 commit bae67cf

File tree

5 files changed

+120
-33
lines changed

5 files changed

+120
-33
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ option(ENABLE_MATHEMATICA "Enable Mathematica support" ON)
8282

8383
option(ENABLE_FRONTEND "Enable the UI frontend" ON)
8484

85+
option(ENABLE_SYSTEM_JSONCPP "Use the system-provided jsoncpp library" OFF)
86+
8587
option(INSTALL_TARGETS_ONLY "Only install targets; skipping icons, shared libraries etc..." OFF)
8688
if (INSTALL_TARGETS_ONLY)
8789
message(STATUS "INSTALL_TARGETS_ONLY is enabled, please make sure all auxillary files and programs Cadabra requires are already installed")

client_server/CMakeLists.txt

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ find_package(GLIBMM REQUIRED)
1919
find_package(SQLite3 REQUIRED)
2020
find_package(Threads REQUIRED)
2121
find_package(Boost 1.53.0 COMPONENTS system program_options date_time filesystem REQUIRED)
22-
22+
if(ENABLE_SYSTEM_JSONCPP)
23+
message("-- Linking against system-provided jsoncpp")
24+
find_package(jsoncpp REQUIRED)
25+
else()
26+
message("-- Linking against included jsoncpp")
27+
endif()
2328

2429
#---------------------------------------------------------------------------
2530
# Enumerate input files.
@@ -32,9 +37,8 @@ set(CADABRA_SERVER_SRC
3237
${CADABRA_CORE_DIR}/InstallPrefix.cc
3338
${CADABRA_CORE_DIR}/CdbPython.cc
3439
${CADABRA_CORE_DIR}/Stopwatch.cc
35-
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
3640
${CADABRA_LIBS_DIR}/whereami/whereami.c
37-
)
41+
)
3842

3943
set(CADABRA_CLIENT_SRC
4044
ComputeThread.cc
@@ -43,9 +47,18 @@ set(CADABRA_CLIENT_SRC
4347
Snoop.cc
4448
${CADABRA_CORE_DIR}/DataCell.cc
4549
${CADABRA_CORE_DIR}/InstallPrefix.cc
46-
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
4750
${CADABRA_LIBS_DIR}/whereami/whereami.c
48-
)
51+
)
52+
53+
if(ENABLE_SYSTEM_JSONCPP)
54+
else()
55+
list(APPEND CADABRA_SERVER_SRC
56+
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
57+
)
58+
list(APPEND CADABRA_CLIENT_SRC
59+
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
60+
)
61+
endif()
4962

5063
#---------------------------------------------------------------------------
5164
# Include directories and preprocessor directives.
@@ -56,13 +69,21 @@ include_directories(
5669
"${CADABRA_CORE_DIR}"
5770
"${CADABRA_LIBS_DIR}/pybind11/include"
5871
"${CADABRA_LIBS_DIR}/websocketpp"
59-
"${CADABRA_LIBS_DIR}/jsoncpp"
6072
"${CADABRA_LIBS_DIR}/internal/include"
6173
"${CADABRA_LIBS_DIR}/whereami"
6274
${Boost_INCLUDE_DIRS}
6375
${PYTHON_INCLUDE_DIRS}
6476
${SQLITE3_INCLUDE_DIR}
6577
)
78+
if(ENABLE_SYSTEM_JSONCPP)
79+
include_directories(
80+
${JSONCPP_INCLUDE_DIRS}
81+
)
82+
else()
83+
include_directories(
84+
"${CADABRA_LIBS_DIR}/jsoncpp"
85+
)
86+
endif()
6687

6788
add_definitions(
6889
-D_WEBSOCKETPP_CPP11_STL_
@@ -87,8 +108,13 @@ target_link_libraries(cadabra-server
87108
${SQLITE3_LIBRARIES}
88109
${PYTHON_LIBRARIES}
89110
${GLIBMM3_LIBRARIES}
90-
Threads::Threads
91-
)
111+
Threads::Threads
112+
)
113+
if(ENABLE_SYSTEM_JSONCPP)
114+
target_link_libraries(cadabra-server
115+
${JSONCPP_LIBRARIES}
116+
)
117+
endif()
92118
if(WIN32)
93119
target_link_libraries(cadabra-server ws2_32 mswsock bcrypt)
94120
endif()
@@ -109,6 +135,11 @@ target_link_libraries(cadabra_client
109135
${GLIBMM3_LIBRARIES}
110136
Threads::Threads
111137
)
138+
if(ENABLE_SYSTEM_JSONCPP)
139+
target_link_libraries(cadabra_client
140+
${JSONCPP_LIBRARIES}
141+
)
142+
endif()
112143
if(WIN32)
113144
target_link_libraries(cadabra_client ws2_32 bcrypt)
114145
endif()

client_server/notebook.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
<head>
3-
<link rel="stylesheet" href="http://cadabra.science/static/fonts/Serif/cmun-serif.css"></link>
3+
<link rel="stylesheet" href="https://cadabra.science/static/fonts/Serif/cmun-serif.css"></link>
44
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/latest.js?config=TeX-AMS-MML_HTMLorMML' async></script>
55
<style>
66
div.image_png { width: 400px; }

core/CMakeLists.txt

Lines changed: 67 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ find_package(GLIBMM REQUIRED)
2727
# GMPXX
2828
find_package(GMPXX REQUIRED)
2929

30+
# JSONCPP (if using the system-provided one)
31+
if(ENABLE_SYSTEM_JSONCPP)
32+
find_package(JSONCPP REQUIRED)
33+
endif()
34+
3035
#---------------------------------------------------------------------------
3136
# Enumerate input files and directories.
3237
#---------------------------------------------------------------------------
@@ -206,8 +211,13 @@ set(LOCAL_SRC_FILES
206211
modules/xperm_new.cc
207212
${ALGORITHM_SRC_FILES}
208213
${PROPERTY_SRC_FILES}
209-
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
210-
)
214+
)
215+
if(ENABLE_SYSTEM_JSONCPP)
216+
else()
217+
list(APPEND LOCAL_SRC_FILES
218+
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
219+
)
220+
endif()
211221
if(MATHEMATICA_FOUND)
212222
set(LOCAL_SRC_FILES
213223
${LOCAL_SRC_FILES}
@@ -229,9 +239,17 @@ include_directories(
229239
"."
230240
"${CADABRA_LIBS_DIR}/internal/include"
231241
"${CADABRA_LIBS_DIR}/whereami"
232-
"${CADABRA_LIBS_DIR}/jsoncpp"
233242
${Boost_INCLUDE_DIRS}
234-
)
243+
)
244+
if(ENABLE_SYSTEM_JSONCPP)
245+
include_directories(
246+
${JSONCPP_INCLUDE_DIRS}
247+
)
248+
else()
249+
include_directories(
250+
"${CADABRA_LIBS_DIR}/jsoncpp"
251+
)
252+
endif()
235253
# FIXME: 2nd line is to find Config.hh
236254
# FIXME: the client_server bit should go back to client_server eventually
237255

@@ -250,7 +268,12 @@ target_link_libraries(cadabra2 PRIVATE
250268
${GMPXX_LIBRARIES}
251269
${GMP_LIBRARIES}
252270
${Boost_LIBRARIES}
253-
)
271+
)
272+
if(ENABLE_SYSTEM_JSONCPP)
273+
target_link_libraries(cadabra2 PRIVATE
274+
${JSONCPP_LIBRARIES}
275+
)
276+
endif()
254277
if(MATHEMATICA_FOUND)
255278
target_link_libraries(cadabra2 PRIVATE ${Mathematica_WSTP_LIBRARIES})
256279
endif()
@@ -262,25 +285,47 @@ add_executable(test_preprocessor
262285
)
263286

264287
# cadabra2python executable
265-
add_executable(cadabra2python
266-
cadabra2python.cc
267-
CdbPython.cc
268-
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
269-
)
270-
target_link_libraries(cadabra2python
271-
${Boost_LIBRARIES}
272-
${PYTHON_LIBRARIES}
273-
)
288+
if(ENABLE_SYSTEM_JSONCPP)
289+
add_executable(cadabra2python
290+
cadabra2python.cc
291+
CdbPython.cc
292+
)
293+
target_link_libraries(cadabra2python
294+
${Boost_LIBRARIES}
295+
${PYTHON_LIBRARIES}
296+
${JSONCPP_LIBRARIES}
297+
)
298+
else()
299+
add_executable(cadabra2python
300+
cadabra2python.cc
301+
CdbPython.cc
302+
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
303+
)
304+
target_link_libraries(cadabra2python
305+
${Boost_LIBRARIES}
306+
${PYTHON_LIBRARIES}
307+
)
308+
endif()
274309

275310
# cadabra2cadabra
276-
add_executable(cadabra2cadabra
277-
cadabra2cadabra.cc
278-
DataCell.cc
279-
InstallPrefix.cc
280-
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
281-
${CADABRA_LIBS_DIR}/whereami/whereami.c
282-
)
283-
target_link_libraries(cadabra2cadabra ${Boost_LIBRARIES} ${GLIBMM3_LIBRARIES})
311+
if(ENABLE_SYSTEM_JSONCPP)
312+
add_executable(cadabra2cadabra
313+
cadabra2cadabra.cc
314+
DataCell.cc
315+
InstallPrefix.cc
316+
${CADABRA_LIBS_DIR}/whereami/whereami.c
317+
)
318+
target_link_libraries(cadabra2cadabra ${Boost_LIBRARIES} ${GLIBMM3_LIBRARIES} ${JSONCPP_LIBRARIES})
319+
else()
320+
add_executable(cadabra2cadabra
321+
cadabra2cadabra.cc
322+
DataCell.cc
323+
InstallPrefix.cc
324+
${CADABRA_LIBS_DIR}/jsoncpp/jsoncpp.cpp
325+
${CADABRA_LIBS_DIR}/whereami/whereami.c
326+
)
327+
target_link_libraries(cadabra2cadabra ${Boost_LIBRARIES} ${GLIBMM3_LIBRARIES})
328+
endif()
284329

285330
# Mathematica WSTP test
286331
if(MATHEMATICA_FOUND)

frontend/gtkmm/CMakeLists.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,22 @@ include_directories(
6363
"${CADABRA_CORE_DIR}"
6464
"${CADABRA_CLIENT_SERVER_DIR}"
6565
"${CADABRA_LIBS_DIR}/internal/include"
66-
"${CADABRA_LIBS_DIR}/jsoncpp"
6766
"${CADABRA_LIBS_DIR}/websocketpp"
6867
"${CADABRA_LIBS_DIR}/tiny-process-library"
6968
${Boost_INCLUDE_DIRS}
7069
${SQLITE3_INCLUDE_DIR}
71-
)
70+
)
7271

72+
if(ENABLE_SYSTEM_JSONCPP)
73+
include_directories(
74+
${JSONCPP_INCLUDE_DIRS}
75+
)
76+
else()
77+
include_directories(
78+
"${CADABRA_LIBS_DIR}/jsoncpp"
79+
)
80+
endif()
81+
7382
add_definitions(
7483
"-D_WEBSOCKETPP_CPP11_STL_"
7584
"-DBOOST_LOG_DYN_LINK"

0 commit comments

Comments
 (0)