[vcpkg] Initial experimental support for VCPKG_BUILD_TYPE release

This commit is contained in:
Robert Schumacher 2017-11-25 15:25:18 -08:00
parent 6b64a9adb6
commit 5335d17f53
15 changed files with 249 additions and 187 deletions

View File

@ -223,33 +223,37 @@ set(B2_OPTIONS_REL
######################
# Perform build + Package
######################
message(STATUS "Building ${TARGET_TRIPLET}-rel")
set(ENV{BOOST_BUILD_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process_repeat(
COUNT 2
COMMAND "${SOURCE_PATH}/b2.exe"
--stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage
--build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
${B2_OPTIONS_REL}
variant=release
debug-symbols=on
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-rel
)
message(STATUS "Building ${TARGET_TRIPLET}-rel done")
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
set(ENV{BOOST_BUILD_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process_repeat(
COUNT 2
COMMAND "${SOURCE_PATH}/b2.exe"
--stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage
--build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
${B2_OPTIONS_DBG}
variant=debug
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-dbg
)
message(STATUS "Building ${TARGET_TRIPLET}-dbg done")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Building ${TARGET_TRIPLET}-rel")
set(ENV{BOOST_BUILD_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process_repeat(
COUNT 2
COMMAND "${SOURCE_PATH}/b2.exe"
--stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage
--build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
${B2_OPTIONS_REL}
variant=release
debug-symbols=on
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-rel
)
message(STATUS "Building ${TARGET_TRIPLET}-rel done")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building ${TARGET_TRIPLET}-dbg")
set(ENV{BOOST_BUILD_PATH} ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process_repeat(
COUNT 2
COMMAND "${SOURCE_PATH}/b2.exe"
--stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage
--build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
${B2_OPTIONS_DBG}
variant=debug
WORKING_DIRECTORY ${SOURCE_PATH}
LOGNAME build-${TARGET_TRIPLET}-dbg
)
message(STATUS "Building ${TARGET_TRIPLET}-dbg done")
endif()
message(STATUS "Packaging headers")
file(
@ -294,32 +298,36 @@ function(boost_rename_libs LIBS)
endforeach()
endfunction()
message(STATUS "Packaging ${TARGET_TRIPLET}-rel")
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/lib
FILES_MATCHING PATTERN "*.lib")
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Packaging ${TARGET_TRIPLET}-rel")
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/bin
FILES_MATCHING PATTERN "*.dll")
DESTINATION ${CURRENT_PACKAGES_DIR}/lib
FILES_MATCHING PATTERN "*.lib")
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/bin
FILES_MATCHING PATTERN "*.dll")
endif()
file(GLOB RELEASE_LIBS ${CURRENT_PACKAGES_DIR}/lib/*.lib)
boost_rename_libs(RELEASE_LIBS)
message(STATUS "Packaging ${TARGET_TRIPLET}-rel done")
endif()
file(GLOB RELEASE_LIBS ${CURRENT_PACKAGES_DIR}/lib/*.lib)
boost_rename_libs(RELEASE_LIBS)
message(STATUS "Packaging ${TARGET_TRIPLET}-rel done")
message(STATUS "Packaging ${TARGET_TRIPLET}-dbg")
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
FILES_MATCHING PATTERN "*.lib")
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Packaging ${TARGET_TRIPLET}-dbg")
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin
FILES_MATCHING PATTERN "*.dll")
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib
FILES_MATCHING PATTERN "*.lib")
if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin
FILES_MATCHING PATTERN "*.dll")
endif()
file(GLOB DEBUG_LIBS ${CURRENT_PACKAGES_DIR}/debug/lib/*.lib)
boost_rename_libs(DEBUG_LIBS)
message(STATUS "Packaging ${TARGET_TRIPLET}-dbg done")
endif()
file(GLOB DEBUG_LIBS ${CURRENT_PACKAGES_DIR}/debug/lib/*.lib)
boost_rename_libs(DEBUG_LIBS)
message(STATUS "Packaging ${TARGET_TRIPLET}-dbg done")
macro(move_to_manual_link LIBNAME)
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/${LIBNAME}-vc140-mt-${VERSION_FULL}.lib)

View File

@ -58,19 +58,23 @@ function(vcpkg_build_cmake)
set(TARGET_PARAM)
endif()
message(STATUS "Build ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-rel
)
message(STATUS "Build ${TARGET_TRIPLET}-rel done")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Build ${TARGET_TRIPLET}-rel")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Release ${TARGET_PARAM} -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-rel
)
message(STATUS "Build ${TARGET_TRIPLET}-rel done")
endif()
message(STATUS "Build ${TARGET_TRIPLET}-dbg")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Debug ${TARGET_PARAM} -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-dbg
)
message(STATUS "Build ${TARGET_TRIPLET}-dbg done")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Build ${TARGET_TRIPLET}-dbg")
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} --build . --config Debug ${TARGET_PARAM} -- ${BUILD_ARGS}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME ${_bc_LOGFILE_ROOT}-${TARGET_TRIPLET}-dbg
)
message(STATUS "Build ${TARGET_TRIPLET}-dbg done")
endif()
endfunction()

View File

@ -87,25 +87,29 @@ function(vcpkg_build_msbuild)
/m
)
message(STATUS "Building ${_csc_PROJECT_PATH} for Release")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
COMMAND msbuild ${_csc_PROJECT_PATH}
/p:Configuration=${_csc_RELEASE_CONFIGURATION}
${_csc_OPTIONS}
${_csc_OPTIONS_RELEASE}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME build-${TARGET_TRIPLET}-rel
)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Building ${_csc_PROJECT_PATH} for Release")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
COMMAND msbuild ${_csc_PROJECT_PATH}
/p:Configuration=${_csc_RELEASE_CONFIGURATION}
${_csc_OPTIONS}
${_csc_OPTIONS_RELEASE}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME build-${TARGET_TRIPLET}-rel
)
endif()
message(STATUS "Building ${_csc_PROJECT_PATH} for Debug")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process(
COMMAND msbuild ${_csc_PROJECT_PATH}
/p:Configuration=${_csc_DEBUG_CONFIGURATION}
${_csc_OPTIONS}
${_csc_OPTIONS_DEBUG}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME build-${TARGET_TRIPLET}-dbg
)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
message(STATUS "Building ${_csc_PROJECT_PATH} for Debug")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process(
COMMAND msbuild ${_csc_PROJECT_PATH}
/p:Configuration=${_csc_DEBUG_CONFIGURATION}
${_csc_OPTIONS}
${_csc_OPTIONS_DEBUG}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME build-${TARGET_TRIPLET}-dbg
)
endif()
endfunction()

View File

@ -199,29 +199,33 @@ function(vcpkg_configure_cmake)
)
endif()
message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE}
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME config-${TARGET_TRIPLET}-rel
)
message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
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 ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE}
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME config-${TARGET_TRIPLET}-rel
)
message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
endif()
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG}
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME config-${TARGET_TRIPLET}-dbg
)
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
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)
vcpkg_execute_required_process(
COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG}
-G ${GENERATOR}
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME config-${TARGET_TRIPLET}-dbg
)
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
endif()
set(_VCPKG_CMAKE_GENERATOR "${GENERATOR}" PARENT_SCOPE)
endfunction()

View File

@ -42,31 +42,35 @@ function(vcpkg_configure_meson)
set(ENV{PATH} "$ENV{PATH};${NINJA_PATH}")
# configure release
message(STATUS "Configuring ${TARGET_TRIPLET}-rel")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_RELEASE_CFLAGS}")
set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_RELEASE_CXXFLAGS}")
set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_RELEASE_LDFLAGS}")
set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_RELEASE_CPPFLAGS}")
vcpkg_execute_required_process(
COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_RELEASE} ${_vcm_SOURCE_PATH}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME config-${TARGET_TRIPLET}-rel
)
message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
# configure debug
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_DEBUG_CFLAGS}")
set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_DEBUG_CXXFLAGS}")
set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_DEBUG_LDFLAGS}")
set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_DEBUG_CPPFLAGS}")
vcpkg_execute_required_process(
COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_DEBUG} ${_vcm_SOURCE_PATH}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME config-${TARGET_TRIPLET}-dbg
)
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
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)
set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_RELEASE_CFLAGS}")
set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_RELEASE_CXXFLAGS}")
set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_RELEASE_LDFLAGS}")
set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_RELEASE_CPPFLAGS}")
vcpkg_execute_required_process(
COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_RELEASE} ${_vcm_SOURCE_PATH}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel
LOGNAME config-${TARGET_TRIPLET}-rel
)
message(STATUS "Configuring ${TARGET_TRIPLET}-rel done")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
# configure debug
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg)
set(ENV{CFLAGS} "${MESON_COMMON_CFLAGS} ${MESON_DEBUG_CFLAGS}")
set(ENV{CXXFLAGS} "${MESON_COMMON_CXXFLAGS} ${MESON_DEBUG_CXXFLAGS}")
set(ENV{LDFLAGS} "${MESON_COMMON_LDFLAGS} ${MESON_DEBUG_LDFLAGS}")
set(ENV{CPPFLAGS} "${MESON_COMMON_CPPFLAGS} ${MESON_DEBUG_CPPFLAGS}")
vcpkg_execute_required_process(
COMMAND ${MESON} ${_vcm_OPTIONS} ${_vcm_OPTIONS_DEBUG} ${_vcm_SOURCE_PATH}
WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg
LOGNAME config-${TARGET_TRIPLET}-dbg
)
message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done")
endif()
endfunction()

View File

@ -27,29 +27,33 @@ function(vcpkg_fixup_cmake_targets)
set(DEBUG_CONFIG ${CURRENT_PACKAGES_DIR}/debug/${_vfct_CONFIG_PATH})
set(RELEASE_CONFIG ${CURRENT_PACKAGES_DIR}/${_vfct_CONFIG_PATH})
if(NOT EXISTS ${DEBUG_CONFIG})
message(FATAL_ERROR "'${DEBUG_CONFIG}' does not exist.")
endif()
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
if(NOT EXISTS ${DEBUG_CONFIG})
message(FATAL_ERROR "'${DEBUG_CONFIG}' does not exist.")
endif()
file(MAKE_DIRECTORY ${DEBUG_SHARE})
file(GLOB FILES ${DEBUG_CONFIG}/*)
file(COPY ${FILES} DESTINATION ${DEBUG_SHARE})
file(REMOVE_RECURSE ${DEBUG_CONFIG})
file(MAKE_DIRECTORY ${DEBUG_SHARE})
file(GLOB FILES ${DEBUG_CONFIG}/*)
file(COPY ${FILES} DESTINATION ${DEBUG_SHARE})
file(REMOVE_RECURSE ${DEBUG_CONFIG})
endif()
file(GLOB FILES ${RELEASE_CONFIG}/*)
file(COPY ${FILES} DESTINATION ${RELEASE_SHARE})
file(REMOVE_RECURSE ${RELEASE_CONFIG})
get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG} NAME)
string(TOLOWER "${DEBUG_CONFIG_DIR_NAME}" DEBUG_CONFIG_DIR_NAME)
if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake")
file(REMOVE_RECURSE ${DEBUG_CONFIG})
else()
get_filename_component(DEBUG_CONFIG_PARENT_DIR ${DEBUG_CONFIG} DIRECTORY)
get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG_PARENT_DIR} NAME)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG} NAME)
string(TOLOWER "${DEBUG_CONFIG_DIR_NAME}" DEBUG_CONFIG_DIR_NAME)
if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake")
file(REMOVE_RECURSE ${DEBUG_CONFIG_PARENT_DIR})
file(REMOVE_RECURSE ${DEBUG_CONFIG})
else()
get_filename_component(DEBUG_CONFIG_PARENT_DIR ${DEBUG_CONFIG} DIRECTORY)
get_filename_component(DEBUG_CONFIG_DIR_NAME ${DEBUG_CONFIG_PARENT_DIR} NAME)
string(TOLOWER "${DEBUG_CONFIG_DIR_NAME}" DEBUG_CONFIG_DIR_NAME)
if(DEBUG_CONFIG_DIR_NAME STREQUAL "cmake")
file(REMOVE_RECURSE ${DEBUG_CONFIG_PARENT_DIR})
endif()
endif()
endif()
@ -67,8 +71,10 @@ function(vcpkg_fixup_cmake_targets)
endif()
endif()
if(NOT EXISTS ${DEBUG_SHARE})
message(FATAL_ERROR "'${DEBUG_SHARE}' does not exist.")
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
if(NOT EXISTS ${DEBUG_SHARE})
message(FATAL_ERROR "'${DEBUG_SHARE}' does not exist.")
endif()
endif()
file(GLOB UNUSED_FILES
@ -94,23 +100,25 @@ function(vcpkg_fixup_cmake_targets)
file(WRITE ${RELEASE_TARGET} "${_contents}")
endforeach()
file(GLOB DEBUG_TARGETS
"${DEBUG_SHARE}/*[Tt]argets-debug.cmake"
"${DEBUG_SHARE}/*[Cc]onfig-debug.cmake"
"${DEBUG_SHARE}/*[Ee]xports-debug.cmake"
)
foreach(DEBUG_TARGET ${DEBUG_TARGETS})
get_filename_component(DEBUG_TARGET_NAME ${DEBUG_TARGET} NAME)
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
file(GLOB DEBUG_TARGETS
"${DEBUG_SHARE}/*[Tt]argets-debug.cmake"
"${DEBUG_SHARE}/*[Cc]onfig-debug.cmake"
"${DEBUG_SHARE}/*[Ee]xports-debug.cmake"
)
foreach(DEBUG_TARGET ${DEBUG_TARGETS})
get_filename_component(DEBUG_TARGET_NAME ${DEBUG_TARGET} NAME)
file(READ ${DEBUG_TARGET} _contents)
string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" _contents "${_contents}")
string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}")
string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" _contents "${_contents}")
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" _contents "${_contents}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/${DEBUG_TARGET_NAME} "${_contents}")
file(READ ${DEBUG_TARGET} _contents)
string(REPLACE "${CURRENT_INSTALLED_DIR}" "\${_IMPORT_PREFIX}" _contents "${_contents}")
string(REGEX REPLACE "\\\${_IMPORT_PREFIX}/bin/([^ \"]+\\.exe)" "\${_IMPORT_PREFIX}/tools/${PORT}/\\1" _contents "${_contents}")
string(REPLACE "\${_IMPORT_PREFIX}/lib" "\${_IMPORT_PREFIX}/debug/lib" _contents "${_contents}")
string(REPLACE "\${_IMPORT_PREFIX}/bin" "\${_IMPORT_PREFIX}/debug/bin" _contents "${_contents}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/${PORT}/${DEBUG_TARGET_NAME} "${_contents}")
file(REMOVE ${DEBUG_TARGET})
endforeach()
file(REMOVE ${DEBUG_TARGET})
endforeach()
endif()
file(GLOB MAIN_TARGETS "${RELEASE_SHARE}/*[Tt]argets.cmake")
foreach(MAIN_TARGET ${MAIN_TARGETS})

View File

@ -8,3 +8,4 @@ message("VCPKG_CMAKE_SYSTEM_VERSION=${VCPKG_CMAKE_SYSTEM_VERSION}")
message("VCPKG_PLATFORM_TOOLSET=${VCPKG_PLATFORM_TOOLSET}")
message("VCPKG_VISUAL_STUDIO_PATH=${VCPKG_VISUAL_STUDIO_PATH}")
message("VCPKG_CHAINLOAD_TOOLCHAIN_FILE=${VCPKG_CHAINLOAD_TOOLCHAIN_FILE}")
message("VCPKG_BUILD_TYPE=${VCPKG_BUILD_TYPE}")

View File

@ -1 +1 @@
"0.0.97"
"0.0.98"

View File

@ -44,6 +44,12 @@ namespace vcpkg::Build
YES
};
enum class ConfigurationType
{
DEBUG,
RELEASE,
};
struct BuildPackageOptions
{
UseHeadVersion use_head_version;
@ -90,6 +96,7 @@ namespace vcpkg::Build
Optional<std::string> platform_toolset;
Optional<fs::path> visual_studio_path;
Optional<std::string> external_toolchain_file;
Optional<ConfigurationType> build_type;
};
std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset);

View File

@ -8,12 +8,6 @@
namespace vcpkg::PostBuildLint
{
enum class ConfigurationType
{
DEBUG,
RELEASE,
};
struct BuildType
{
enum class BackingEnum
@ -24,12 +18,12 @@ namespace vcpkg::PostBuildLint
RELEASE_DYNAMIC
};
static BuildType value_of(const ConfigurationType& config, const Build::LinkageType& linkage);
static BuildType value_of(const Build::ConfigurationType& config, const Build::LinkageType& linkage);
BuildType() = delete;
constexpr BuildType(const BackingEnum backing_enum,
const ConfigurationType config,
const Build::ConfigurationType config,
const Build::LinkageType linkage)
: backing_enum(backing_enum), m_config(config), m_linkage(linkage)
{
@ -37,14 +31,14 @@ namespace vcpkg::PostBuildLint
constexpr operator BackingEnum() const { return backing_enum; }
const ConfigurationType& config() const;
const Build::ConfigurationType& config() const;
const Build::LinkageType& linkage() const;
const std::regex& crt_regex() const;
const std::string& to_string() const;
private:
BackingEnum backing_enum;
ConfigurationType m_config;
Build::ConfigurationType m_config;
Build::LinkageType m_linkage;
};
@ -55,12 +49,14 @@ namespace vcpkg::PostBuildLint
static constexpr CStringView ENUM_NAME = "vcpkg::PostBuildLint::BuildType";
static constexpr BuildType DEBUG_STATIC = {BE::DEBUG_STATIC, ConfigurationType::DEBUG, LinkageType::STATIC};
static constexpr BuildType DEBUG_DYNAMIC = {BE::DEBUG_DYNAMIC, ConfigurationType::DEBUG, LinkageType::DYNAMIC};
static constexpr BuildType DEBUG_STATIC = {
BE::DEBUG_STATIC, Build::ConfigurationType::DEBUG, LinkageType::STATIC};
static constexpr BuildType DEBUG_DYNAMIC = {
BE::DEBUG_DYNAMIC, Build::ConfigurationType::DEBUG, LinkageType::DYNAMIC};
static constexpr BuildType RELEASE_STATIC = {
BE::RELEASE_STATIC, ConfigurationType::RELEASE, LinkageType::STATIC};
BE::RELEASE_STATIC, Build::ConfigurationType::RELEASE, LinkageType::STATIC};
static constexpr BuildType RELEASE_DYNAMIC = {
BE::RELEASE_DYNAMIC, ConfigurationType::RELEASE, LinkageType::DYNAMIC};
BE::RELEASE_DYNAMIC, Build::ConfigurationType::RELEASE, LinkageType::DYNAMIC};
static constexpr std::array<BuildType, 4> VALUES = {
DEBUG_STATIC, DEBUG_DYNAMIC, RELEASE_STATIC, RELEASE_DYNAMIC};

View File

@ -565,6 +565,20 @@ namespace vcpkg::Build
continue;
}
if (variable_name == "VCPKG_BUILD_TYPE")
{
if (variable_value.empty())
pre_build_info.build_type = nullopt;
else if (Strings::case_insensitive_ascii_equals(variable_value, "debug"))
pre_build_info.build_type = ConfigurationType::DEBUG;
else if (Strings::case_insensitive_ascii_equals(variable_value, "release"))
pre_build_info.build_type = ConfigurationType::RELEASE;
else
Checks::exit_with_message(
VCPKG_LINE_INFO, "Unknown setting for VCPKG_BUILD_TYPE: %s", variable_value);
continue;
}
Checks::exit_with_message(VCPKG_LINE_INFO, "Unknown variable name %s", line);
}

View File

@ -3,6 +3,8 @@
#include <vcpkg/base/checks.h>
#include <vcpkg/postbuildlint.buildtype.h>
using vcpkg::Build::ConfigurationType;
namespace vcpkg::PostBuildLint
{
BuildType BuildType::value_of(const ConfigurationType& config, const Build::LinkageType& linkage)

View File

@ -758,7 +758,8 @@ namespace vcpkg::PostBuildLint
std::vector<fs::path> release_libs = fs.get_files_recursive(release_lib_dir);
Util::unstable_keep_if(release_libs, has_extension_pred(fs, ".lib"));
error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs);
if (!pre_build_info.build_type)
error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs);
{
std::vector<fs::path> libs;
@ -777,7 +778,8 @@ namespace vcpkg::PostBuildLint
{
case Build::LinkageType::DYNAMIC:
{
error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls);
if (!pre_build_info.build_type)
error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls);
error_count += check_lib_files_are_available_if_dlls_are_available(
build_info.policies, debug_libs.size(), debug_dlls.size(), debug_lib_dir);
@ -805,15 +807,15 @@ namespace vcpkg::PostBuildLint
if (!build_info.policies.is_enabled(BuildPolicy::ONLY_RELEASE_CRT))
{
error_count +=
check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::DEBUG, build_info.crt_linkage),
debug_libs,
toolset.dumpbin);
error_count += check_crt_linkage_of_libs(
BuildType::value_of(Build::ConfigurationType::DEBUG, build_info.crt_linkage),
debug_libs,
toolset.dumpbin);
}
error_count +=
check_crt_linkage_of_libs(BuildType::value_of(ConfigurationType::RELEASE, build_info.crt_linkage),
release_libs,
toolset.dumpbin);
error_count += check_crt_linkage_of_libs(
BuildType::value_of(Build::ConfigurationType::RELEASE, build_info.crt_linkage),
release_libs,
toolset.dumpbin);
break;
}
default: Checks::unreachable(VCPKG_LINE_INFO);

View File

@ -138,6 +138,9 @@
<ItemGroup>
<ClCompile Include="..\src\vcpkg.cpp" />
</ItemGroup>
<ItemGroup>
<Text Include="..\VERSION.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -19,4 +19,9 @@
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="..\VERSION.txt">
<Filter>Source Files</Filter>
</Text>
</ItemGroup>
</Project>