Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (83 sloc) 3.53 KB
cmake_minimum_required(VERSION 2.6)
enable_testing()
project(jsonme)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
set(includedir ${CMAKE_INSTALL_PREFIX}/include)
ADD_DEFINITIONS( -Wall -Werror -Weffc++ -Wctor-dtor-privacy -Wuninitialized -Winit-self -Wmissing-include-dirs -Wfloat-equal -Wshadow -Wpointer-arith )
SET(GOBJ_JSON_INC_SEARCHPATH
/usr/include
/usr/local/include
/usr/include/json-glib-1.0/
/usr/include/json-glib-1.0/json-glib/
)
FIND_PATH(GOBJ_JSON_INCLUDE_PATH json-glib.h ${GOBJ_JSON_INC_SEARCHPATH})
SET(GOBJ_JSON_LIB_SEARCHPATH
/usr/lib
/usr/local/lib
)
FIND_LIBRARY(GOBJ_JSON_LIBRARY json-glib-1.0 ${GOBJ_JSON_LIB_SEARCHPATH})
SET(SPIRIT_JSON_INC_SEARCHPATH
/usr/include
/usr/local/include
)
FIND_PATH(SPIRIT_JSON_INCLUDE_PATH json_spirit.h ${SPIRIT_JSON_INC_SEARCHPATH})
SET(SPIRIT_JSON_LIB_SEARCHPATH
/usr/lib
/usr/local/lib
)
FIND_LIBRARY(SPIRIT_JSON_LIBRARY json_spirit ${SPIRIT_JSON_LIB_SEARCHPATH})
IF(GOBJ_JSON_LIBRARY)
IF(GOBJ_JSON_INCLUDE_PATH)
message(STATUS "Using json-glib as low level library")
ADD_DEFINITIONS(-DUSE_GOBJECT_JSON_LIB)
IF(EXISTS "/usr/include/glib-2.0/")
ADD_DEFINITIONS( -I/usr/include/glib-2.0/)
ENDIF()
IF(EXISTS "/usr/include/json-glib-1.0/")
ADD_DEFINITIONS( -I/usr/include/json-glib-1.0/)
ENDIF()
IF(EXISTS "/usr/lib/x86_64-linux-gnu/glib-2.0/include/")
ADD_DEFINITIONS( -I/usr/lib/x86_64-linux-gnu/glib-2.0/include/)
ENDIF()
add_library(jsonme SHARED JsonMeLib.cpp Scalar.cpp Node.cpp ParseError.cpp gobj/GobjectLibImpl.cpp gobj/GobjectImplParser.cpp gobj/GobjectImplFsTopNode.cpp gobj/GobjectImplStringTopNode.cpp gobj/GobjectImplError.cpp gobj/GobjectImplNode.cpp gobj/GobjectImplScalar.cpp gobj/GobjectImplKeys.cpp)
ELSE()
message(STATUS "Found the json-glib library but not the relevant header files.")
ENDIF()
ELSEIF(SPIRIT_JSON_LIBRARY)
message(FATAL_ERROR "Json glib has not been found and the Spirit json based library implementation has not yet been implemented.")
ELSE()
message(FATAL_ERROR "No suitable json lib found.")
ENDIF()
SET_TARGET_PROPERTIES(jsonme PROPERTIES VERSION 1.0.0 SOVERSION 1)
target_link_libraries(jsonme gobject-2.0 json-glib-1.0)
install_targets(/lib jsonme)
install(FILES json-me.hpp DESTINATION include)
add_executable(test_bogusstring tests/bogusstring.cpp)
target_link_libraries(test_bogusstring jsonme)
add_test(tests.bogusstring test_bogusstring)
add_executable(test_bogusfile tests/bogusfile.cpp)
target_link_libraries(test_bogusfile jsonme)
add_test(tests.bogusfile test_bogusfile)
add_executable(test_parsejsonstring tests/parsejsonstring.cpp)
target_link_libraries(test_parsejsonstring jsonme)
add_test(tests.parsejsonstring test_parsejsonstring)
add_executable(test_parsejsonfile tests/parsejsonfile.cpp)
target_link_libraries(test_parsejsonfile jsonme)
add_test(tests.parsejsonfile test_parsejsonfile)
add_executable(test_bogusnode tests/bogusnode.cpp)
target_link_libraries(test_bogusnode jsonme)
add_test(tests.bogusnode test_bogusnode)
add_executable(test_validnode tests/validnode.cpp)
target_link_libraries(test_validnode jsonme)
add_test(tests.validnode test_validnode)
add_executable(test_nodecount tests/nodecount.cpp)
target_link_libraries(test_nodecount jsonme)
add_test(tests.nodecount test_nodecount)
add_executable(test_value tests/value.cpp)
target_link_libraries(test_value jsonme)
add_test(tests.value test_value)
add_executable(test_keys tests/keys.cpp)
target_link_libraries(test_keys jsonme)
add_test(tests.keys test_keys)