Permalink
Browse files

Made Cmake config more complete and multi-impl rdy

  • Loading branch information...
1 parent 2eaecdc commit 39f577b8278d3c79d13cacc8695c4677c2ccb572 Rob Meijer committed Feb 20, 2012
Showing with 44 additions and 10 deletions.
  1. +44 −8 CMakeLists.txt
  2. +0 −2 README
View
@@ -6,15 +6,51 @@ 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 )
-ADD_DEFINITIONS(-DUSE_GOBJECT_JSON_LIB)
-ADD_DEFINITIONS( -I/usr/include/json-glib-1.0/ -I/usr/include/glib-2.0/)
-IF(EXISTS "/usr/include/json-glib-1.0/")
- ADD_DEFINITIONS( -I/usr/include/json-glib-1.0/)
+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()
-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)
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)
View
2 README
@@ -11,8 +11,6 @@ After the 1.0 we may look at the following:
* See if we can get stuff compiling with the -Wold-style-cast flag set.
* I didn't find a list of the Gtype's that json-glib can produce, there are probably some pieces of
dead code in gobj/GobjectImplScalar.cpp and there might be one missing.
-* The CMakeLists.txt doesn't look for its dependencies and just adds -I flags that happen to be right
- on Ubuntu 11.4. Should do some real checking.
* I didn't create non of the operator<< stuff for making usage ostream usage easy. Tried to for half
an hour and kept getting useless messages from my compiler. Should make the library even more
friendly if we could fix this.

0 comments on commit 39f577b

Please sign in to comment.