-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
External cmake project integration (#193)
Work to make it easier/possible to integrate the C++ components of MLOS with an external C++ project (e.g. LevelDB, MySql, etc.) via `cmake`. - Fixes some issues with our own `cmake` config assumptions. - Adds examples patterns and documentation for using in an "external project" (currently just a minimal example). - Hooks those into the CI pipelines. This branch was split off of the work from #177 (since merged) to build NuGet packages for some of the C# components, so many of the original commits are shared.
- Loading branch information
Showing
38 changed files
with
807 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -431,3 +431,4 @@ website/python_api | |
|
||
# python code coverage | ||
coverage | ||
.coverage.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Ignore the local MLOS codegen output for this example: | ||
./Mlos.CodeGen.out/ | ||
.nuget/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "(gdb) Attach - ExternalIntegrationExample", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/build/ExternalIntegrationExample", | ||
"cwd": "${workspaceFolder}/build", | ||
"MIMode": "gdb", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
|
||
# Here we assume some existing external build system setup, using cmake: | ||
|
||
project(ExternalIntegrationExample) | ||
|
||
# Set some general compile options. | ||
include(./cmake/Common.cmake) | ||
|
||
# This is a simple existing project definition. | ||
# | ||
add_executable(${PROJECT_NAME} | ||
ExternalIntegrationExample.cpp | ||
) | ||
|
||
# Now, we start adding MLOS integrations. | ||
|
||
# First, include some cross component/target cmake rules for | ||
# fetching the MLOS source code and registering its cmake targets. | ||
# | ||
include(./cmake/MlosBuildIntegrations.cmake) | ||
|
||
target_link_libraries(${PROJECT_NAME} Mlos.Core) | ||
|
||
# SettingsRegistry projects produce C++ codegen artifacts, that this project | ||
# consumes, so we mark that project as a dependency. | ||
# | ||
add_subdirectory(ExternalIntegrationExample.SettingsRegistry) | ||
add_dependencies(${PROJECT_NAME} ExternalIntegrationExample.SettingsRegistry) |
3 changes: 3 additions & 0 deletions
3
external/ExternalIntegrationExample/ExternalIntegrationExample.SettingsRegistry/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
!build/ | ||
bin/ | ||
obj/ |
25 changes: 25 additions & 0 deletions
25
...nal/ExternalIntegrationExample/ExternalIntegrationExample.SettingsRegistry/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This is a sub component of the ExternalIntegrationExample.cpp | ||
# As such, some additional setup work to fetch and prepare the MLOS upstream | ||
# source repo for use is expected to have been done already. | ||
# See Also: MlosBuildIntegrations.cmake | ||
|
||
include(MLOS) | ||
|
||
# Use an MLOS cmake module provided function to create a small wrapper target | ||
# around the dotnet build for the SettingsRegistry csproj file. | ||
# | ||
add_mlos_settings_registry( | ||
# The name of the .csproj for this MLOS SettingsRegistry: | ||
NAME ExternalIntegrationExample.SettingsRegistry | ||
# Where to find it: | ||
DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" | ||
# Optionally override some settings in the .csproj file. | ||
# | ||
# This is equivalent to "dotnet build /p:MlosSettingsSystemCodeGenOutputDirectory=/basepath-to-all-codegen-output/specific-component" | ||
CODEGEN_OUTPUT_DIR "${MlosCodeGenBaseOutDir}/ExternalIntegrationExample" | ||
# This is equivalent to "dotnet build /p:MlosSettingsRegistryAssemblyOutputDirectory=/path-to-all-settings-registry-dll-outputs" | ||
BINPLACE_DIR "${MlosSettingsRegistryDllDir}" | ||
# Optionally build, pack, and restore the nugets from the local Mlos repo checkout. | ||
# (since we aren't yet publishing these nugets, this is currently required) | ||
USE_LOCAL_MLOS_NUGETS | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 18 additions & 1 deletion
19
external/ExternalIntegrationExample/ExternalIntegrationExample.SettingsRegistry/Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
# This is a simple Makefile used mostly for local interactive development. | ||
|
||
CONFIGURATION ?= Release | ||
|
||
all: dotnet-build | ||
|
||
clean: dotnet-clean | ||
rm -rf ../.nuget/packages/mlos.* || true | ||
rm -rf ../Mlos.CodeGen.out/ExternalIntegrationExample | ||
|
||
distclean: clean | ||
rm -rf ./bin/ | ||
rm -rf ./obj/ | ||
rm -rf ../.nuget/ | ||
rm -rf ../Mlos.CodeGen.out/ | ||
|
||
dotnet-build: | ||
dotnet build $(MSBUILD_ARGS) -c $(CONFIGURATION) /p:PackMlosDependencies=true | ||
|
||
dotnet-build-quick: | ||
dotnet build $(MSBUILD_ARGS) -c $(CONFIGURATION) --no-restore | ||
|
||
# A convenience helper for local package development: | ||
dotnet-rebuild-all: | ||
dotnet build $(MSBUILD_ARGS) -c $(CONFIGURATION) /p:PackMlosDependencies=true /p:CleanMlosPackages=true | ||
|
||
dotnet-clean: | ||
dotnet build $(MSBUILD_ARGS) -c $(CONFIGURATION) --no-restore /t:clean | ||
dotnet build $(MSBUILD_ARGS) -c $(CONFIGURATION) --no-restore /t:clean 2>/dev/null >/dev/null || true | ||
|
||
# A quick wrapper for invoking testing the CMakeLists.txt wrapper. | ||
cmake-build: | ||
mkdir -p ../build | ||
cd ../build/ && cmake .. | ||
cd ../build/ && make -j ExternalIntegrationExample.SettingsRegistry |
3 changes: 3 additions & 0 deletions
3
...xternalIntegrationExample/ExternalIntegrationExample.SettingsRegistry/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ExternalIntegrationExample.SettingsRegistry | ||
|
||
[This directory](./#mlos-github-tree-view) contains the *SettingsRegistry* definitions and build configuration files for the [`ExternalIntegrationExample`](../) project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ | |
<!--Rule Id="CS1591" Action="Hidden" /--> | ||
</Rules> | ||
</RuleSet> | ||
|
||
|
Oops, something went wrong.