2017-09-18 15:33:32 +00:00
|
|
|
include(ExternalProject)
|
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
|
|
|
set(JSONCPP_CMAKE_COMMAND emcmake cmake)
|
|
|
|
else()
|
|
|
|
set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(prefix "${CMAKE_BINARY_DIR}/deps")
|
2018-06-06 06:03:07 +00:00
|
|
|
set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
2017-09-18 15:33:32 +00:00
|
|
|
set(JSONCPP_INCLUDE_DIR "${prefix}/include")
|
|
|
|
|
2018-04-17 08:50:03 +00:00
|
|
|
if(NOT MSVC)
|
|
|
|
set(JSONCPP_EXTRA_FLAGS "-std=c++11")
|
|
|
|
endif()
|
|
|
|
|
2017-09-18 15:33:32 +00:00
|
|
|
set(byproducts "")
|
|
|
|
if(CMAKE_VERSION VERSION_GREATER 3.1)
|
|
|
|
set(byproducts BUILD_BYPRODUCTS "${JSONCPP_LIBRARY}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
ExternalProject_Add(jsoncpp-project
|
|
|
|
PREFIX "${prefix}"
|
2017-09-19 18:41:28 +00:00
|
|
|
DOWNLOAD_DIR "${CMAKE_SOURCE_DIR}/deps/downloads"
|
2018-02-15 23:03:12 +00:00
|
|
|
DOWNLOAD_NAME jsoncpp-1.8.4.tar.gz
|
|
|
|
URL https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.tar.gz
|
|
|
|
URL_HASH SHA256=c49deac9e0933bcb7044f08516861a2d560988540b23de2ac1ad443b219afdb6
|
2017-09-18 15:33:32 +00:00
|
|
|
CMAKE_COMMAND ${JSONCPP_CMAKE_COMMAND}
|
|
|
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
|
|
|
|
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
|
|
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
2018-06-06 06:03:07 +00:00
|
|
|
-DCMAKE_INSTALL_LIBDIR=lib
|
2017-09-18 15:33:32 +00:00
|
|
|
# Build static lib but suitable to be included in a shared lib.
|
|
|
|
-DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS}
|
|
|
|
-DJSONCPP_WITH_TESTS=OFF
|
|
|
|
-DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF
|
2018-04-17 08:50:03 +00:00
|
|
|
-DCMAKE_CXX_FLAGS=${JSONCPP_EXTRA_FLAGS}
|
2018-07-10 13:12:32 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
2017-09-18 15:33:32 +00:00
|
|
|
${byproducts}
|
|
|
|
)
|
|
|
|
|
|
|
|
# Create jsoncpp imported library
|
|
|
|
add_library(jsoncpp STATIC IMPORTED)
|
|
|
|
file(MAKE_DIRECTORY ${JSONCPP_INCLUDE_DIR}) # Must exist.
|
|
|
|
set_property(TARGET jsoncpp PROPERTY IMPORTED_LOCATION ${JSONCPP_LIBRARY})
|
|
|
|
set_property(TARGET jsoncpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JSONCPP_INCLUDE_DIR})
|
|
|
|
add_dependencies(jsoncpp jsoncpp-project)
|