Skip to content

Commit

Permalink
fix: update task for new cross-compile with project_options
Browse files Browse the repository at this point in the history
  • Loading branch information
furudbat committed Dec 29, 2022
1 parent c9bb00b commit 64eff67
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
24 changes: 18 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@ cmake_minimum_required(VERSION 3.16)
# If commented, the latest supported standard for your compiler is automatically set.
# set(CMAKE_CXX_STANDARD 20)

# Add project_options v0.26.2

# Add project_options
# https://github.com/aminya/project_options
# Change the version in the following URL to update the package (watch the releases of the repository for future updates)
include(FetchContent)
FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.26.2.zip)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)
# Change the version to update the package (watch the releases of the repository for future updates)
include(cmake/CPM.cmake)
CPMAddPackage(
NAME project_options
GITHUB_REPOSITORY aminya/project_options
#VERSION 0.26.3
GIT_TAG main
DOWNLOAD_ONLY
)
if(project_options_ADDED)
include(${project_options_SOURCE_DIR}/Index.cmake)
endif()

# Define the features of the project
include("./Features.cmake")

# enable cross-compiling: - should be called before run_vcpkg()
if(ENABLE_CROSS_COMPILING)
enable_cross_compiler()
endif()
# install vcpkg dependencies: - should be called before defining project()
run_vcpkg()

Expand Down
2 changes: 2 additions & 0 deletions Features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ option(FEATURE_DOCS "Enable the docs" OFF)

# fuzz tests
option(FEATURE_FUZZ_TESTS "Enable the fuzz tests" OFF)

option(ENABLE_CROSS_COMPILING "Detect cross compiler and setup toolchain" OFF)
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ tasks:
FEATURE_TESTS: OFF
CMAKE_BUILD_TYPE: Debug

cross_build_mingw:
build_cross_mingw:
- task: build_template
vars:
FEATURE_TESTS: OFF
CMAKE_BUILD_TYPE: Release
CONFIGURE_FLAGS: -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="/home/cmake/toolchains/x86_64-w64-mingw32.toolchain.cmake" -DVCPKG_TARGET_TRIPLET="x64-mingw-dynamic"
CONFIGURE_FLAGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DDEFAULT_TRIPLET=x64-mingw-dynamic

install:
- task: build
Expand Down
21 changes: 21 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set(CPM_DOWNLOAD_VERSION 0.35.0)

if(CPM_SOURCE_CACHE)
# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_SOURCE_CACHE ${CPM_SOURCE_CACHE} ABSOLUTE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION}
)
endif()

include(${CPM_DOWNLOAD_LOCATION})

0 comments on commit 64eff67

Please sign in to comment.