Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ cmake --preset x64-windows-internal

This will generate an .slnx at `.cmake-build-<preset-name>/`. Run `cmake --list-presets` to see the presets
(`x64-windows-*`, `arm64-osx-*`, `x64-osx-*`, each in `internal`, `release`, `debug` and `trinitydev` flavours).
The solution contains only the preset's flavour, because vcpkg installs the dependencies for that flavour alone.
To work on another flavour, generate it with its own preset into its own build folder.

Or build from the command line:

```powershell
cmake --build .cmake-build-x64-windows-internal --config Release
cmake --build .cmake-build-x64-windows-internal --config Internal
```

- Open the generated solution, not the repo folder. Opening the folder makes Visual Studio
Expand Down
42 changes: 12 additions & 30 deletions cmake/CcpBuildConfigurations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,20 @@ Options placed in the toolchain files apply to both this top level project and i
While it is desierable for all dependencies to share the same build flags and other settings provided by the toolchain,
we do not want 3rd party dependencies to be configured with the settings provided by this file.
]]
# this applies to multi-configuration build system, e.g. XCode, Visual Studio, Ninja Multi-Config
# Every flavor a Carbon component is published in. The published package holds one build of each.
set(CCP_BUILD_FLAVORS Debug TrinityDev Internal Release)

set(CMAKE_CONFIGURATION_TYPES Debug TrinityDev Internal Release)

get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}"
CACHE
STRING
"Reset the configurations to what we need"
FORCE
)
else()
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No CMAKE_BUILD_TYPE was specified, defaulting to 'Debug'")
set(CMAKE_BUILD_TYPE "Debug")
endif()
# Update the documentation string of CMAKE_BUILD_TYPE for GUIs
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}"
CACHE
STRING
"Choose the type of build, options are: ${CMAKE_CONFIGURATION_TYPES}."
FORCE
)

# check if a valid build type was supplied
if (CMAKE_BUILD_TYPE IN_LIST CMAKE_CONFIGURATION_TYPES)
message(STATUS "Building configuration ${CMAKE_BUILD_TYPE}")
else()
message(FATAL_ERROR "Invalid configuration ${CMAKE_BUILD_TYPE}. Available options are: ${CMAKE_CONFIGURATION_TYPES}")
endif()
# A build folder holds one flavor: the one its preset's vcpkg triplet installed dependencies for.
# This applies to multi-config generators too (Visual Studio, Xcode, Ninja Multi-Config): any other configuration
# would build against that flavor's dependencies.
if (NOT CMAKE_BUILD_TYPE IN_LIST CCP_BUILD_FLAVORS)
message(FATAL_ERROR "CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}', expected one of: ${CCP_BUILD_FLAVORS}. "
"Configure with a preset, e.g. cmake --preset x64-windows-trinitydev")
endif()
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "Build flavor, one of: ${CCP_BUILD_FLAVORS}" FORCE)
message(STATUS "Building configuration ${CMAKE_BUILD_TYPE}")

set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "The build flavor only" FORCE)

# Create a new configuration based on an existing one
function(create_new_build_config config prototype)
Expand Down
3 changes: 2 additions & 1 deletion cmake/CcpPackageConfigHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ function(configure_ccp_vendor_config_file)
set(CCP_PACKAGE_CONFIG_TARGET_DEPENDENCIES "${CCP_PACKAGE_CONFIG_TARGET_DEPENDENCIES}find_dependency(${_DEP} REQUIRED CONFIG NO_CMAKE_PATH)\n")
endforeach()
if(NOT CCP_PACKAGE_CONFIG_CONFIGURATIONS)
set(CCP_PACKAGE_CONFIG_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
# A build folder builds one flavor, but the published package holds every flavor
set(CCP_PACKAGE_CONFIG_CONFIGURATIONS ${CCP_BUILD_FLAVORS})
endif()
get_target_property(CCP_PACKAGE_CONFIG_TARGET_TYPE ${CCP_PACKAGE_CONFIG_TARGET} TYPE)
if (${CCP_PACKAGE_CONFIG_TARGET_TYPE} STREQUAL STATIC_LIBRARY)
Expand Down