Change CMakeLists.txt in toolsrc to allow compiling with llvm toolset (#4572)

* llvm warning pessimistic move

* warning missing override

* warning invalid noreturn. ::TerminateProcess ist not marked as noreturn!

* use more modern cmake features instead of adding c++ standard by hand.

* Normalize line endings

* Fix add_executable()

* Fix target commands

* Clean up CMakeLists.txt
This commit is contained in:
Alexander Neumann 2019-08-14 23:06:00 +02:00 committed by Victor Romero
parent 50253f06a4
commit f9c92910a7
3 changed files with 28 additions and 13 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.14)
project(vcpkg C CXX)
@ -28,11 +28,32 @@ If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
set(CLANG 1)
elseif(MSVC)
add_compile_options(/std:c++17 /FC)
add_compile_options(/FC)
else()
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
if(GCC OR (CLANG AND NOT MSVC))
if(WERROR)
add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
endif()
endif()
if (DEFINE_DISABLE_METRICS)
set(DISABLE_METRICS_VALUE "1")
else()
set(DISABLE_METRICS_VALUE "0")
endif()
file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
target_compile_features(vcpkg PRIVATE cxx_std_17)
target_compile_definitions(vcpkg PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
target_include_directories(vcpkg PRIVATE include)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
@ -52,9 +73,9 @@ if(CLANG)
endif()
if(GCC OR (CLANG AND USES_LIBSTDCXX))
link_libraries(stdc++fs)
elseif(CLANG)
link_libraries(c++fs)
target_link_libraries(vcpkg PRIVATE stdc++fs)
elseif(CLANG AND NOT MSVC)
target_link_libraries(vcpkg PRIVATE c++fs)
endif()
if(GCC OR CLANG)
@ -64,11 +85,6 @@ if(GCC OR CLANG)
endif()
endif()
file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
add_library(vcpkglib OBJECT ${VCPKGLIB_SOURCES})
add_executable(vcpkg src/vcpkg.cpp $<TARGET_OBJECTS:vcpkglib>)
if (BUILD_TESTING)
file(GLOB_RECURSE VCPKGTEST_SOURCES src/vcpkg-test/*.cpp)

View File

@ -27,9 +27,8 @@ namespace vcpkg
#if defined(_WIN32)
::TerminateProcess(::GetCurrentProcess(), exit_code);
#else
std::exit(exit_code);
#endif
std::exit(exit_code);
}
void Checks::unreachable(const LineInfo& line_info)

View File

@ -174,7 +174,7 @@ namespace vcpkg::Install
const std::vector<fs::path> package_file_paths = fs.get_files_recursive(package_dir);
const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash
auto package_files = Util::fmap(package_file_paths, [package_remove_char_count](const fs::path& path) {
return std::move(std::string(path.generic_string(), package_remove_char_count));
return std::move(std::string(path.generic_string(), package_remove_char_count));
});
return SortedVector<std::string>(std::move(package_files));