Build Jansson if library not found

If the Jansson JSON library is not found on the system, it is built from
source.
This commit is contained in:
Markus Mäkelä 2017-01-27 07:28:57 +02:00
parent 89f456840c
commit 4adc9d705b
8 changed files with 32 additions and 6 deletions

View File

@ -62,6 +62,12 @@ if(NOT MARIADB_CONNECTOR_FOUND)
include(cmake/BuildMariaDBConnector.cmake)
endif()
if(NOT JANSSON_FOUND)
message(STATUS "Building Jansson from source.")
include(cmake/BuildJansson.cmake)
include_directories(${JANSSON_INCLUDE_DIR})
endif()
# You can find the variables set by this in the FindCURL.cmake file
# which is a default module in CMake.

View File

@ -1,7 +1,7 @@
if (AVRO_FOUND AND JANSSON_FOUND)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_library(maxavro maxavro.c maxavro_schema.c maxavro_record.c maxavro_file.c)
target_link_libraries(maxavro maxscale-common jansson)
target_link_libraries(maxavro maxscale-common ${JANSSON_LIBRARIES})
add_executable(maxavrocheck maxavrocheck.c)
target_link_libraries(maxavrocheck maxavro)

20
cmake/BuildJansson.cmake Normal file
View File

@ -0,0 +1,20 @@
# If the Jansson library is not found, download it and build it from source.
set(JANSSON_REPO "https://github.com/akheron/jansson.git" CACHE STRING "Jansson Git repository")
# Release 2.9 of Jansson
set(JANSSON_TAG "v2.9" CACHE STRING "Jansson Git tag")
ExternalProject_Add(jansson
GIT_REPOSITORY ${JANSSON_REPO}
GIT_TAG ${JANSSON_TAG}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/jansson/install -DCMAKE_C_FLAGS=-fPIC
BINARY_DIR ${CMAKE_BINARY_DIR}/jansson
INSTALL_DIR ${CMAKE_BINARY_DIR}/jansson/install
UPDATE_COMMAND "")
set(JANSSON_FOUND TRUE CACHE INTERNAL "")
set(JANSSON_STATIC_FOUND TRUE CACHE INTERNAL "")
set(JANSSON_INCLUDE_DIR ${CMAKE_BINARY_DIR}/jansson/install/include CACHE INTERNAL "")
set(JANSSON_STATIC_LIBRARIES ${CMAKE_BINARY_DIR}/jansson/install/lib/libjansson.a CACHE INTERNAL "")
set(JANSSON_LIBRARIES ${JANSSON_STATIC_LIBRARIES} CACHE INTERNAL "")

View File

@ -17,7 +17,7 @@ if (JANSSON_FOUND)
storagefactory.cc
storagereal.cc
)
target_link_libraries(cache maxscale-common jansson)
target_link_libraries(cache maxscale-common ${JANSSON_LIBRARIES})
set_target_properties(cache PROPERTIES VERSION "1.0.0")
set_target_properties(cache PROPERTIES LINK_FLAGS -Wl,-z,defs)
install_module(cache core)

View File

@ -17,7 +17,7 @@ if (ROCKSDB_BUILT)
storage_rocksdb.cc
)
add_dependencies(storage_rocksdb RocksDB)
target_link_libraries(storage_rocksdb maxscale-common jansson ${ROCKSDB_LIB} ${ROCKSDB_LINK_LIBS})
target_link_libraries(storage_rocksdb maxscale-common ${JANSSON_LIBRARIES} ${ROCKSDB_LIB} ${ROCKSDB_LINK_LIBS})
set_target_properties(storage_rocksdb PROPERTIES VERSION "1.0.0")
set_target_properties(storage_rocksdb PROPERTIES LINK_FLAGS -Wl,-z,defs)
install_module(storage_rocksdb experimental)

View File

@ -10,7 +10,7 @@ add_library(cachetester
)
add_executable(testrules testrules.cc ../rules.cc)
target_link_libraries(testrules maxscale-common jansson)
target_link_libraries(testrules maxscale-common ${JANSSON_LIBRARIES})
add_executable(testkeygeneration
testkeygeneration.cc

View File

@ -6,7 +6,7 @@ if (JANSSON_FOUND)
maskingrules.cc
)
target_link_libraries(masking maxscale-common jansson)
target_link_libraries(masking maxscale-common ${JANSSON_LIBRARIES})
set_target_properties(masking PROPERTIES VERSION "1.0.0")
set_target_properties(masking PROPERTIES LINK_FLAGS -Wl,-z,defs)
install_module(masking core)

View File

@ -1,6 +1,6 @@
include_directories(..)
add_executable(masking_testrules testrules.cc ../maskingrules.cc)
target_link_libraries(masking_testrules maxscale-common jansson)
target_link_libraries(masking_testrules maxscale-common ${JANSSON_LIBRARIES})
add_test(TestMasking_rules masking_testrules)