Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/miloyip/rapidjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndriy Senkovych <jolly_roger@itblog.org.ua>2014-11-04 01:36:24 +0300
committerAndriy Senkovych <jolly_roger@itblog.org.ua>2014-11-11 18:26:59 +0300
commit8ae1c971ea833fed0640dd87abdeb3374ce890e7 (patch)
tree4edb218eeb3a4776e6fdb1f8b9a11bece86540dd /CMakeLists.txt
parent8d4405cf6309acb89c2cffad4bd5c19ff23b3584 (diff)
Add initial CMake support
* Support for both in-source and out-of-source builds * Set library version to 0.12 to map Debian package * Add separate options to build tests, examples and documentation * Add pkgconfig lookup support (if installed with `make install`) * Add CMake lookup support (if isntalled with `make install`) * Add Google Test Source lookup * Add CTest support for running tests (use `make test` or `ctest -V`)
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt85
1 files changed, 85 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..b7a4961b
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,85 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)
+
+PROJECT(RapidJSON CXX)
+
+set(LIB_MAJOR_VERSION "0")
+set(LIB_MINOR_VERSION "12")
+set(LIB_PATCH_VERSION "0")
+set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}")
+
+# compile in release with debug info mode by default
+SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build Type")
+
+option(RAPIDJSON_BUILD_DOC "Build rapidjson documentation." ON)
+option(RAPIDJSON_BUILD_EXAMPLES "Build rapidjson examples." ON)
+option(RAPIDJSON_BUILD_TESTS "Build rapidjson perftests and unittests." ON)
+
+#add extra search paths for libraries and includes
+SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
+SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install")
+SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation")
+
+IF(UNIX OR CYGWIN)
+ SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}")
+ELSEIF(WIN32)
+ SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake")
+ENDIF()
+SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake fiels are installed in")
+
+
+include_directories(${CMAKE_SOURCE_DIR}/include)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RAPIDJSON_CXX_FLAGS}")
+
+if(RAPIDJSON_BUILD_DOC)
+ add_subdirectory(doc)
+endif()
+
+if(RAPIDJSON_BUILD_EXAMPLES)
+ add_subdirectory(example)
+endif()
+
+if(RAPIDJSON_BUILD_TESTS)
+ add_subdirectory(test)
+ include(CTest)
+endif()
+
+# pkg-config
+IF (UNIX OR CYGWIN)
+ CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
+ @ONLY)
+ INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc
+ DESTINATION "${LIB_INSTALL_DIR}/pkgconfig"
+ COMPONENT pkgconfig)
+ENDIF()
+
+install(FILES readme.md
+ DESTINATION "${DOC_INSTALL_DIR}"
+ COMPONENT doc)
+
+install(DIRECTORY include/rapidjson
+ DESTINATION "${INCLUDE_INSTALL_DIR}"
+ COMPONENT dev)
+
+install(DIRECTORY example/
+ DESTINATION "${DOC_INSTALL_DIR}/examples"
+ COMPONENT examples)
+
+# Provide config and version files to be used by other applications
+# ===============================
+
+export(PACKAGE ${PROJECT_NAME})
+
+# cmake-modules
+CONFIGURE_FILE(${PROJECT_NAME}Config.cmake.in
+ ${PROJECT_NAME}Config.cmake
+ @ONLY)
+CONFIGURE_FILE(${PROJECT_NAME}ConfigVersion.cmake.in
+ ${PROJECT_NAME}ConfigVersion.cmake
+ @ONLY)
+INSTALL(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
+ DESTINATION "${CMAKE_INSTALL_DIR}"
+ COMPONENT dev)