Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QoL: Buildtype variables for looping over buildtypes #7733

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2b6cf9a
define buildtype variables for easier looping over them
Neumann-A Aug 16, 2019
c19a15c
Merge branch 'master' into build_variables
Neumann-A Aug 19, 2019
23bad7f
Merge branch 'master' into build_variables
Neumann-A Aug 23, 2019
5fcd7b5
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Sep 16, 2019
f8bd0d8
refactored vcpkg_configure_cmake with new variables
Neumann-A Sep 16, 2019
d0d99d9
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Sep 20, 2019
7517be9
add/update documentation
Neumann-A Sep 20, 2019
31dede7
refactored vcpkg_configure_qmake
Neumann-A Sep 20, 2019
eaaa60b
refactored qt-5base configure_qt
Neumann-A Sep 20, 2019
ceabb41
refactored install_qt in qt5-base
Neumann-A Sep 20, 2019
26cc37c
refactor vcpkg_build_cmake
Neumann-A Sep 20, 2019
a69a436
note about the possibility of introducing an option mapping
Neumann-A Sep 20, 2019
fe280ed
refactored vcpkg_install_msbuild
Neumann-A Sep 20, 2019
0802dfa
fix linux regressions
Neumann-A Sep 20, 2019
b906905
bump qt control
Neumann-A Sep 20, 2019
8aed23b
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A May 5, 2020
356013c
use globaly defined variables in qmake configure
Neumann-A May 5, 2020
2d4d915
[fftw3] remove deprecated function for cmake CI test
Neumann-A May 15, 2020
6aa035b
[3fd] remove deprecated function for CI rebuild (msbuild)
Neumann-A May 15, 2020
75b46fd
[qcustomplot] remove deprecated include for CI rerun (qmake)
Neumann-A May 15, 2020
5a2bcb5
[vcpkg/scripts] add missing ) in vcpkg_configure_qmake
Neumann-A May 15, 2020
0c68fd5
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A May 15, 2020
653d75b
[vcpkg/scripts] fix cmake configure
Neumann-A May 15, 2020
cf941ea
ws change to rerun ci
Neumann-A May 15, 2020
d990a14
[fftw3] bump control.
Neumann-A May 15, 2020
5dd65e9
[vcpkg/scripts] small change to vcpkg_fixup_cmake_targets to trigger …
Neumann-A May 15, 2020
b07235c
[vcpkg/scripts/cmake] use same quoting as before.
Neumann-A May 16, 2020
ddbb7a5
[vcpkg/scripts/cmake] change to fixup to trigger full CI rebuild
Neumann-A May 16, 2020
f7bdfc7
[vcpkg/scripts/msbuild] fix "EXES" "AND" error
Neumann-A May 17, 2020
ce00f1d
[vcpkg/scripts/cmake] add missing $ and remove emtpy variable
Neumann-A May 17, 2020
fcd4d97
[vcpkg/scripts/cmake] trigger full rebuild with a change to vcpkg_fix…
Neumann-A May 17, 2020
b5cbf0b
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Jun 9, 2020
88d27f5
Merge remote-tracking branch 'origin/master' into build_variables
BillyONeal Jun 11, 2020
7ca06e3
Merge from master
PhoebeHui Jun 18, 2020
afaf5fb
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Aug 11, 2020
76852fd
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Aug 20, 2020
1f97108
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Sep 3, 2020
01ae106
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Sep 6, 2020
bee1f2c
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Nov 12, 2020
7dc2a69
fix ocilib regression
Neumann-A Nov 13, 2020
a100f23
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Nov 20, 2020
acf52b3
remove any unnecessary changes
Neumann-A Nov 20, 2020
8801434
rename VCPKG_BUILD_LIST to VCPKG_BUILD_TYPES
Neumann-A Nov 20, 2020
42089f6
lowercase buildname.
Neumann-A Nov 25, 2020
783ab6f
Merge remote-tracking branch 'upstream/master' into build_variables
Neumann-A Nov 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ports/3fd/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include(vcpkg_common_functions)

# Check architecture:
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(BUILD_ARCH "Win32")
Expand Down Expand Up @@ -102,4 +100,4 @@ endif()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/3fd RENAME copyright)
file(INSTALL ${SOURCE_PATH}/Acknowledgements.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/3fd)

vcpkg_copy_pdbs()
vcpkg_copy_pdbs()
2 changes: 1 addition & 1 deletion ports/libqglviewer/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ vcpkg_configure_qmake(
vcpkg_install_qmake()

file(INSTALL ${SOURCE_PATH}/QGLViewer DESTINATION ${CURRENT_PACKAGES_DIR}/include FILES_MATCHING PATTERN "*.h")
file(INSTALL ${SOURCE_PATH}/LICENCE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libqglviewer RENAME copyright)
file(INSTALL ${SOURCE_PATH}/LICENCE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libqglviewer RENAME copyright)
4 changes: 1 addition & 3 deletions ports/qcustomplot/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include(vcpkg_common_functions)

set(QCP_VERSION 2.0.1)

vcpkg_download_distfile(ARCHIVE
Expand Down Expand Up @@ -37,4 +35,4 @@ file(INSTALL ${SOURCE_PATH}/qcustomplot.h
vcpkg_copy_pdbs()

# Handle copyright
configure_file(${SOURCE_PATH}/GPL.txt ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
configure_file(${SOURCE_PATH}/GPL.txt ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright COPYONLY)
58 changes: 23 additions & 35 deletions scripts/cmake/vcpkg_build_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,45 +60,33 @@ function(vcpkg_build_cmake)
set(TARGET_PARAM)
endif()

foreach(BUILDTYPE "debug" "release")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL BUILDTYPE)
if(BUILDTYPE STREQUAL "debug")
set(SHORT_BUILDTYPE "dbg")
set(CONFIG "Debug")
else()
set(SHORT_BUILDTYPE "rel")
set(CONFIG "Release")
endif()
foreach(BUILDTYPE ${VCPKG_BUILD_LIST})
set(CONFIG "${VCPKG_BUILD_CMAKE_TYPE_${BUILDTYPE}}")

message(STATUS "Building ${TARGET_TRIPLET}-${SHORT_BUILDTYPE}")
message(STATUS "Building ${VCPKG_BUILD_TRIPLET_${BUILDTYPE}}")

if(_bc_ADD_BIN_TO_PATH)
set(_BACKUP_ENV_PATH "$ENV{PATH}")
if(BUILDTYPE STREQUAL "debug")
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/debug/bin")
else()
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}/bin")
endif()
endif()
if(_bc_ADD_BIN_TO_PATH)
set(_BACKUP_ENV_PATH "$ENV{PATH}")
vcpkg_add_to_path(PREPEND "${CURRENT_INSTALLED_DIR}${VCPKG_PATH_SUFFIX_${BUILDTYPE}}/bin")
endif()

if (_bc_DISABLE_PARALLEL)
vcpkg_execute_build_process(
COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}"
)
else()
vcpkg_execute_build_process(
COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}
NO_PARALLEL_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${SHORT_BUILDTYPE}
LOGNAME "${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-${SHORT_BUILDTYPE}"
)
endif()
if (_bc_DISABLE_PARALLEL)
vcpkg_execute_build_process(
COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
WORKING_DIRECTORY ${VCPKG_BUILDTREE_TRIPLET_DIR_${BUILDTYPE}}
LOGNAME "${_bc_LOGFILE_ROOT}-${VCPKG_BUILD_TRIPLET_${BUILDTYPE}}"
)
else()
vcpkg_execute_build_process(
COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${PARALLEL_ARG}
NO_PARALLEL_COMMAND ${CMAKE_COMMAND} --build . --config ${CONFIG} ${TARGET_PARAM} -- ${BUILD_ARGS} ${NO_PARALLEL_ARG}
WORKING_DIRECTORY ${VCPKG_BUILDTREE_TRIPLET_DIR_${BUILDTYPE}}
LOGNAME "${_bc_LOGFILE_ROOT}-${VCPKG_BUILD_TRIPLET_${BUILDTYPE}}"
)
endif()

if(_bc_ADD_BIN_TO_PATH)
set(ENV{PATH} "${_BACKUP_ENV_PATH}")
endif()
if(_bc_ADD_BIN_TO_PATH)
set(ENV{PATH} "${_BACKUP_ENV_PATH}")
endif()
endforeach()
endfunction()
35 changes: 35 additions & 0 deletions scripts/cmake/vcpkg_common_definitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
## VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX import library suffix for target (same as CMAKE_IMPORT_LIBRARY_SUFFIX)
## VCPKG_FIND_LIBRARY_PREFIXES target dependent prefixes used for find_library calls in portfiles
## VCPKG_FIND_LIBRARY_SUFFIXES target dependent suffixes used for find_library calls in portfiles
## VCPKG_BUILD_LIST List of VCPKG_BUILD_TYPE which the current port will build (uppercase)
## VCPKG_BUILD_SHORT_NAME_<BUILDTYPE> Short name of the buildtype (e.g. DEBUG=dbg; RELEASE=rel)
## VCPKG_BUILD_CMAKE_TYPE_<BUILDTYPE> CMAKE_BUILD_TYPE used for buildtype
## VCPKG_BUILD_QMAKE_CONFIG_<BUILDTYPE> Required QMAKE CONFIG flags for buildtype
Comment on lines +22 to +23
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## VCPKG_BUILD_CMAKE_TYPE_<BUILDTYPE> CMAKE_BUILD_TYPE used for buildtype
## VCPKG_BUILD_QMAKE_CONFIG_<BUILDTYPE> Required QMAKE CONFIG flags for buildtype

## VCPKG_PATH_SUFFIX_<BUILDTYPE> Path suffix used for buildtype (e.g. /debug)
## VCPKG_BUILD_TRIPLET_<BUILDTYPE> Fullname of the buildtriplet e.g. ${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_<BUILDTYPE>}
## VCPKG_BUILDTREE_TRIPLET_DIR_<BUILDTYPE> Path to current buildtype buildtree (e.g. CURRENT_BUILDTREES_DIR/TRIPLET-rel )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In discussion, we have agreed on the following things:

  1. We probably shouldn't define VCPKG_BUILD_CMAKE_TYPE_* and VCPKG_BUILD_QMAKE_CONFIG_*, since they're build-system specific.
  2. We should remove VCPKG_BUILDTREE_TRIPLET_DIR_*, since that's not a concept we want to codify.
  3. We need to rename these:
  • VCPKG_BUILD_LIST -> VCPKG_BUILD_TYPES
  • VCPKG_BUILD_SHORT_NAME_* -> VCPKG_BUILD_TYPE_SHORT_NAME_*
  • VCPKG_BUILD_TRIPLET_* -> VCPKG_LOGNAME_STEM_* or something similar

VCPKG_PATH_SUFFIX_* is good as it is.

Additionally, we want to lowercase the build types in these, so that VCPKG_BUILD_TYPES becomes release;debug,
and the different variables are VCPKG_PATH_SUFFIX_release, VCPKG_PATH_SUFFIX_debug, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please re-discuss the following or give arguments:

Additionally, we want to lowercase the build types in these

uppercase is the way to go since cmake variables itself are uppercase. If I don't use uppercase build types I always have to use a string(UPPER) for VCPKG_DETECTED_<SOMELANGUAGE>_FLAGS_<SOMEBUILDTYPE_UPPER> . I don't see any good reason to stick to lowercase build types here. (I mean I can also introduce VCPKG_BUILD_TYPE_UPPER_<config> if you plan to stick to lowercase configs but it will get complicated to access flags: MY_C_FLAGS_${VCPKG_BUILD_TYPE_UPPER_${config}} instead of MY_C_FLAGS_${config})

We should remove VCPKG_BUILDTREE_TRIPLET_DIR_*, since that's not a concept we want to codify.

The path is used so often and even inside portfiles. I can rename it to _VCPKG_INTERNAL_BUILDTREE_TRIPLET_DIR_

VCPKG_BUILD_TRIPLET_* -> VCPKG_LOGNAME_STEM_* or something similar

although often used for the logname it is not only used there. It is also used in messages and paths/folders.

We probably shouldn't define VCPKG_BUILD_CMAKE_TYPE_* and VCPKG_BUILD_QMAKE_CONFIG_*, since they're build-system specific.

TODO: I'll move them to the configure scripts.

Copy link
Contributor

@strega-nil strega-nil Nov 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is, release and debug aren't necessarily related to the CMake stuff, they're related to the vcpkg BUILD_TYPE stuff; even though the words are the same between VCPKG_BUILD_TYPE = release and CMAKE_BUILD_TYPE = Release, they're not necessarily the same thing, and we shouldn't use RELEASE just because CMake does for a related but different concept. It's important to understand that our usecase of CMake is not as a build system -- we are simply using CMake as a language for writing descriptions of existing build systems.

The big reason we want to do this is we wish to tie this to VCPKG_BUILD_TYPE. I think this would be a really unfortunate and weird feature if it weren't tied to VCPKG_BUILD_TYPE.

## VCPKG_SYSTEM_LIBRARIES list of libraries are provide by the toolchain and are not managed by vcpkg
## ```
##
Expand Down Expand Up @@ -115,6 +122,33 @@ set(CMAKE_IMPORT_LIBRARY_PREFIX "${VCPKG_TARGET_IMPORT_LIBRARY_SUFFIX}")
set(CMAKE_FIND_LIBRARY_SUFFIXES "${VCPKG_FIND_LIBRARY_SUFFIXES}" CACHE INTERNAL "") # Required by find_library
set(CMAKE_FIND_LIBRARY_PREFIXES "${VCPKG_FIND_LIBRARY_PREFIXES}" CACHE INTERNAL "") # Required by find_library

# Script helpers for looping over the different buildtypes
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
set(_buildname "RELEASE")
list(APPEND VCPKG_BUILD_LIST ${_buildname})
#Might also be needed: set(VCPKG_BUILD_OPTION_MAPPING_${_buildname} "RELEASE") currently the value of VCPKG_BUILD_LIST is used
set(VCPKG_BUILD_SHORT_NAME_${_buildname} "rel")
set(VCPKG_BUILD_CMAKE_TYPE_${_buildname} "Release")
set(VCPKG_BUILD_QMAKE_CONFIG_${_buildname} "CONFIG+=release;CONFIG-=debug")
set(VCPKG_PATH_SUFFIX_${_buildname} "")
set(VCPKG_COPY_EXE_${_buildname} 1)
set(VCPKG_BUILD_TRIPLET_${_buildname} "${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${_buildname}}")
set(VCPKG_BUILDTREE_TRIPLET_DIR_${_buildname} "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${_buildname}}")
unset(_buildname)
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
set(_buildname "DEBUG")
list(APPEND VCPKG_BUILD_LIST ${_buildname})
#Might also be needed: set(VCPKG_BUILD_OPTION_MAPPING_${_buildname} "DEBUG") currently the value of VCPKG_BUILD_LIST is used
set(VCPKG_BUILD_SHORT_NAME_${_buildname} "dbg")
set(VCPKG_BUILD_CMAKE_TYPE_${_buildname} "Debug")
set(VCPKG_BUILD_QMAKE_CONFIG_${_buildname} "CONFIG-=release;CONFIG+=debug")
set(VCPKG_PATH_SUFFIX_${_buildname} "/debug")
set(VCPKG_BUILD_TRIPLET_${_buildname} "${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${_buildname}}")
set(VCPKG_BUILDTREE_TRIPLET_DIR_${_buildname} "${CURRENT_BUILDTREES_DIR}/${VCPKG_BUILD_TRIPLET_${_buildname}}")
unset(_buildname)
endif()

# Append platform libraries to VCPKG_SYSTEM_LIBRARIES
# The variable are just appended to permit to custom triplets define the variable

Expand Down Expand Up @@ -182,3 +216,4 @@ if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND VCPKG_SYSTEM_LIBRARIES wsock32)
list(APPEND VCPKG_SYSTEM_LIBRARIES Ws2_32)
endif()

102 changes: 38 additions & 64 deletions scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,11 @@ function(vcpkg_configure_cmake)
set(NINJA_CAN_BE_USED ON) # Ninja as generator
set(NINJA_HOST ON) # Ninja as parallel configurator

if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(_TARGETTING_UWP 1)
endif()

if(_csc_HOST_ARCHITECTURE STREQUAL "x86")
# Prebuilt ninja binaries are only provided for x64 hosts
set(NINJA_CAN_BE_USED OFF)
set(NINJA_HOST OFF)
elseif(_TARGETTING_UWP)
elseif(VCPKG_TARGET_IS_UWP)
# Ninja and MSBuild have many differences when targetting UWP, so use MSBuild to maximize existing compatibility
set(NINJA_CAN_BE_USED OFF)
endif()
Expand All @@ -101,9 +97,8 @@ function(vcpkg_configure_cmake)
set(GENERATOR ${_csc_GENERATOR})
elseif(_csc_PREFER_NINJA AND NINJA_CAN_BE_USED)
set(GENERATOR "Ninja")
elseif(VCPKG_CHAINLOAD_TOOLCHAIN_FILE OR (VCPKG_CMAKE_SYSTEM_NAME AND NOT _TARGETTING_UWP))
elseif(VCPKG_CHAINLOAD_TOOLCHAIN_FILE OR NOT VCPKG_TARGET_IS_WINDOWS)
set(GENERATOR "Ninja")

elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" AND VCPKG_PLATFORM_TOOLSET STREQUAL "v120")
set(GENERATOR "Visual Studio 12 2013")
elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" AND VCPKG_PLATFORM_TOOLSET STREQUAL "v120")
Expand Down Expand Up @@ -161,7 +156,8 @@ function(vcpkg_configure_cmake)

if(DEFINED VCPKG_CMAKE_SYSTEM_NAME)
list(APPEND _csc_OPTIONS "-DCMAKE_SYSTEM_NAME=${VCPKG_CMAKE_SYSTEM_NAME}")
if(_TARGETTING_UWP AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
if(VCPKG_TARGET_IS_UWP AND NOT DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
message(WARNING "UWP triplet is missing VCPKG_CMAKE_SYSTEM_VERSION. Setting it to 10.0")
set(VCPKG_CMAKE_SYSTEM_VERSION 10.0)
endif()
endif()
Expand Down Expand Up @@ -196,24 +192,25 @@ function(vcpkg_configure_cmake)
endif()

if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
if(NOT DEFINED VCPKG_CMAKE_SYSTEM_NAME OR _TARGETTING_UWP)
if(VCPKG_TARGET_IS_MINGW) # MinGW also defines VCPKG_TARGET_IS_WINDOWS
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake")
elseif(VCPKG_TARGET_IS_WINDOWS)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")
elseif(VCPKG_TARGET_IS_LINUX)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
elseif(VCPKG_TARGET_IS_ANDROID)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/android.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Darwin")
elseif(VCPKG_TARGET_IS_OSX)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/osx.cmake")
elseif(VCPKG_TARGET_IS_FREEBSD)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/ios.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/freebsd.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "MinGW")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake")
else()
message(STATUS "Unknown VCPKG target. No VCPKG_CHAINLOAD_TOOLCHAIN_FILE set!")
endif()
endif()


list(APPEND _csc_OPTIONS
"-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}"
"-DVCPKG_TARGET_TRIPLET=${TARGET_TRIPLET}"
Expand Down Expand Up @@ -258,16 +255,13 @@ function(vcpkg_configure_cmake)
endif()
endforeach()

set(rel_command
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} "${_csc_OPTIONS}" "${_csc_OPTIONS_RELEASE}"
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR})
set(dbg_command
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} "${_csc_OPTIONS}" "${_csc_OPTIONS_DEBUG}"
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug)
foreach(buildtype ${VCPKG_BUILD_LIST})
set(${VCPKG_BUILD_SHORT_NAME_${buildtype}}_command
${CMAKE_COMMAND} ${_csc_SOURCE_PATH} "${_csc_OPTIONS}" "${_csc_OPTIONS_${buildtype}}"
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=${VCPKG_BUILD_CMAKE_TYPE_${buildtype}}
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}${VCPKG_PATH_SUFFIX_${buildtype}})
endforeach()

if(NINJA_HOST AND CMAKE_HOST_WIN32 AND NOT _csc_DISABLE_PARALLEL_CONFIGURE)
list(APPEND _csc_OPTIONS "-DCMAKE_DISABLE_SOURCE_CHANGES=ON")
Expand All @@ -280,53 +274,33 @@ function(vcpkg_configure_cmake)
set(_contents
"rule CreateProcess\n command = $process\n\n"
)

macro(_build_cmakecache whereat build_type)
set(${build_type}_line "build ${whereat}/CMakeCache.txt: CreateProcess\n process = cmd /c \"cd ${whereat} &&")
foreach(arg ${${build_type}_command})
set(${build_type}_line "${${build_type}_line} \"${arg}\"")
foreach(buildtype ${VCPKG_BUILD_LIST})
set(buildshort ${VCPKG_BUILD_SHORT_NAME_${buildtype}})
set(${buildtype}_line "build ../${TARGET_TRIPLET}-${buildshort}/CMakeCache.txt: CreateProcess\n process = cmd /c \"cd ../${TARGET_TRIPLET}-${buildshort} && ")
foreach(arg ${${buildshort}_command})
string(APPEND ${buildtype}_line "\"${arg}\" ")
endforeach()
set(_contents "${_contents}${${build_type}_line}\"\n\n")
endmacro()

if(NOT DEFINED VCPKG_BUILD_TYPE)
_build_cmakecache(".." "rel")
_build_cmakecache("../../${TARGET_TRIPLET}-dbg" "dbg")
elseif(VCPKG_BUILD_TYPE STREQUAL "release")
_build_cmakecache(".." "rel")
elseif(VCPKG_BUILD_TYPE STREQUAL "debug")
_build_cmakecache("../../${TARGET_TRIPLET}-dbg" "dbg")
endif()

file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure)
file(WRITE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure/build.ninja "${_contents}")
set(_contents "${_contents}${${buildtype}_line}\"\n\n")
endforeach()
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/vcpkg-parallel-configure)
file(WRITE ${CURRENT_BUILDTREES_DIR}/vcpkg-parallel-configure/build.ninja "${_contents}")

message(STATUS "Configuring ${TARGET_TRIPLET}")
vcpkg_execute_required_process(
COMMAND ninja -v
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/vcpkg-parallel-configure
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/vcpkg-parallel-configure
LOGNAME config-${TARGET_TRIPLET}
)
else()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
foreach(buildtype ${VCPKG_BUILD_LIST})
message(STATUS "Configuring ${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${buildtype}}")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${buildtype}})
vcpkg_execute_required_process(
COMMAND ${dbg_command}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME config-${TARGET_TRIPLET}-dbg
COMMAND ${${VCPKG_BUILD_SHORT_NAME_${buildtype}}_command}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${buildtype}}
LOGNAME config-${TARGET_TRIPLET}-${VCPKG_BUILD_SHORT_NAME_${buildtype}}
)
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
COMMAND ${rel_command}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME config-${TARGET_TRIPLET}-rel
)
endif()
endforeach()
endif()

set(_VCPKG_CMAKE_GENERATOR "${GENERATOR}" PARENT_SCOPE)
Expand Down
Loading