forked from fblumenthal/buildem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsoncpp.cmake
88 lines (73 loc) · 3.11 KB
/
jsoncpp.cmake
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
#
# Install the JsonCpp program into an OS-specific build directory
#
if (NOT jsoncpp_NAME)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
include (ExternalProject)
include (ExternalSource)
include (BuildSupport)
include (PatchSupport)
include (python)
external_source (scons_embedded
1.2.0
scons-local-1.2.0.tar.gz
aa92aff8b285ad992c2bf436dae72536
http://downloads.sourceforge.net/project/scons/scons-local/1.2.0)
external_source (jsoncpp
0.5.0
jsoncpp-src-0.5.0.tar.gz
24482b67c1cb17aac1ed1814288a3a8f
http://downloads.sourceforge.net/project/jsoncpp/jsoncpp/0.5.0)
# Copy script will take a string pattern and copy all matches into a destination directory.
# Surprisingly, this is hard to do within ExternalProject_Add due to lack of wildcard expansion?
# TODO -- Find some CMake equivalent although initial attempts have been unsuccessful.
set (COPY_SCRIPT ${BUILDEM_REPO_DIR}/scripts/copy.py)
# Download required scons local package
message ("Installing scons-local 1.2.0 needed to build jsoncpp...")
ExternalProject_Add(${scons_embedded_NAME}
PREFIX ${BUILDEM_DIR}
URL ${scons_embedded_URL}
URL_MD5 ${scons_embedded_MD5}
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
set_target_properties(${scons_embedded_NAME} PROPERTIES EXCLUDE_FROM_ALL ON)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (jsoncpp_PATCH ${BUILDEM_ENV_STRING} ${PATCH_EXE}
${jsoncpp_SRC_DIR}/SConstruct ${PATCH_DIR}/jsoncpp-SConstruct-mac.patch )
else()
set (jsoncpp_PATCH ${BUILDEM_ENV_STRING} ${PATCH_EXE}
${jsoncpp_SRC_DIR}/SConstruct ${PATCH_DIR}/jsoncpp-SConstruct-linux.patch)
endif()
# Download jsoncpp and build it.
message ("Installing ${jsoncpp_NAME} ...")
ExternalProject_Add(${jsoncpp_NAME}
PREFIX ${BUILDEM_DIR}
DEPENDS ${scons_embedded_NAME} ${python_NAME}
URL ${jsoncpp_URL}
URL_MD5 ${jsoncpp_MD5}
UPDATE_COMMAND ${BUILDEM_ENV_STRING} ${PYTHON_EXE}
${COPY_SCRIPT} "${scons_embedded_SRC_DIR}/*" ${jsoncpp_SRC_DIR}
PATCH_COMMAND ${jsoncpp_PATCH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ${BUILDEM_ENV_STRING} ${PYTHON_EXE} scons.py platform=linux-gcc
BUILD_IN_SOURCE 1
INSTALL_COMMAND ""
)
set_target_properties(${jsoncpp_NAME} PROPERTIES EXCLUDE_FROM_ALL ON)
add_custom_command (TARGET ${jsoncpp_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${jsoncpp_SRC_DIR}/libs/linux-gcc-*/libjson_linux-gcc-*_libmt.so
${BUILDEM_DIR}/lib/libjsoncpp.so
COMMAND python ${COPY_SCRIPT}
"${jsoncpp_SRC_DIR}/include/*"
${BUILDEM_DIR}/include
COMMENT "Copied jsoncpp library and include files to ${BUILDEM_DIR}")
set (json_LIB ${BUILDEM_DIR}/lib/libjsoncpp.so)
set (json_INCLUDES ${BUILDEM_DIR}/include)
message ("Including JSON include files from here: ${json_INCLUDES}")
endif (NOT jsoncpp_NAME)