diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index ff65b1db..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "third_party/rapidjson"] - path = third_party/rapidjson - url = https://github.com/Tencent/rapidjson diff --git a/CMakeLists.txt b/CMakeLists.txt index 993376d8..ed6b884f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,14 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.11) project(ccls LANGUAGES CXX) +### Colored output +if(NOT WIN32) + string(ASCII 27 Esc) + set(Green "${Esc}[32m") + set(BoldBlue "${Esc}[1;34m") +endif() + + list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) include(DefaultCMakeBuildType) @@ -92,12 +100,48 @@ endif() target_compile_definitions(ccls PRIVATE DEFAULT_RESOURCE_DIRECTORY=R"\(${Clang_RESOURCE_DIR}\)") + +### use local installed RapidJSON or FETCH from git via cmake +find_package(RapidJSON QUIET) +if(RapidJSON_FOUND) + message("${BoldBlue}\nRapidJSON has been installed by your system before cloning ccls\n\n${ColourReset}") + include_directories(${RapidJSON_INCLUDE_DIRS}) +else() + message("${Green}====> Downloading RapidJSON ---- A fast JSON parser/generator for C++ with both SAX/DOM style API http://rapidjson.org/ +${ColourReset}") + include(FetchContent) + FetchContent_Declare( + rapidjson + GIT_REPOSITORY https://github.com/Tencent/rapidjson + GIT_TAG master + ) + + FetchContent_GetProperties(rapidjson) + if (NOT rapidjson_POPULATED) + FetchContent_Populate(rapidjson) + + message(${rapidjson_SOURCE_DIR}) + message(${rapidjson_BINARY_DIR}) + add_subdirectory(${rapidjson_SOURCE_DIR}) + message("${BoldBlue}\ngit clone RapidJSON successfully!\n\n${ColourReset}") + set(INCLUDE_DIRS ${rapidjson_SOURCE_DIR}/include) + + message("${BoldBlue}\n${rapidjson_SOURCE_DIR}/include ${ColourReset}") + message("${BoldBlue}\n${INCLUDE_DIRS} ${ColourReset}") + target_include_directories(ccls PUBLIC + ${INCLUDE_DIRS} + ) + + endif() + +endif() + + ### Includes target_include_directories(ccls PRIVATE src) target_include_directories(ccls SYSTEM PRIVATE - third_party - third_party/rapidjson/include) + third_party) ### Install diff --git a/third_party/rapidjson b/third_party/rapidjson deleted file mode 160000 index 6a905f93..00000000 --- a/third_party/rapidjson +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a905f9311f82d306da77bd963ec5aa5da07da9c