ycmd icon indicating copy to clipboard operation
ycmd copied to clipboard

Cmake refactor

Open Borwe opened this issue 3 years ago • 2 comments

Just some small refactoring:

  1. Use add_compile_definitions instead of add_definitions
  2. Shorten the code for checking c++17
  3. Use FetchContent_MakeAvailable to make code simpler/shorter.

This change is Reviewable

Borwe avatar Jun 13 '21 20:06 Borwe

Codecov Report

Merging #1574 (8b7e932) into master (e1e9e09) will decrease coverage by 0.07%. The diff coverage is n/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     

codecov[bot] avatar Jun 13 '21 20:06 codecov[bot]


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 lacking std::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()

Borwe avatar Jun 14 '21 10:06 Borwe

@MergifyIO rebase

puremourning avatar Aug 16 '22 20:08 puremourning

rebase

✅ Branch has been successfully rebased

mergify[bot] avatar Aug 16 '22 20:08 mergify[bot]

@mergifyio rebase

puremourning avatar Sep 29 '22 19:09 puremourning

rebase

✅ Branch has been successfully rebased

mergify[bot] avatar Sep 29 '22 19:09 mergify[bot]

Seems abandoned, and I'm not sure that the risk of this warrants the benefit we get from it.

puremourning avatar Sep 29 '22 19:09 puremourning