mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-25 17:11:59 +00:00
cmake: make FreeBSD 11,12 build
This commit is contained in:
parent
a385bffcbd
commit
b349983e13
@ -85,11 +85,12 @@ if(NOT SYSTEM_CLANG)
|
|||||||
|
|
||||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang AND CLANG_USE_BUNDLED_LIBC++)
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang AND CLANG_USE_BUNDLED_LIBC++)
|
||||||
message(STATUS "Using bundled libc++")
|
message(STATUS "Using bundled libc++")
|
||||||
target_compile_options(ccls PRIVATE -stdlib=libc++)
|
target_compile_options(ccls PRIVATE -nostdinc++ -cxx-isystem ${CLANG_ROOT}/include/c++/v1)
|
||||||
target_include_directories(ccls PRIVATE ${CLANG_ROOT}/include/c++/v1)
|
target_link_libraries(ccls PRIVATE -stdlib=libc++ -L${CLANG_ROOT}/lib -lc++experimental)
|
||||||
target_link_libraries(ccls PRIVATE ${CLANG_ROOT}/lib/libc++.a
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
${CLANG_ROOT}/lib/libc++abi.a
|
# FreeBSD uses system libcxxrt.a and does not need libc++abi.
|
||||||
${CLANG_ROOT}/lib/libc++experimental.a)
|
target_link_libraries(ccls PRIVATE c++abi)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
@ -107,15 +108,13 @@ set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(ccls PRIVATE Threads::Threads)
|
target_link_libraries(ccls PRIVATE Threads::Threads)
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
|
||||||
target_link_libraries(ccls PRIVATE -lstdc++fs)
|
|
||||||
elseif(MSVC)
|
|
||||||
else()
|
|
||||||
# e.g. Darwin, FreeBSD
|
|
||||||
target_link_libraries(ccls PRIVATE -lc++experimental)
|
target_link_libraries(ccls PRIVATE -lc++experimental)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
|
if(NOT CLANG_USE_BUNDLED_LIBC++)
|
||||||
|
target_link_libraries(ccls PRIVATE -lstdc++fs)
|
||||||
|
endif()
|
||||||
# loguru calls dladdr
|
# loguru calls dladdr
|
||||||
target_link_libraries(ccls PRIVATE ${CMAKE_DL_LIBS})
|
target_link_libraries(ccls PRIVATE ${CMAKE_DL_LIBS})
|
||||||
|
|
||||||
@ -125,6 +124,9 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
|
|||||||
# src/platform_posix.cc uses libthr
|
# src/platform_posix.cc uses libthr
|
||||||
find_package(Backtrace REQUIRED)
|
find_package(Backtrace REQUIRED)
|
||||||
target_link_libraries(ccls PRIVATE ${Backtrace_LIBRARIES} kvm thr)
|
target_link_libraries(ccls PRIVATE ${Backtrace_LIBRARIES} kvm thr)
|
||||||
|
if(SYSTEM_CLANG)
|
||||||
|
target_link_libraries(ccls PRIVATE c++experimental)
|
||||||
|
endif()
|
||||||
|
|
||||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
|
elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
|
||||||
# sparsepp/spp_memory.h uses LibPsapi
|
# sparsepp/spp_memory.h uses LibPsapi
|
||||||
|
@ -121,7 +121,7 @@ int FuzzyMatcher::Match(std::string_view text) {
|
|||||||
pat[i] == text[j]))
|
pat[i] == text[j]))
|
||||||
? std::max(pre[j][0] + MatchScore(i, j, false),
|
? std::max(pre[j][0] + MatchScore(i, j, false),
|
||||||
pre[j][1] + MatchScore(i, j, true))
|
pre[j][1] + MatchScore(i, j, true))
|
||||||
: cur[j + 1][1] = kMinScore * 2;
|
: kMinScore * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#define GUARDED_BY(x) __attribute__((guarded_by(x)))
|
#define GUARDED_BY(x) __attribute__((guarded_by(x)))
|
||||||
|
#else
|
||||||
|
#define GUARDED_BY(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO GCC
|
// TODO GCC
|
||||||
|
@ -69,7 +69,7 @@ std::vector<std::string> kBlacklist = {
|
|||||||
// Arguments which are followed by a potentially relative path. We need to make
|
// Arguments which are followed by a potentially relative path. We need to make
|
||||||
// all relative paths absolute, otherwise libclang will not resolve them.
|
// all relative paths absolute, otherwise libclang will not resolve them.
|
||||||
std::vector<std::string> kPathArgs = {
|
std::vector<std::string> kPathArgs = {
|
||||||
"-I", "-iquote", "-isystem", "--sysroot=",
|
"-I", "-iquote", "-cxx-isystem", "-isystem", "--sysroot=",
|
||||||
"-isysroot", "-gcc-toolchain", "-include-pch", "-iframework",
|
"-isysroot", "-gcc-toolchain", "-include-pch", "-iframework",
|
||||||
"-F", "-imacros", "-include", "/I",
|
"-F", "-imacros", "-include", "/I",
|
||||||
"-idirafter"};
|
"-idirafter"};
|
||||||
@ -82,7 +82,7 @@ std::vector<std::string> kNormalizePathArgs = {"--sysroot="};
|
|||||||
// Arguments whose path arguments should be injected into include dir lookup
|
// Arguments whose path arguments should be injected into include dir lookup
|
||||||
// for #include completion.
|
// for #include completion.
|
||||||
std::vector<std::string> kQuoteIncludeArgs = {"-iquote", "-I", "/I"};
|
std::vector<std::string> kQuoteIncludeArgs = {"-iquote", "-I", "/I"};
|
||||||
std::vector<std::string> kAngleIncludeArgs = {"-isystem", "-I", "/I"};
|
std::vector<std::string> kAngleIncludeArgs = {"-cxx-isystem", "-isystem", "-I", "/I"};
|
||||||
|
|
||||||
bool ShouldAddToQuoteIncludes(const std::string& arg) {
|
bool ShouldAddToQuoteIncludes(const std::string& arg) {
|
||||||
return StartsWithAny(arg, kQuoteIncludeArgs);
|
return StartsWithAny(arg, kQuoteIncludeArgs);
|
||||||
@ -152,16 +152,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
for (; i < args.size(); ++i) {
|
for (; i < args.size(); ++i) {
|
||||||
std::string arg = args[i];
|
std::string arg = args[i];
|
||||||
|
|
||||||
// If blacklist skip.
|
|
||||||
if (!next_flag_is_path) {
|
|
||||||
if (StartsWithAny(arg, kBlacklistMulti)) {
|
|
||||||
++i;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (StartsWithAny(arg, kBlacklist))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finish processing path for the previous argument, which was a switch.
|
// Finish processing path for the previous argument, which was a switch.
|
||||||
// {"-I", "foo"} style.
|
// {"-I", "foo"} style.
|
||||||
if (next_flag_is_path) {
|
if (next_flag_is_path) {
|
||||||
@ -177,6 +167,12 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
add_next_flag_to_quote_dirs = false;
|
add_next_flag_to_quote_dirs = false;
|
||||||
add_next_flag_to_angle_dirs = false;
|
add_next_flag_to_angle_dirs = false;
|
||||||
} else {
|
} else {
|
||||||
|
// If blacklist skip.
|
||||||
|
if (StartsWithAny(arg, kBlacklistMulti)) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check to see if arg is a path and needs to be updated.
|
// Check to see if arg is a path and needs to be updated.
|
||||||
for (const std::string& flag_type : kPathArgs) {
|
for (const std::string& flag_type : kPathArgs) {
|
||||||
// {"-I", "foo"} style.
|
// {"-I", "foo"} style.
|
||||||
@ -184,7 +180,7 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
next_flag_is_path = true;
|
next_flag_is_path = true;
|
||||||
add_next_flag_to_quote_dirs = ShouldAddToQuoteIncludes(arg);
|
add_next_flag_to_quote_dirs = ShouldAddToQuoteIncludes(arg);
|
||||||
add_next_flag_to_angle_dirs = ShouldAddToAngleIncludes(arg);
|
add_next_flag_to_angle_dirs = ShouldAddToAngleIncludes(arg);
|
||||||
break;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// {"-Ifoo"} style.
|
// {"-Ifoo"} style.
|
||||||
@ -198,10 +194,13 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
config->quote_dirs.insert(path);
|
config->quote_dirs.insert(path);
|
||||||
if (ShouldAddToAngleIncludes(flag_type))
|
if (ShouldAddToAngleIncludes(flag_type))
|
||||||
config->angle_dirs.insert(path);
|
config->angle_dirs.insert(path);
|
||||||
break;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (StartsWithAny(arg, kBlacklist))
|
||||||
|
continue;
|
||||||
|
|
||||||
// This is most likely the file path we will be passing to clang. The
|
// This is most likely the file path we will be passing to clang. The
|
||||||
// path needs to be absolute, otherwise clang_codeCompleteAt is extremely
|
// path needs to be absolute, otherwise clang_codeCompleteAt is extremely
|
||||||
// slow. See
|
// slow. See
|
||||||
@ -215,6 +214,7 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
result.args.push_back(arg);
|
result.args.push_back(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,12 @@
|
|||||||
#include "serializers/json.h"
|
#include "serializers/json.h"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <optional>
|
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iterator>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
Loading…
Reference in New Issue
Block a user