CMakeLists.txt 1.8 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
set(SRC_FILES
    src/Json.cpp
)

set(INC_FILES
    inc/MantidJson/Json.h
)

set (TEST_FILES
    test/JsonTest.h
)

add_library(Json ${SRC_FILES} ${INC_FILES})
14
add_library(Mantid::Json ALIAS Json)
Stephen's avatar
Stephen committed
15
16
17


target_link_libraries(Json PUBLIC JsonCPP::jsoncpp)
18
19
20
21
22
23
24
25
26
27
28
set_target_properties(Json PROPERTIES OUTPUT_NAME MantidJson)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
  set_target_properties(Json
                        PROPERTIES INSTALL_RPATH
                                   "@loader_path/../Contents/MacOS")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  set_target_properties(Json
                        PROPERTIES INSTALL_RPATH "\$ORIGIN/../${LIB_DIR}")
endif()

29
30
31
32
33
34

target_include_directories(Json PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
	$<INSTALL_INTERFACE:include/Mantid>
)

35
36
37
38
# Add to the 'Framework' group in VS
set_property(TARGET Json PROPERTY FOLDER "MantidFramework")

# Auto-generate exports header
Stephen's avatar
Stephen committed
39
40
41
42
43
target_include_directories(Json PUBLIC
  $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/Framework/Json>
  $<INSTALL_INTERFACE:include/Mantid>
)

44
45
generate_mantid_export_header(Json FALSE)

Samuel Jones's avatar
Samuel Jones committed
46
47
48
if(CXXTEST_FOUND)

cxxtest_add_test(JsonTest ${TEST_FILES})
49
target_include_directories(JsonTest SYSTEM PRIVATE ${CXXTEST_INCLUDE_DIR} ${JSONCPP_INCLUDE_DIR})
50
target_link_libraries(JsonTest PUBLIC ${JSONCPP_LIBRARIES} gmock Json)
Samuel Jones's avatar
Samuel Jones committed
51
52
53
54
55
56
57

add_dependencies(FrameworkTests JsonTest)

# Add to the 'FrameworkTests' group in VS
set_property(TARGET JsonTest PROPERTY FOLDER "UnitTests")

endif()
58
59
60
61
62
63
64
65
66
67
68
69

# Installation settings
if (CONDA_BUILD)
set(TARGET_EXPORT_NAME "MantidJsonTargets")
mtd_install_framework_lib(TARGETS Json INSTALL_EXPORT_FILE EXPORT_NAME ${TARGET_EXPORT_NAME})
else()
mtd_install_targets(TARGETS
                    Json
                    INSTALL_DIRS
                    ${LIB_DIR}
                    ${WORKBENCH_LIB_DIR})
endif()