Skip to content

Commit

Permalink
feat: add CPM.cmake (#195)
Browse files Browse the repository at this point in the history
Non-breaking, adds CPM as an alternative to vcpkg via additional build
presets.

Closes #189
  • Loading branch information
ThirdEyeSqueegee authored Oct 24, 2023
1 parent 70a77d3 commit d2dd993
Show file tree
Hide file tree
Showing 10 changed files with 1,344 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
uses: lukka/[email protected]
with:
cmakeListsTxtPath: "${{ github.workspace }}/CommonLibSF/CMakeLists.txt"
configurePreset: build-release-${{ matrix.compiler }}-ninja
configurePreset: build-release-${{ matrix.compiler }}-ninja-vcpkg
configurePresetCmdString: "[`-B`, `$[env.GITHUB_WORKSPACE]/build`, `-S`, `$[env.GITHUB_WORKSPACE]/CommonLibSF`, `--preset`, `$[env.CONFIGURE_PRESET_NAME]`]"
buildPreset: release-${{ matrix.compiler }}-ninja
buildPreset: release-${{ matrix.compiler }}-ninja-vcpkg
buildPresetCmdString: "[`--build`, `$[env.GITHUB_WORKSPACE]/build`, `--preset`, `$[env.BUILD_PRESET_NAME]`]"
4 changes: 2 additions & 2 deletions .github/workflows/update_pdb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
uses: lukka/[email protected]
with:
cmakeListsTxtPath: "${{ github.workspace }}/CommonLibSF/CMakeLists.txt"
configurePreset: build-debug-msvc-ninja
configurePreset: build-debug-msvc-ninja-vcpkg
configurePresetCmdString: "[`-B`, `$[env.GITHUB_WORKSPACE]/build`, `-S`, `$[env.GITHUB_WORKSPACE]/CommonLibSF`, `--preset`, `$[env.CONFIGURE_PRESET_NAME]`]"
buildPreset: debug-msvc-ninja
buildPreset: debug-msvc-ninja-vcpkg
buildPresetCmdString: "[`--build`, `$[env.GITHUB_WORKSPACE]/build`, `--preset`, `$[env.BUILD_PRESET_NAME]`]"

- name: Find PDB
Expand Down
43 changes: 32 additions & 11 deletions CommonLibSF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
endif()

# dependencies
find_package(spdlog CONFIG REQUIRED)
if(USING_VCPKG)
find_package(spdlog CONFIG REQUIRED)
else()
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake")

CPMAddPackage(
GITHUB_REPOSITORY gabime/spdlog
VERSION 1.12.0
OPTIONS "SPDLOG_USE_STD_FORMAT ON"
)
endif()

# source files
execute_process(
Expand Down Expand Up @@ -125,13 +135,17 @@ target_link_libraries(
)

if(SFSE_SUPPORT_XBYAK)
find_package(xbyak CONFIG REQUIRED)
if(USING_VCPKG)
find_package(xbyak CONFIG REQUIRED)
else()
CPMAddPackage("gh:herumi/[email protected]")
endif()

target_link_libraries(
${PROJECT_NAME}
PUBLIC
xbyak::xbyak
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
xbyak::xbyak
)
endif()

target_precompile_headers(
Expand All @@ -140,10 +154,17 @@ target_precompile_headers(
include/SFSE/Impl/PCH.h
)

install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
)
if(USING_VCPKG)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
)
else()
install(
TARGETS ${PROJECT_NAME} spdlog
EXPORT ${PROJECT_NAME}-targets
)
endif()

install(
EXPORT ${PROJECT_NAME}-targets
Expand Down
181 changes: 148 additions & 33 deletions CommonLibSF/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows-static-md",
"VCPKG_HOST_TRIPLET": "x64-windows-static-md"
"VCPKG_HOST_TRIPLET": "x64-windows-static-md",
"USING_VCPKG": true
}
},
{
Expand Down Expand Up @@ -103,7 +104,7 @@
}
},
{
"name": "build-debug-msvc-msvc",
"name": "build-debug-msvc-msvc-vcpkg",
"inherits": [
"common",
"packaging-vcpkg",
Expand All @@ -113,7 +114,7 @@
]
},
{
"name": "build-debug-msvc-ninja",
"name": "build-debug-msvc-ninja-vcpkg",
"inherits": [
"common",
"packaging-vcpkg",
Expand All @@ -123,7 +124,7 @@
]
},
{
"name": "build-debug-clang-cl-msvc",
"name": "build-debug-clang-cl-msvc-vcpkg",
"toolset": "ClangCL",
"inherits": [
"common",
Expand All @@ -134,7 +135,7 @@
]
},
{
"name": "build-debug-clang-cl-ninja",
"name": "build-debug-clang-cl-ninja-vcpkg",
"inherits": [
"common",
"packaging-vcpkg",
Expand All @@ -144,7 +145,7 @@
]
},
{
"name": "build-release-msvc-msvc",
"name": "build-release-msvc-msvc-vcpkg",
"inherits": [
"common",
"packaging-vcpkg",
Expand All @@ -154,7 +155,7 @@
]
},
{
"name": "build-release-msvc-ninja",
"name": "build-release-msvc-ninja-vcpkg",
"inherits": [
"common",
"packaging-vcpkg",
Expand All @@ -164,7 +165,7 @@
]
},
{
"name": "build-release-clang-cl-msvc",
"name": "build-release-clang-cl-msvc-vcpkg",
"toolset": "ClangCL",
"inherits": [
"common",
Expand All @@ -175,56 +176,170 @@
]
},
{
"name": "build-release-clang-cl-ninja",
"name": "build-release-clang-cl-ninja-vcpkg",
"inherits": [
"common",
"packaging-vcpkg",
"buildtype-release-clang-cl",
"generator-ninja",
"compiler-clang-cl"
]
},
{
"name": "build-debug-msvc-msvc-cpm",
"inherits": [
"common",
"buildtype-debug-msvc",
"generator-msvc",
"compiler-msvc"
]
},
{
"name": "build-debug-msvc-ninja-cpm",
"inherits": [
"common",
"buildtype-debug-msvc",
"generator-ninja",
"compiler-msvc"
]
},
{
"name": "build-debug-clang-cl-msvc-cpm",
"toolset": "ClangCL",
"inherits": [
"common",
"buildtype-debug-clang-cl",
"generator-msvc",
"compiler-clang-cl"
]
},
{
"name": "build-debug-clang-cl-ninja-cpm",
"inherits": [
"common",
"buildtype-debug-clang-cl",
"generator-ninja",
"compiler-clang-cl"
]
},
{
"name": "build-release-msvc-msvc-cpm",
"inherits": [
"common",
"buildtype-release-msvc",
"generator-msvc",
"compiler-msvc"
]
},
{
"name": "build-release-msvc-ninja-cpm",
"inherits": [
"common",
"buildtype-release-msvc",
"generator-ninja",
"compiler-msvc"
]
},
{
"name": "build-release-clang-cl-msvc-cpm",
"toolset": "ClangCL",
"inherits": [
"common",
"buildtype-release-clang-cl",
"generator-msvc",
"compiler-clang-cl"
]
},
{
"name": "build-release-clang-cl-ninja-cpm",
"inherits": [
"common",
"buildtype-release-clang-cl",
"generator-ninja",
"compiler-clang-cl"
]
}
],
"buildPresets": [
{
"name": "debug-msvc-ninja",
"configurePreset": "build-debug-msvc-ninja",
"displayName": "1. (Debug) MSVC - Ninja"
"name": "debug-msvc-ninja-vcpkg",
"configurePreset": "build-debug-msvc-ninja-vcpkg",
"displayName": "01. (Debug) MSVC - Ninja - vcpkg"
},
{
"name": "release-msvc-ninja-vcpkg",
"configurePreset": "build-release-msvc-ninja-vcpkg",
"displayName": "02. (Release) MSVC - Ninja - vcpkg"
},
{
"name": "debug-msvc-msvc-vcpkg",
"configurePreset": "build-debug-msvc-msvc-vcpkg",
"displayName": "03. (Debug) MSVC - MSVC - vcpkg"
},
{
"name": "release-msvc-msvc-vcpkg",
"configurePreset": "build-release-msvc-msvc-vcpkg",
"displayName": "04. (Release) MSVC - MSVC - vcpkg"
},
{
"name": "debug-clang-cl-ninja-vcpkg",
"configurePreset": "build-debug-clang-cl-ninja-vcpkg",
"displayName": "05. (Debug) Clang - Ninja - vcpkg"
},
{
"name": "release-clang-cl-ninja-vcpkg",
"configurePreset": "build-release-clang-cl-ninja-vcpkg",
"displayName": "06. (Release) Clang - Ninja - vcpkg"
},
{
"name": "debug-clang-cl-msvc-vcpkg",
"configurePreset": "build-debug-clang-cl-msvc-vcpkg",
"displayName": "07. (Debug) Clang - MSVC - vcpkg"
},
{
"name": "release-clang-cl-msvc-vcpkg",
"configurePreset": "build-release-clang-cl-msvc-vcpkg",
"displayName": "08. (Release) Clang - MSVC - vcpkg"
},
{
"name": "debug-msvc-ninja-cpm",
"configurePreset": "build-debug-msvc-ninja-cpm",
"displayName": "09. (Debug) MSVC - Ninja - CPM"
},
{
"name": "release-msvc-ninja",
"configurePreset": "build-release-msvc-ninja",
"displayName": "2. (Release) MSVC - Ninja"
"name": "release-msvc-ninja-cpm",
"configurePreset": "build-release-msvc-ninja-cpm",
"displayName": "10. (Release) MSVC - Ninja - CPM"
},
{
"name": "debug-msvc-msvc",
"configurePreset": "build-debug-msvc-msvc",
"displayName": "3. (Debug) MSVC - MSVC"
"name": "debug-msvc-msvc-cpm",
"configurePreset": "build-debug-msvc-msvc-cpm",
"displayName": "11. (Debug) MSVC - MSVC - CPM"
},
{
"name": "release-msvc-msvc",
"configurePreset": "build-release-msvc-msvc",
"displayName": "4. (Release) MSVC - MSVC"
"name": "release-msvc-msvc-cpm",
"configurePreset": "build-release-msvc-msvc-cpm",
"displayName": "12. (Release) MSVC - MSVC - CPM"
},
{
"name": "debug-clang-cl-ninja",
"configurePreset": "build-debug-clang-cl-ninja",
"displayName": "5. (Debug) Clang - Ninja"
"name": "debug-clang-cl-ninja-cpm",
"configurePreset": "build-debug-clang-cl-ninja-cpm",
"displayName": "13. (Debug) Clang - Ninja - CPM"
},
{
"name": "release-clang-cl-ninja",
"configurePreset": "build-release-clang-cl-ninja",
"displayName": "6. (Release) Clang - Ninja"
"name": "release-clang-cl-ninja-cpm",
"configurePreset": "build-release-clang-cl-ninja-cpm",
"displayName": "14. (Release) Clang - Ninja - CPM"
},
{
"name": "debug-clang-cl-msvc",
"configurePreset": "build-debug-clang-cl-msvc",
"displayName": "7. (Debug) Clang - MSVC"
"name": "debug-clang-cl-msvc-cpm",
"configurePreset": "build-debug-clang-cl-msvc-cpm",
"displayName": "15. (Debug) Clang - MSVC - CPM"
},
{
"name": "release-clang-cl-msvc",
"configurePreset": "build-release-clang-cl-msvc",
"displayName": "8. (Release) Clang - MSVC"
"name": "release-clang-cl-msvc-cpm",
"configurePreset": "build-release-clang-cl-msvc-cpm",
"displayName": "16. (Release) Clang - MSVC - CPM"
}
]
}
Loading

0 comments on commit d2dd993

Please sign in to comment.