ycmd
ycmd copied to clipboard
Cmake refactor
Just some small refactoring:
- Use add_compile_definitions instead of add_definitions
- Shorten the code for checking c++17
- Use FetchContent_MakeAvailable to make code simpler/shorter.
Codecov Report
Merging #1574 (8b7e932) into master (e1e9e09) will decrease coverage by
0.07%
. The diff coverage isn/a
.
:exclamation: Current head 8b7e932 differs from pull request most recent head 2cf01e3. Consider uploading reports for the commit 2cf01e3 to get more accurate results
@@ Coverage Diff @@
## master #1574 +/- ##
==========================================
- Coverage 96.32% 96.25% -0.08%
==========================================
Files 90 90
Lines 7841 7906 +65
Branches 164 164
==========================================
+ Hits 7553 7610 +57
- Misses 235 244 +9
+ Partials 53 52 -1
cpp/CMakeLists.txt, line 153 at r1 (raw file):
Previously, bstaletic (Boris Staletic) wrote…
This loses the compiler version checks. I'd love to be able to do it like this, but...
std::filesystem
arrived late. GCC 7 does have support for C++17, but is lackingstd::filesystem
. Same goes for Clang 6 and MSVC 1910.
Wait, I thaught that was the whole point of the dance try_compile @ cpp/ycm/CMakeLists.txt
with :
# Check if we need to add -lstdc++fs or -lc++fs or nothing
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp "#include <filesystem>\nint main( int argc, char ** argv ) {\n std::filesystem::path p( argv[ 0 ] );\n return p.string().length();\n}" )
try_compile( STD_FS_NO_LIB_NEEDED ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE
CXX_EXTENSIONS ${NEEDS_EXTENSIONS} )
try_compile( STD_FS_NEEDS_STDCXXFS ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE
CXX_EXTENSIONS ${NEEDS_EXTENSIONS}
LINK_LIBRARIES stdc++fs )
try_compile( STD_FS_NEEDS_CXXFS ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/main.cpp
CXX_STANDARD 17
CXX_STANDARD_REQUIRED TRUE
CXX_EXTENSIONS ${NEEDS_EXTENSIONS}
LINK_LIBRARIES c++fs )
file( REMOVE ${CMAKE_CURRENT_BINARY_DIR}/main.cpp )
if( ${STD_FS_NEEDS_STDCXXFS} )
set( STD_FS_LIB stdc++fs )
elseif( ${STD_FS_NEEDS_CXXFS} )
set( STD_FS_LIB c++fs )
elseif( ${STD_FS_NO_LIB_NEEDED} )
set( STD_FS_LIB "" )
else()
message( FATAL_ERROR "Unknown compiler - C++17 filesystem library missing" )
endif()
@MergifyIO rebase
rebase
✅ Branch has been successfully rebased
@mergifyio rebase
rebase
✅ Branch has been successfully rebased
Seems abandoned, and I'm not sure that the risk of this warrants the benefit we get from it.