diff --git a/ports/butteraugli/CMakeLists.txt b/ports/butteraugli/CMakeLists.txt index 3bd8a6c37f..0b5373c5a3 100644 --- a/ports/butteraugli/CMakeLists.txt +++ b/ports/butteraugli/CMakeLists.txt @@ -1,29 +1,19 @@ cmake_minimum_required(VERSION 3.8.0) -project(butteraugli) +project(butteraugli CXX) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +add_compile_options(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX) if(MSVC) - add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS -DNOMINMAX) + add_compile_options(/W3 /wd4005 /wd4996 /wd4018) endif() - - find_package(JPEG REQUIRED) find_package(PNG REQUIRED) -include_directories("." ${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIRS}) - -if(BUILD_SHARED_LIBS) - set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) -endif() - +include_directories(".") add_library(butteraugli_lib butteraugli/butteraugli.cc) -add_executable(butteraugli butteraugli/butteraugli_main.cc) - -target_link_libraries(butteraugli butteraugli_lib ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) - - install( TARGETS butteraugli_lib RUNTIME DESTINATION bin @@ -32,6 +22,10 @@ install( ) if(NOT DISABLE_INSTALL_TOOLS) + add_executable(butteraugli butteraugli/butteraugli_main.cc) + target_include_directories(butteraugli PRIVATE ${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIRS}) + target_link_libraries(butteraugli PRIVATE butteraugli_lib ${JPEG_LIBRARIES} ${PNG_LIBRARIES}) + install ( TARGETS butteraugli RUNTIME DESTINATION tools/butteraugli diff --git a/ports/libjpeg-turbo/portfile.cmake b/ports/libjpeg-turbo/portfile.cmake index d1138dbbf5..a5d09fda26 100644 --- a/ports/libjpeg-turbo/portfile.cmake +++ b/ports/libjpeg-turbo/portfile.cmake @@ -16,12 +16,12 @@ vcpkg_find_acquire_program(NASM) get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) set(ENV{PATH} "$ENV{PATH};${NASM_EXE_PATH}") -if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - set(BUILD_STATIC OFF) - set(NOT_BUILD_STATIC ON) +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + set(ENABLE_STATIC OFF) + set(ENABLE_SHARED ON) else() - set(BUILD_STATIC ON) - set(NOT_BUILD_STATIC OFF) + set(ENABLE_STATIC ON) + set(ENABLE_SHARED OFF) endif() if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") @@ -32,9 +32,8 @@ vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA OPTIONS - -DENABLE_STATIC=${BUILD_STATIC} - -DENABLE_SHARED=${NOT_BUILD_STATIC} - -DWITH_CRT_DLL=ON + -DENABLE_STATIC=${ENABLE_STATIC} + -DENABLE_SHARED=${ENABLE_SHARED} -DENABLE_EXECUTABLES=OFF -DINSTALL_DOCS=OFF ${LIBJPEGTURBO_SIMD} diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index d8c7ee6b8e..19fc99af7a 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -1,156 +1,175 @@ # Mark variables as used so cmake doesn't complain about them -set(CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE}) -if(NOT VCPKG_TOOLCHAIN) - if(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") - set(_VCPKG_TARGET_TRIPLET_ARCH x86) - elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") - set(_VCPKG_TARGET_TRIPLET_ARCH x64) - elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") - set(_VCPKG_TARGET_TRIPLET_ARCH arm) - else() - if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$") - set(_VCPKG_TARGET_TRIPLET_ARCH x64) - elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$") - set(_VCPKG_TARGET_TRIPLET_ARCH arm) - elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$") - set(_VCPKG_TARGET_TRIPLET_ARCH x86) - elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 Win64$") - set(_VCPKG_TARGET_TRIPLET_ARCH x64) - elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 ARM") - set(_VCPKG_TARGET_TRIPLET_ARCH arm) - elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017") - set(_VCPKG_TARGET_TRIPLET_ARCH x86) - else() - find_program(_VCPKG_CL cl) - if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$") - set(_VCPKG_TARGET_TRIPLET_ARCH x64) - elseif(_VCPKG_CL MATCHES "arm/cl.exe$") - set(_VCPKG_TARGET_TRIPLET_ARCH arm) - elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$") - set(_VCPKG_TARGET_TRIPLET_ARCH x86) - else() - message(FATAL_ERROR "Unable to determine target architecture.") - endif() - endif() - endif() +mark_as_advanced(CMAKE_TOOLCHAIN_FILE) - if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone") - set(_VCPKG_TARGET_TRIPLET_PLAT uwp) - else() - set(_VCPKG_TARGET_TRIPLET_PLAT windows) - endif() - - set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)") - set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) - - #Detect .vcpkg-root to figure VCPKG_ROOT_DIR - SET(_VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR}) - while(IS_DIRECTORY ${_VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${_VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root") - get_filename_component(_VCPKG_ROOT_DIR_TEMP ${_VCPKG_ROOT_DIR_CANDIDATE} DIRECTORY) - if (_VCPKG_ROOT_DIR_TEMP STREQUAL _VCPKG_ROOT_DIR_CANDIDATE) # If unchanged, we have reached the root of the drive - message(FATAL_ERROR "Could not find .vcpkg-root") - else() - SET(_VCPKG_ROOT_DIR_CANDIDATE ${_VCPKG_ROOT_DIR_TEMP}) - endif() - endwhile() - set(_VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR_CANDIDATE}) - set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed) - - if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) - list(APPEND CMAKE_PREFIX_PATH - ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug - ) - list(APPEND CMAKE_LIBRARY_PATH - ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link - ) - endif() - list(APPEND CMAKE_PREFIX_PATH - ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} - ) - list(APPEND CMAKE_LIBRARY_PATH - ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link - ) - - set(Boost_COMPILER "-vc140") - - if (NOT DEFINED CMAKE_SYSTEM_VERSION) - include(${_VCPKG_ROOT_DIR}/scripts/cmake/vcpkg_get_windows_sdk.cmake) - # This is used as an implicit parameter for vcpkg_get_windows_sdk - set(VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR}) - vcpkg_get_windows_sdk(WINDOWS_SDK_VERSION) - unset(VCPKG_ROOT_DIR) - set(CMAKE_SYSTEM_VERSION ${WINDOWS_SDK_VERSION}) - endif() - - file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) - set(CMAKE_SYSTEM_IGNORE_PATH - "${_programfiles}/OpenSSL" - "${_programfiles}/OpenSSL-Win32" - "${_programfiles}/OpenSSL-Win64" - "${_programfiles}/OpenSSL-Win32/lib/VC" - "${_programfiles}/OpenSSL-Win64/lib/VC" - "${_programfiles}/OpenSSL-Win32/lib/VC/static" - "${_programfiles}/OpenSSL-Win64/lib/VC/static" - "C:/OpenSSL/" - "C:/OpenSSL-Win32/" - "C:/OpenSSL-Win64/" - "C:/OpenSSL-Win32/lib/VC" - "C:/OpenSSL-Win64/lib/VC" - "C:/OpenSSL-Win32/lib/VC/static" - "C:/OpenSSL-Win64/lib/VC/static" - ) - - set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools) - file(GLOB _VCPKG_TOOLS_DIRS ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/*) - foreach(_VCPKG_TOOLS_DIR ${_VCPKG_TOOLS_DIRS}) - if(IS_DIRECTORY ${_VCPKG_TOOLS_DIR}) - set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_TOOLS_DIR}) - endif() - endforeach() - - option(VCPKG_APPLOCAL_DEPS "Automatically copy dependencies into the output directory for executables." ON) - function(add_executable name) - _add_executable(${ARGV}) - list(FIND ARGV "IMPORTED" IMPORTED_IDX) - list(FIND ARGV "ALIAS" ALIAS_IDX) - if(IMPORTED_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1) - if(VCPKG_APPLOCAL_DEPS) - add_custom_command(TARGET ${name} POST_BUILD - COMMAND powershell -noprofile -executionpolicy Bypass -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 - -targetBinary $ - -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$:/debug>/bin" - -OutVariable out - ) - endif() - set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props) - set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false) - endif() - endfunction() - - function(add_library name) - _add_library(${ARGV}) - list(FIND ARGV "IMPORTED" IMPORTED_IDX) - list(FIND ARGV "INTERFACE" INTERFACE_IDX) - list(FIND ARGV "ALIAS" ALIAS_IDX) - if(IMPORTED_IDX EQUAL -1 AND INTERFACE_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1) - set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props) - set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false) - endif() - endfunction() - - macro(find_package name) - if(name STREQUAL "Boost") - unset(Boost_USE_STATIC_LIBS) - endif() - _find_package(${ARGV}) - endmacro() - - set(VCPKG_TOOLCHAIN ON) +if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE) + include("${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") endif() -set(_UNUSED ${CMAKE_TOOLCHAIN_FILE}) +if(VCPKG_TOOLCHAIN) + return() +endif() + +get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE ) +if( _CMAKE_IN_TRY_COMPILE ) + include( "${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg.config.cmake" OPTIONAL ) +endif() + +if(VCPKG_TARGET_TRIPLET) +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) +elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) +else() + if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 Win64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017 ARM") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 15 2017") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + else() + find_program(_VCPKG_CL cl) + if(_VCPKG_CL MATCHES "amd64/cl.exe$" OR _VCPKG_CL MATCHES "x64/cl.exe$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(_VCPKG_CL MATCHES "arm/cl.exe$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + elseif(_VCPKG_CL MATCHES "bin/cl.exe$" OR _VCPKG_CL MATCHES "x86/cl.exe$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + else() + message(FATAL_ERROR "Unable to determine target architecture.") + endif() + endif() +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone") + set(_VCPKG_TARGET_TRIPLET_PLAT uwp) +else() + set(_VCPKG_TARGET_TRIPLET_PLAT windows) +endif() + +set(VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT} CACHE STRING "Vcpkg target triplet (ex. x86-windows)") +set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) + +# Detect .vcpkg-root to figure VCPKG_ROOT_DIR +set(_VCPKG_ROOT_DIR_CANDIDATE ${CMAKE_CURRENT_LIST_DIR}) +while(IS_DIRECTORY ${_VCPKG_ROOT_DIR_CANDIDATE} AND NOT EXISTS "${_VCPKG_ROOT_DIR_CANDIDATE}/.vcpkg-root") + get_filename_component(_VCPKG_ROOT_DIR_TEMP ${_VCPKG_ROOT_DIR_CANDIDATE} DIRECTORY) + if (_VCPKG_ROOT_DIR_TEMP STREQUAL _VCPKG_ROOT_DIR_CANDIDATE) # If unchanged, we have reached the root of the drive + message(FATAL_ERROR "Could not find .vcpkg-root") + else() + SET(_VCPKG_ROOT_DIR_CANDIDATE ${_VCPKG_ROOT_DIR_TEMP}) + endif() +endwhile() +set(_VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR_CANDIDATE}) +set(_VCPKG_INSTALLED_DIR ${_VCPKG_ROOT_DIR}/installed) + +if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) + list(APPEND CMAKE_PREFIX_PATH + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug + ) + list(APPEND CMAKE_LIBRARY_PATH + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib/manual-link + ) +endif() +list(APPEND CMAKE_PREFIX_PATH + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET} +) +list(APPEND CMAKE_LIBRARY_PATH + ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/manual-link +) + +set(Boost_COMPILER "-vc140") + +if (NOT DEFINED CMAKE_SYSTEM_VERSION) + include(${_VCPKG_ROOT_DIR}/scripts/cmake/vcpkg_get_windows_sdk.cmake) + # This is used as an implicit parameter for vcpkg_get_windows_sdk + set(VCPKG_ROOT_DIR ${_VCPKG_ROOT_DIR}) + vcpkg_get_windows_sdk(WINDOWS_SDK_VERSION) + unset(VCPKG_ROOT_DIR) + set(CMAKE_SYSTEM_VERSION ${WINDOWS_SDK_VERSION} CACHE STRING "Windows SDK version") +endif() + +file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) +set(CMAKE_SYSTEM_IGNORE_PATH + "${_programfiles}/OpenSSL" + "${_programfiles}/OpenSSL-Win32" + "${_programfiles}/OpenSSL-Win64" + "${_programfiles}/OpenSSL-Win32/lib/VC" + "${_programfiles}/OpenSSL-Win64/lib/VC" + "${_programfiles}/OpenSSL-Win32/lib/VC/static" + "${_programfiles}/OpenSSL-Win64/lib/VC/static" + "C:/OpenSSL/" + "C:/OpenSSL-Win32/" + "C:/OpenSSL-Win64/" + "C:/OpenSSL-Win32/lib/VC" + "C:/OpenSSL-Win64/lib/VC" + "C:/OpenSSL-Win32/lib/VC/static" + "C:/OpenSSL-Win64/lib/VC/static" +) + +set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools) +file(GLOB _VCPKG_TOOLS_DIRS ${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/*) +foreach(_VCPKG_TOOLS_DIR ${_VCPKG_TOOLS_DIRS}) + if(IS_DIRECTORY ${_VCPKG_TOOLS_DIR}) + set(CMAKE_PROGRAM_PATH ${CMAKE_PROGRAM_PATH} ${_VCPKG_TOOLS_DIR}) + endif() +endforeach() + +option(VCPKG_APPLOCAL_DEPS "Automatically copy dependencies into the output directory for executables." ON) +function(add_executable name) + _add_executable(${ARGV}) + list(FIND ARGV "IMPORTED" IMPORTED_IDX) + list(FIND ARGV "ALIAS" ALIAS_IDX) + if(IMPORTED_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1) + if(VCPKG_APPLOCAL_DEPS) + add_custom_command(TARGET ${name} POST_BUILD + COMMAND powershell -noprofile -executionpolicy Bypass -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 + -targetBinary $ + -installedDir "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}$<$:/debug>/bin" + -OutVariable out + ) + endif() + set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props) + set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false) + endif() +endfunction() + +function(add_library name) + _add_library(${ARGV}) + list(FIND ARGV "IMPORTED" IMPORTED_IDX) + list(FIND ARGV "INTERFACE" INTERFACE_IDX) + list(FIND ARGV "ALIAS" ALIAS_IDX) + if(IMPORTED_IDX EQUAL -1 AND INTERFACE_IDX EQUAL -1 AND ALIAS_IDX EQUAL -1) + set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props) + set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false) + endif() +endfunction() + +macro(find_package name) + if(name STREQUAL "Boost") + unset(Boost_USE_STATIC_LIBS) + endif() + _find_package(${ARGV}) +endmacro() + +set(VCPKG_TOOLCHAIN ON) set(_UNUSED ${CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION}) set(_UNUSED ${CMAKE_EXPORT_NO_PACKAGE_REGISTRY}) set(_UNUSED ${CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY}) set(_UNUSED ${CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY}) set(_UNUSED ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP}) + +if(NOT _CMAKE_IN_TRY_COMPILE) + file(TO_CMAKE_PATH "${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}" _chainload_file) + file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/vcpkg.config.cmake" + "set(VCPKG_TARGET_TRIPLET \"${VCPKG_TARGET_TRIPLET}\" CACHE STRING \"\")\n" + "set(VCPKG_APPLOCAL_DEPS \"${VCPKG_APPLOCAL_DEPS}\" CACHE STRING \"\")\n" + "set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE \"${_chainload_file}\" CACHE STRING \"\")\n") +endif() \ No newline at end of file diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake index bfb6a19fd5..b979245aa9 100644 --- a/scripts/cmake/vcpkg_configure_cmake.cmake +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -61,37 +61,39 @@ function(vcpkg_configure_cmake) set(GENERATOR ${_csc_GENERATOR}) elseif(_csc_PREFER_NINJA AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND NOT _csc_HOST_ARCHITECTURE STREQUAL "x86") set(GENERATOR "Ninja") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 Win64") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 ARM") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 Win64") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v140") set(GENERATOR "Visual Studio 14 2015 ARM") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017 Win64") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH STREQUAL "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017 ARM") - elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND TRIPLET_SYSTEM_ARCH STREQUAL "arm64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017") set(ARCH "ARM64") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x86" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017") - elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "x64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017 Win64") - elseif(TRIPLET_SYSTEM_ARCH STREQUAL "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017 ARM") - elseif(TRIPLET_SYSTEM_ARCH STREQUAL "arm64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") + elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64" AND VCPKG_PLATFORM_TOOLSET MATCHES "v141") set(GENERATOR "Visual Studio 15 2017") set(ARCH "ARM64") + else() + message(FATAL_ERROR "Unable to determine appropriate generator for: ${VCPKG_CMAKE_SYSTEM_NAME}-${VCPKG_TARGET_ARCHITECTURE}-${VCPKG_PLATFORM_TOOLSET}") endif() # If we use Ninja, make sure it's on PATH @@ -104,15 +106,18 @@ function(vcpkg_configure_cmake) file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) if(DEFINED VCPKG_CMAKE_SYSTEM_NAME) - list(APPEND _csc_OPTIONS -DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}) + list(APPEND _csc_OPTIONS "-DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}") endif() if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION) - list(APPEND _csc_OPTIONS -DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}) + list(APPEND _csc_OPTIONS "-DCMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}") endif() - if(DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + + if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") list(APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=ON) - elseif(DEFINED VCPKG_LIBRARY_LINKAGE AND VCPKG_LIBRARY_LINKAGE STREQUAL static) + elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static") list(APPEND _csc_OPTIONS -DBUILD_SHARED_LIBS=OFF) + else() + message(FATAL_ERROR "Invalid setting for VCPKG_LIBRARY_LINKAGE: \"${VCPKG_LIBRARY_LINKAGE}\". It must be \"static\" or \"dynamic\"") endif() if((NOT DEFINED VCPKG_CXX_FLAGS_DEBUG AND NOT DEFINED VCPKG_C_FLAGS_DEBUG) OR @@ -131,10 +136,45 @@ function(vcpkg_configure_cmake) message(FATAL_ERROR "You must set both the VCPKG_CXX_FLAGS and VCPKG_C_FLAGS") endif() + if(VCPKG_CHAINLOAD_TOOLCHAIN_FILE) + list(APPEND _csc_OPTIONS "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}") + else() + set(VCPKG_CXX_FLAGS " /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP ${VCPKG_CXX_FLAGS}") + set(VCPKG_C_FLAGS " /DWIN32 /D_WINDOWS /W3 /utf-8 /MP ${VCPKG_C_FLAGS}") + if(VCPKG_CRT_LINKAGE STREQUAL "dynamic") + list(APPEND _csc_OPTIONS_DEBUG + "-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" + "-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" + ) + list(APPEND _csc_OPTIONS_RELEASE + "-DCMAKE_CXX_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}" + "-DCMAKE_C_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}" + ) + elseif(VCPKG_CRT_LINKAGE STREQUAL "static") + list(APPEND _csc_OPTIONS_DEBUG + "-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" + "-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" + ) + list(APPEND _csc_OPTIONS_RELEASE + "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}" + "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}" + ) + else() + message(FATAL_ERROR "Invalid setting for VCPKG_CRT_LINKAGE: \"${VCPKG_CRT_LINKAGE}\". It must be \"static\" or \"dynamic\"") + endif() + + list(APPEND _csc_OPTIONS_RELEASE + "-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}" + "-DCMAKE_EXE_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}" + ) + list(APPEND _csc_OPTIONS + "-DCMAKE_CXX_FLAGS=${VCPKG_CXX_FLAGS}" + "-DCMAKE_C_FLAGS=${VCPKG_C_FLAGS}" + ) + endif() + list(APPEND _csc_OPTIONS "-DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET}" - "-DCMAKE_CXX_FLAGS= /DWIN32 /D_WINDOWS /W3 /utf-8 /GR /EHsc /MP ${VCPKG_CXX_FLAGS}" - "-DCMAKE_C_FLAGS= /DWIN32 /D_WINDOWS /W3 /utf-8 /MP ${VCPKG_C_FLAGS}" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" @@ -151,32 +191,6 @@ function(vcpkg_configure_cmake) ) endif() - if(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL dynamic) - list(APPEND _csc_OPTIONS_DEBUG - "-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" - "-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MDd /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" - ) - list(APPEND _csc_OPTIONS_RELEASE - "-DCMAKE_CXX_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}" - "-DCMAKE_C_FLAGS_RELEASE=/MD /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}" - ) - - elseif(DEFINED VCPKG_CRT_LINKAGE AND VCPKG_CRT_LINKAGE STREQUAL static) - list(APPEND _csc_OPTIONS_DEBUG - "-DCMAKE_CXX_FLAGS_DEBUG=/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" - "-DCMAKE_C_FLAGS_DEBUG=/D_DEBUG /MTd /Z7 /Ob0 /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" - ) - list(APPEND _csc_OPTIONS_RELEASE - "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_CXX_FLAGS_RELEASE}" - "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Oi /Gy /DNDEBUG /Z7 ${VCPKG_C_FLAGS_RELEASE}" - ) - endif() - - list(APPEND _csc_OPTIONS_RELEASE - "-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}" - "-DCMAKE_EXE_LINKER_FLAGS_RELEASE=/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS}" - ) - message(STATUS "Configuring ${TARGET_TRIPLET}-rel") file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) vcpkg_execute_required_process(