diff --git a/.github/workflows/vcpkg.yml b/.github/workflows/vcpkg.yml index 5cd050166..8217bd09a 100644 --- a/.github/workflows/vcpkg.yml +++ b/.github/workflows/vcpkg.yml @@ -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: @@ -46,6 +46,21 @@ jobs: ninja --version clang --version + - name: Install dependencies (Windows) + if: runner.os == 'Windows' + uses: microsoft/setup-msbuild@v1.0.2 + + - 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: diff --git a/CMakeLists.txt b/CMakeLists.txt index ae205833e..8760bb9b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,7 @@ if(BUILD_TESTS OR OPENMIND_BUILD_TESTS OR _IS_DEBUG OR NOT CMAKE_BUILD_TYPE) endif() list(REMOVE_DUPLICATES _BOOST_USED_COMPONENTS) set(BOOST_USED_COMPONENTS ${_BOOST_USED_COMPONENTS} CACHE STRING "Components" FORCE) +set(_BOOST_USED_COMPONENTS ${BOOST_USED_COMPONENTS} CACHE STRING "Components" FORCE) if(OPENMIND_BUILD_GC) add_definitions(-DOPENMIND_BUILD_GC) @@ -236,18 +237,30 @@ 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() + endif() + if (NOT Boost_FOUND) + 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} + ) + endif() + endif () +endif () add_custom_target(prerequisites) set_target_properties(prerequisites PROPERTIES FOLDER "util") @@ -289,7 +302,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() @@ -385,11 +398,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} diff --git a/cmake/bins.cmake b/cmake/bins.cmake index 02feefec0..a6721aa43 100644 --- a/cmake/bins.cmake +++ b/cmake/bins.cmake @@ -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() diff --git a/cmake/vcpkg.cmake b/cmake/vcpkg.cmake index 0bd75ca62..6208f2fa3 100644 --- a/cmake/vcpkg.cmake +++ b/cmake/vcpkg.cmake @@ -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}) @@ -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() @@ -59,6 +68,8 @@ endmacro() if(NOT VCPKG_FOUND) find_vcpkg() +else() + #prepend_toolchain_file() endif() option(OPENMIND_USE_VCPKG "Use vcpkg" ${VCPKG_FOUND}) @@ -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() diff --git a/omnn/storage/CMakeLists.txt b/omnn/storage/CMakeLists.txt index 2eca949ef..a193825ed 100644 --- a/omnn/storage/CMakeLists.txt +++ b/omnn/storage/CMakeLists.txt @@ -1,7 +1,7 @@ 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) @@ -9,15 +9,15 @@ if(OPENMIND_STORAGE_LEVELDB OR OPENMIND_STORAGE_FOUNDATIONDB) 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)