Skip to content

Commit

Permalink
cmake: for -DSYSTEM_CLANG=off, 6.0.0 -> 6.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Jul 30, 2018
1 parent 0bb311a commit b4aa070
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 99 deletions.
149 changes: 75 additions & 74 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
include(DefaultCMakeBuildType)

# Required Clang version
set(CLANG_VERSION 6.0.0 CACHE STRING "Clang version")
set(CLANG_DOWNLOAD_LOCATION ${CMAKE_BINARY_DIR}
CACHE STRING "Downloaded Clang location")
option(SYSTEM_CLANG "Use system installation of Clang instead of \
Expand Down Expand Up @@ -42,18 +41,20 @@ target_compile_options(ccls PRIVATE -fno-rtti)
if(MSVC)
# Common MSVC/Clang(Windows) options
target_compile_options(ccls PRIVATE
/nologo
/EHsc
/W3 # roughly -Wall
/wd4996 # disable loguru unsafe warnings
/wd4722 # ignores warning C4722
# (destructor never returns) in loguru
/wd4267 # ignores warning C4267
# (conversion from 'size_t' to 'type'),
# roughly -Wno-sign-compare
/wd4800
$<$<CONFIG:Debug>:/FS>
)
/nologo
/EHsc
/D_CRT_SECURE_NO_WARNINGS # don't try to use MSVC std replacements
/W3 # roughly -Wall
/wd4996 # disable loguru unsafe warnings
/wd4722 # ignores warning C4722
# (destructor never returns) in loguru
/wd4267 # ignores warning C4267
# (conversion from 'size_t' to 'type'),
# roughly -Wno-sign-compare
/wd4800
/wd4068 # Disable unknown pragma warning
$<$<CONFIG:Debug>:/FS>
)
else()
# Common GCC/Clang(Linux) options
target_compile_options(ccls PRIVATE
Expand Down Expand Up @@ -83,7 +84,7 @@ if(NOT SYSTEM_CLANG)
message(STATUS "Using downloaded Clang")

include(DownloadAndExtractClang)
download_and_extract_clang(${CLANG_VERSION} ${CLANG_DOWNLOAD_LOCATION})
download_and_extract_clang(${CLANG_DOWNLOAD_LOCATION})
# Used by FindClang
set(CLANG_ROOT ${DOWNLOADED_CLANG_DIR})

Expand All @@ -105,7 +106,7 @@ endif()
### Libraries

# See cmake/FindClang.cmake
find_package(Clang ${CLANG_VERSION} REQUIRED)
find_package(Clang 6.0.0)
target_link_libraries(ccls PRIVATE Clang::Clang)

# Enable threading support
Expand Down Expand Up @@ -136,7 +137,6 @@ target_include_directories(ccls SYSTEM PRIVATE

install(TARGETS ccls RUNTIME DESTINATION bin)

# TODO: install libclang.dll on Windows as well
if(NOT SYSTEM_CLANG AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL Windows)

if(${CMAKE_SYSTEM_NAME} MATCHES Linux|FreeBSD)
Expand Down Expand Up @@ -174,63 +174,64 @@ file(GLOB SOURCES src/*.cc src/*.h src/serializers/*.cc src/serializers/*.h
target_sources(ccls PRIVATE third_party/siphash.cc)

target_sources(ccls PRIVATE
src/clang_complete.cc
src/clang_tu.cc
src/clang_utils.cc
src/config.cc
src/file_consumer.cc
src/filesystem.cc
src/fuzzy_match.cc
src/main.cc
src/include_complete.cc
src/indexer.cc
src/method.cc
src/language.cc
src/log.cc
src/lsp.cc
src/match.cc
src/message_handler.cc
src/pipeline.cc
src/platform_posix.cc
src/platform_win.cc
src/position.cc
src/project.cc
src/query_utils.cc
src/query.cc
src/serializer.cc
src/test.cc
src/utils.cc
src/working_files.cc)
src/clang_complete.cc
src/clang_tu.cc
src/clang_utils.cc
src/config.cc
src/file_consumer.cc
src/filesystem.cc
src/fuzzy_match.cc
src/main.cc
src/include_complete.cc
src/indexer.cc
src/method.cc
src/language.cc
src/log.cc
src/lsp.cc
src/match.cc
src/message_handler.cc
src/pipeline.cc
src/platform_posix.cc
src/platform_win.cc
src/position.cc
src/project.cc
src/query_utils.cc
src/query.cc
src/serializer.cc
src/test.cc
src/utils.cc
src/working_files.cc
)

target_sources(ccls PRIVATE
src/messages/ccls_base.cc
src/messages/ccls_callHierarchy.cc
src/messages/ccls_callers.cc
src/messages/ccls_fileInfo.cc
src/messages/ccls_freshenIndex.cc
src/messages/ccls_inheritanceHierarchy.cc
src/messages/ccls_memberHierarchy.cc
src/messages/ccls_vars.cc
src/messages/exit.cc
src/messages/initialize.cc
src/messages/shutdown.cc
src/messages/textDocument_codeAction.cc
src/messages/textDocument_codeLens.cc
src/messages/textDocument_completion.cc
src/messages/textDocument_definition.cc
src/messages/textDocument_didChange.cc
src/messages/textDocument_didClose.cc
src/messages/textDocument_didOpen.cc
src/messages/textDocument_didSave.cc
src/messages/textDocument_documentHighlight.cc
src/messages/textDocument_documentSymbol.cc
src/messages/textDocument_hover.cc
src/messages/textDocument_implementation.cc
src/messages/textDocument_references.cc
src/messages/textDocument_rename.cc
src/messages/textDocument_signatureHelp.cc
src/messages/textDocument_typeDefinition.cc
src/messages/workspace_didChangeConfiguration.cc
src/messages/workspace_didChangeWatchedFiles.cc
src/messages/workspace_symbol.cc
)
src/messages/ccls_base.cc
src/messages/ccls_callHierarchy.cc
src/messages/ccls_callers.cc
src/messages/ccls_fileInfo.cc
src/messages/ccls_freshenIndex.cc
src/messages/ccls_inheritanceHierarchy.cc
src/messages/ccls_memberHierarchy.cc
src/messages/ccls_vars.cc
src/messages/exit.cc
src/messages/initialize.cc
src/messages/shutdown.cc
src/messages/textDocument_codeAction.cc
src/messages/textDocument_codeLens.cc
src/messages/textDocument_completion.cc
src/messages/textDocument_definition.cc
src/messages/textDocument_didChange.cc
src/messages/textDocument_didClose.cc
src/messages/textDocument_didOpen.cc
src/messages/textDocument_didSave.cc
src/messages/textDocument_documentHighlight.cc
src/messages/textDocument_documentSymbol.cc
src/messages/textDocument_hover.cc
src/messages/textDocument_implementation.cc
src/messages/textDocument_references.cc
src/messages/textDocument_rename.cc
src/messages/textDocument_signatureHelp.cc
src/messages/textDocument_typeDefinition.cc
src/messages/workspace_didChangeConfiguration.cc
src/messages/workspace_didChangeWatchedFiles.cc
src/messages/workspace_symbol.cc
)
1 change: 0 additions & 1 deletion clang_archive_hashes/LLVM-6.0.0-win64.exe.SHA256

This file was deleted.

1 change: 1 addition & 0 deletions clang_archive_hashes/LLVM-6.0.1-win64.exe.SHA256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
780276221635aa08120187ffc2c72ff7873dee37f5609455ee7bba6fcdd91d79

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6d1f67c9e7c3481106d5c9bfcb8a75e3876eb17a446a14c59c13cafd000c21d2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7ea204ecd78c39154d72dfc0d4a79f7cce1b2264da2551bb2eef10e266d54d91
45 changes: 26 additions & 19 deletions cmake/DownloadAndExtractClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
# Returns the extracted Clang archive directory in DOWNLOADED_CLANG_DIR
#
# Downloads 7-Zip to extract Clang if it isn't available in the PATH
function(download_and_extract_clang CLANG_VERSION CLANG_DOWNLOAD_LOCATION)
function(download_and_extract_clang CLANG_DOWNLOAD_LOCATION)

set(CLANG_VERSION 6.0.1)
set(CLANG_ARCHIVE_EXT .tar.xz)

if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)

# Default to Ubuntu 16.04
set(CLANG_ARCHIVE_NAME
clang+llvm-${CLANG_VERSION}-x86_64-linux-gnu-ubuntu-16.04)

elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)

# No Darwin binaries were released for LLVM 6.0.1
set(CLANG_VERSION 6.0.0)
set(CLANG_ARCHIVE_NAME clang+llvm-${CLANG_VERSION}-x86_64-apple-darwin)

elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
Expand All @@ -24,11 +28,7 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)

elseif(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)

if(${CLANG_VERSION} STREQUAL 6.0.0)
set(CLANG_ARCHIVE_NAME clang+llvm-${CLANG_VERSION}-amd64-unknown-freebsd-10)
else()
set(CLANG_ARCHIVE_NAME clang+llvm-${CLANG_VERSION}-amd64-unknown-freebsd10)
endif()
set(CLANG_ARCHIVE_NAME clang+llvm-${CLANG_VERSION}-amd64-unknown-freebsd10)

endif()

Expand Down Expand Up @@ -92,31 +92,38 @@ if(${CLANG_ARCHIVE_EXT} STREQUAL .exe)

include(DownloadAndExtract7zip)
download_and_extract_7zip(${CLANG_DOWNLOAD_LOCATION})
find_program(7ZIP_EXECUTABLE 7z NO_DEFAULT_PATH
PATHS ${DOWNLOADED_7ZIP_DIR})
find_program(7ZIP_EXECUTABLE
NAMES 7z
NO_DEFAULT_PATH
PATHS ${DOWNLOADED_7ZIP_DIR}
)
else()
message(STATUS "7-Zip found in PATH")
endif()

message(STATUS "Extracting downloaded Clang with 7-Zip ...")

# Avoid running the Clang installer by extracting the exe with 7-Zip
execute_process(COMMAND ${7ZIP_EXECUTABLE} x
-o${CLANG_ARCHIVE_EXTRACT_DIR}
-xr!$PLUGINSDIR ${CLANG_ARCHIVE_FILE}
WORKING_DIRECTORY ${CLANG_DOWNLOAD_LOCATION}
OUTPUT_QUIET)
execute_process(
COMMAND ${7ZIP_EXECUTABLE} x
-o${CLANG_ARCHIVE_EXTRACT_DIR}
-xr!$PLUGINSDIR ${CLANG_ARCHIVE_FILE}
WORKING_DIRECTORY ${CLANG_DOWNLOAD_LOCATION}
OUTPUT_QUIET
)

elseif(${CLANG_ARCHIVE_EXT} STREQUAL .tar.xz)
message(STATUS "Extracting downloaded Clang with CMake built-in tar ...")

# CMake has builtin support for tar via the -E flag
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xf ${CLANG_ARCHIVE_FILE}
# Specify working directory to allow running cmake from
# everywhere
# (example: cmake -H"$HOME/ccls" -B"$home/ccls/build")
WORKING_DIRECTORY ${CLANG_DOWNLOAD_LOCATION}
OUTPUT_QUIET)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar -xf ${CLANG_ARCHIVE_FILE}
# Specify working directory to allow running cmake from
# everywhere
# (example: cmake -H"$HOME/cquery" -B"$home/cquery/build")
WORKING_DIRECTORY ${CLANG_DOWNLOAD_LOCATION}
OUTPUT_QUIET
)
endif()

set(DOWNLOADED_CLANG_DIR ${CLANG_ARCHIVE_EXTRACT_DIR} PARENT_SCOPE)
Expand Down
6 changes: 4 additions & 2 deletions cmake/FindClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ executable. Output:\n ${_Clang_FIND_RESOURCE_DIR_ERROR}")

# Find Clang version
set(_Clang_VERSION_REGEX "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
execute_process(COMMAND ${Clang_EXECUTABLE} --version
OUTPUT_VARIABLE Clang_VERSION)
execute_process(
COMMAND ${Clang_EXECUTABLE} --version
OUTPUT_VARIABLE Clang_VERSION
)
string(REGEX MATCH ${_Clang_VERSION_REGEX} Clang_VERSION ${Clang_VERSION})
endif()

Expand Down

0 comments on commit b4aa070

Please sign in to comment.