Skip to content

Commit

Permalink
CI: Windows build with vcpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhmm committed Sep 27, 2024
1 parent 80fb779 commit b39094c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 34 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/vcpkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -46,6 +46,21 @@ jobs:
ninja --version
clang --version
- name: Install dependencies (Windows)
if: runner.os == 'Windows'
uses: microsoft/[email protected]

- name: Setup MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Install CMake and Ninja (Windows)
if: runner.os == 'Windows'
run: |
choco install cmake ninja
cmake --version
ninja --version
- name: Setup vcpkg
uses: lukka/run-vcpkg@v11
with:
Expand Down
39 changes: 23 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,28 @@ elseif(OPENMIND_USE_CONAN)
endif()
endif()

find_package(Boost ${OPENMIND_PREFERRED_BOOST_VERSION}
CONFIG
HINTS C:/Boost
COMPONENTS ${BOOST_USED_COMPONENTS}
)
if(NOT Boost_FOUND)
find_package(Boost ${OPENMIND_REQUIRED_BOOST_VERSION}
CONFIG
HINTS C:/Boost
COMPONENTS ${BOOST_USED_COMPONENTS}
if (NOT Boost_FOUND)
if (OPENMIND_USE_VCPKG)
include(vcpkg)
unset(Boost_DIR CACHE)
unset(Boost_INCLUDE_DIR CACHE)
find_package(Boost CONFIG REQUIRED COMPONENTS ${BOOST_USED_COMPONENTS})
endif()
if (NOT Boost_FOUND)
find_package(Boost ${OPENMIND_PREFERRED_BOOST_VERSION}
CONFIG
HINTS C:/Boost
COMPONENTS ${BOOST_USED_COMPONENTS}
)
endif()
if(NOT Boost_FOUND)
find_package(Boost ${OPENMIND_REQUIRED_BOOST_VERSION}
CONFIG
HINTS C:/Boost
COMPONENTS ${BOOST_USED_COMPONENTS}
)
endif()
endif ()
endif ()
add_custom_target(prerequisites)
set_target_properties(prerequisites PROPERTIES FOLDER "util")

Expand Down Expand Up @@ -289,7 +299,7 @@ find_package(OpenMP)
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
#endif()

if (Boost_FOUND OR OPENMIND_USE_CONAN)
if (Boost_FOUND OR OPENMIND_USE_CONAN OR OPENMIND_USE_VCPKG)
if(NOT TARGET boost)
add_custom_target(boost)
endif()
Expand Down Expand Up @@ -385,11 +395,8 @@ if(NOT MSVC OR Boost_VERSION VERSION_LESS 1.80.0)
Boost::thread)
endif()
if(OPENMIND_USE_VCPKG)
set(BOOST_LINK_LIBS ${BOOST_LINK_LIBS}
Boost::headers
)
set(BOOST_TEST_LINK_LIBS ${BOOST_LINK_LIBS}
Boost::test
Boost::unit_test_framework
)
else()
set(BOOST_TEST_LINK_LIBS ${BOOST_LINK_LIBS}
Expand Down
2 changes: 1 addition & 1 deletion cmake/bins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ macro(exe)
${BOOST_LINK_LIBS}
tbb
)
elseif(OPENMIND_USE_CONAN)
elseif(OPENMIND_USE_CONAN OR OPENMIND_USE_VCPKG)
deps(${BOOST_LINK_LIBS})
endif()

Expand Down
25 changes: 13 additions & 12 deletions cmake/vcpkg.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@

function(prepend_toolchain_file)
if(EXISTS ${CMAKE_TOOLCHAIN_FILE})
list(PREPEND CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_TOOLCHAIN_FILE}")
set(${CMAKE_PROJECT_TOP_LEVEL_INCLUDES} "${${CMAKE_PROJECT_TOP_LEVEL_INCLUDES}}" PARENT_SCOPE)
list(PREPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PROJECT_TOP_LEVEL_INCLUDES)
set(${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES} "${${CMAKE_TRY_COMPILE_PLATFORM_VARIABLES}}" PARENT_SCOPE)
endif()
endfunction()

macro(find_vcpkg)
if(NOT EXISTS ${CMAKE_TOOLCHAIN_FILE})
if(NOT EXISTS ${VCPKG_EXECUTABLE})
Expand All @@ -19,8 +29,7 @@ macro(find_vcpkg)

if(EXISTS ${CMAKE_TOOLCHAIN_FILE})
set(VCPKG_FOUND TRUE CACHE BOOL "VCPKG toolchain file found ${CMAKE_TOOLCHAIN_FILE}" FORCE)
list(PREPEND CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_TOOLCHAIN_FILE}")
list(PREPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_PROJECT_TOP_LEVEL_INCLUDES)
prepend_toolchain_file()
else()
set(VCPKG_FOUND FALSE CACHE BOOL "VCPKG not found" FORCE)
endif()
Expand Down Expand Up @@ -59,6 +68,8 @@ endmacro()

if(NOT VCPKG_FOUND)
find_vcpkg()
else()
prepend_toolchain_file()
endif()

option(OPENMIND_USE_VCPKG "Use vcpkg" ${VCPKG_FOUND})
Expand All @@ -76,14 +87,4 @@ if(OPENMIND_USE_VCPKG)
if(NOT VCPKG_FOUND)
message(WARNING "Vcpkg not found")
endif()
if(VCPKG_EXECUTABLE)
execute_process(
COMMAND ${VCPKG_EXECUTABLE} install
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE VCPKG_RESULT
)
if(NOT VCPKG_RESULT EQUAL 0)
message(FATAL_ERROR "Failed to install dependencies using vcpkg")
endif()
endif()
endif()
8 changes: 4 additions & 4 deletions omnn/storage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
option(OPENMIND_STORAGE_FOUNDATIONDB "Use Apple FoundationDB library for one of the multistorage levels" OFF)
option(OPENMIND_STORAGE_LEVELDB "Use Google LevelDB library for one of the multistorage levels" ON)

set(DEPENDENCIES ${DEPENDENCIES} rt)
set(DEPENDENCIES rt)
if(OPENMIND_STORAGE_LEVELDB OR OPENMIND_STORAGE_FOUNDATIONDB)
option(OPENMIND_STORAGE_ALLOW_UPGRADE "Update optimized cached values during fetch if new optimizations applied" ON)
option(OPENMIND_STORAGE_VOLATILE "Clean cache each start (for debugging purposes)" OFF)


if(OPENMIND_STORAGE_LEVELDB)
find_package(Threads) # workaround leveldb config bug
set(DEPENDENCIES ${DEPENDENCIES} google/leveldb)
list(APPEND DEPENDENCIES google/leveldb)
if(NOT WIN32)
set(DEPENDENCIES ${DEPENDENCIES} pthread)
list(APPEND DEPENDENCIES pthread)
endif()
endif()

if(OPENMIND_STORAGE_FOUNDATIONDB)
add_definitions(-DOPENMIND_STORAGE_FOUNDATIONDB)
set(DEPENDENCIES ${DEPENDENCIES} ohhmm/FoundationDB)
list(APPEND DEPENDENCIES ohhmm/FoundationDB)
endif()

if(OPENMIND_STORAGE_ALLOW_UPGRADE)
Expand Down

0 comments on commit b39094c

Please sign in to comment.