2017-11-26 07:53:32 +08:00
|
|
|
cmake_minimum_required(VERSION 3.3)
|
2019-04-11 15:32:03 +08:00
|
|
|
|
2018-03-13 20:21:17 +08:00
|
|
|
project(vcpkg C CXX)
|
2017-11-26 07:53:32 +08:00
|
|
|
|
2018-06-12 08:01:13 +08:00
|
|
|
OPTION(DEFINE_DISABLE_METRICS "Option for disabling metrics" OFF)
|
2019-04-11 15:32:03 +08:00
|
|
|
OPTION(VCPKG_ALLOW_APPLE_CLANG "Option for allowing apple clang" OFF)
|
2018-06-09 09:01:35 +08:00
|
|
|
|
2017-12-15 06:31:16 +08:00
|
|
|
if(CMAKE_COMPILER_IS_GNUXX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
2017-11-29 05:06:56 +08:00
|
|
|
set(GCC 1)
|
2018-03-30 06:29:16 +08:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
|
2018-03-31 05:46:22 +08:00
|
|
|
if(NOT VCPKG_ALLOW_APPLE_CLANG)
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Building the vcpkg tool requires support for the C++ Filesystem TS.
|
2019-05-13 19:11:35 +08:00
|
|
|
Apple clang versions 10.01 and below do not have support for it.
|
2018-03-31 05:46:22 +08:00
|
|
|
Please install gcc6 or newer from homebrew (brew install gcc6).
|
2019-04-11 15:32:03 +08:00
|
|
|
If you would like to try anyway, pass --allowAppleClang to bootstrap.sh.")
|
2018-03-30 06:29:16 +08:00
|
|
|
else()
|
|
|
|
set(CLANG 1)
|
|
|
|
endif()
|
2017-11-29 05:06:56 +08:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
|
|
|
|
set(CLANG 1)
|
2018-03-03 03:16:49 +08:00
|
|
|
elseif(MSVC)
|
2019-06-20 02:49:57 +08:00
|
|
|
add_compile_options(/std:c++17 /FC)
|
2017-12-15 06:31:16 +08:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
|
2017-11-29 05:06:56 +08:00
|
|
|
endif()
|
|
|
|
|
2018-03-03 03:16:49 +08:00
|
|
|
if(GCC OR CLANG)
|
|
|
|
add_compile_options(-std=c++1z)
|
2018-04-12 15:47:17 +08:00
|
|
|
if(WERROR)
|
|
|
|
add_compile_options(-Wall -Wno-unknown-pragmas -Werror)
|
|
|
|
endif()
|
2018-03-03 03:16:49 +08:00
|
|
|
endif()
|
|
|
|
|
2017-11-26 07:53:32 +08:00
|
|
|
file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)
|
|
|
|
|
2018-06-12 08:01:13 +08:00
|
|
|
if (DEFINE_DISABLE_METRICS)
|
|
|
|
set(DISABLE_METRICS_VALUE "1")
|
|
|
|
else()
|
|
|
|
set(DISABLE_METRICS_VALUE "0")
|
|
|
|
endif()
|
|
|
|
|
2018-02-20 04:20:16 +08:00
|
|
|
add_executable(vcpkg src/vcpkg.cpp ${VCPKGLIB_SOURCES})
|
2018-06-12 08:01:13 +08:00
|
|
|
target_compile_definitions(vcpkg PRIVATE -DDISABLE_METRICS=${DISABLE_METRICS_VALUE})
|
2018-03-13 20:21:17 +08:00
|
|
|
target_include_directories(vcpkg PRIVATE include)
|
2017-11-29 02:50:33 +08:00
|
|
|
|
2019-03-06 06:52:26 +08:00
|
|
|
if(CLANG)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
check_cxx_source_compiles("#include <iostream>
|
|
|
|
int main() { return __GLIBCXX__; }" USES_LIBSTDCXX)
|
|
|
|
check_cxx_source_compiles("#include <iostream>
|
|
|
|
int main() { return _LIBCPP_VERSION; }" USES_LIBCXX)
|
|
|
|
if ( NOT USES_LIBSTDCXX AND NOT USES_LIBCXX )
|
|
|
|
message(FATAL_ERROR "Can't find which C++ runtime is in use")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(GCC OR (CLANG AND USES_LIBSTDCXX))
|
2018-03-13 20:21:17 +08:00
|
|
|
target_link_libraries(vcpkg PRIVATE stdc++fs)
|
2017-11-29 05:06:56 +08:00
|
|
|
elseif(CLANG)
|
2019-04-16 13:50:09 +08:00
|
|
|
target_link_libraries(vcpkg PRIVATE c++fs)
|
2017-11-29 02:50:33 +08:00
|
|
|
endif()
|
2018-03-13 20:21:17 +08:00
|
|
|
|
2019-04-09 14:26:18 +08:00
|
|
|
if(MSVC)
|
|
|
|
get_target_property(_srcs vcpkg SOURCES)
|
|
|
|
|
|
|
|
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio .*")
|
|
|
|
set_property(SOURCE src/pch.cpp APPEND PROPERTY OBJECT_OUTPUTS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
|
|
|
|
set_property(SOURCE ${_srcs} APPEND PROPERTY OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_source_files_properties(src/pch.cpp PROPERTIES COMPILE_FLAGS "/Ycpch.h")
|
|
|
|
target_sources(vcpkg PRIVATE src/pch.cpp)
|
|
|
|
target_compile_options(vcpkg PRIVATE /Yupch.h /FIpch.h /Zm200)
|
2018-06-27 02:40:44 +08:00
|
|
|
endif()
|
|
|
|
|
2018-03-13 20:21:17 +08:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
target_link_libraries(vcpkg PRIVATE Threads::Threads)
|