-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from jollyroger/cmake
CMake support
- Loading branch information
Showing
21 changed files
with
325 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) | ||
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") | ||
|
||
# Build all binaries in a separate directory | ||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | ||
|
||
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) | ||
|
||
option(RAPIDJSON_HAS_STDSTRING "" OFF) | ||
if(RAPIDJSON_HAS_STDSTRING) | ||
add_definitions(-DRAPIDJSON_HAS_STDSTRING) | ||
endif() | ||
|
||
|
||
#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() | ||
|
||
add_custom_target(travis_doc) | ||
add_custom_command(TARGET travis_doc | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/travis-doxygen.sh) | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
SET(GTEST_SEARCH_PATH | ||
"${GTEST_SOURCE_DIR}" | ||
"${CMAKE_SOURCE_DIR}/thirdparty/gtest") | ||
|
||
IF(UNIX) | ||
LIST(INSERT GTEST_SEARCH_PATH 1 "/usr/src/gtest") | ||
ENDIF() | ||
|
||
FIND_PATH(GTEST_SOURCE_DIR | ||
NAMES CMakeLists.txt src/gtest_main.cc | ||
PATHS ${GTEST_SEARCH_PATH}) | ||
|
||
# Debian installs gtest include directory in /usr/include, thus need to look | ||
# for include directory separately from source directory. | ||
FIND_PATH(GTEST_INCLUDE_DIR | ||
NAMES gtest/gtest.h | ||
PATH_SUFFIXES include | ||
PATHS ${GTEST_SEARCH_PATH}) | ||
|
||
find_package_handle_standard_args(GTestSrc DEFAULT_MSG | ||
GTEST_SOURCE_DIR | ||
GTEST_INCLUDE_DIR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Name: @PROJECT_NAME@ | ||
Description: RapidJSON is a JSON parser and generator for C++ inspired by RapidXml. | ||
Version: @LIB_VERSION_STRING@ | ||
Cflags: -I${includedir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
get_filename_component(RAPIDJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
set(RAPIDJSON_INCLUDE_DIRS "@INCLUDE_INSTALL_DIR@") | ||
message(STATUS "RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SET(PACKAGE_VERSION "@LIB_VERSION_STRING@") | ||
|
||
IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) | ||
SET(PACKAGE_VERSION_EXACT "true") | ||
ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) | ||
IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) | ||
SET(PACKAGE_VERSION_COMPATIBLE "true") | ||
ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) | ||
SET(PACKAGE_VERSION_UNSUITABLE "true") | ||
ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.