Skip to content

Commit ba45ad7

Browse files
committed
cmake: add option to use system rapidjson if exists
1 parent 5e15f51 commit ba45ad7

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(DefaultCMakeBuildType)
77
# Required Clang version
88
option(LLVM_ENABLE_RTTI "-fno-rtti if OFF. This should match LLVM libraries" OFF)
99
option(USE_SHARED_LLVM "Link against libLLVM.so instead separate LLVM{Option,Support,...}" OFF)
10+
option(USE_SYSTEM_RAPIDJSON "Use system RapidJSON instead of the git submodule if exists" ON)
1011

1112
# Sources for the executable are specified at end of CMakeLists.txt
1213
add_executable(ccls "")
@@ -95,9 +96,16 @@ target_compile_definitions(ccls PRIVATE
9596
### Includes
9697

9798
target_include_directories(ccls PRIVATE src)
98-
target_include_directories(ccls SYSTEM PRIVATE
99-
third_party
100-
third_party/rapidjson/include)
99+
target_include_directories(ccls SYSTEM PRIVATE third_party)
100+
101+
if(USE_SYSTEM_RAPIDJSON)
102+
find_package(RapidJSON QUIET)
103+
endif()
104+
if(RapidJSON_FOUND)
105+
target_include_directories(ccls SYSTEM PRIVATE ${RapidJSON_INCLUDE_DIRS})
106+
else()
107+
target_include_directories(ccls SYSTEM PRIVATE third_party/rapidjson/include)
108+
endif()
101109

102110
### Install
103111

0 commit comments

Comments
 (0)