diff --git a/.github/scripts/cmake.bat b/.github/scripts/cmake.bat new file mode 100644 index 00000000000..efe3663fc5f --- /dev/null +++ b/.github/scripts/cmake.bat @@ -0,0 +1,5 @@ +cmake .. -DTorch_DIR="%1"^ + -DWITH_CUDA=%2^ + -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%"^ + -DCMAKE_FIND_FRAMEWORK=NEVER^ + -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%" diff --git a/.github/scripts/cmake.sh b/.github/scripts/cmake.sh index ef3e5f61dad..0f46b838988 100755 --- a/.github/scripts/cmake.sh +++ b/.github/scripts/cmake.sh @@ -65,19 +65,22 @@ echo '::endgroup::' echo '::group::Build and install libtorchvision' pushd cpp_build -# On macOS, CMake is looking for the library (*.dylib) and the header (*.h) separately. By default, it prefers to load -# the header from other packages that install the library. This easily leads to a mismatch if the library installed -# from conda doesn't have the exact same version. Thus, we need to explicitly set CMAKE_FIND_FRAMEWORK=NEVER to force -# it to not load anything from other installed frameworks. Resources: -# https://stackoverflow.com/questions/36523911/osx-homebrew-cmake-libpng-version-mismatch-issue -# https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_FRAMEWORK.html -cmake .. -DTorch_DIR="${Torch_DIR}" -DWITH_CUDA="${WITH_CUDA}" \ - -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ - -DCMAKE_FIND_FRAMEWORK=NEVER \ - -DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" if [[ $OS_TYPE == windows ]]; then + "${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PWD}/.github/scripts/cmake.bat" $Torch_DIR $WITH_CUDA "${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_cmake.bat" $JOBS else + # On macOS, CMake is looking for the library (*.dylib) and the header (*.h) separately. By default, it prefers to load + # the header from other packages that install the library. This easily leads to a mismatch if the library installed + # from conda doesn't have the exact same version. Thus, we need to explicitly set CMAKE_FIND_FRAMEWORK=NEVER to force + # it to not load anything from other installed frameworks. Resources: + # https://stackoverflow.com/questions/36523911/osx-homebrew-cmake-libpng-version-mismatch-issue + # https://cmake.org/cmake/help/latest/variable/CMAKE_FIND_FRAMEWORK.html + cmake .. -DTorch_DIR="${Torch_DIR}" \ + -DWITH_CUDA="${WITH_CUDA}" \ + -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ + -DCMAKE_FIND_FRAMEWORK=NEVER \ + -DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" + make -j$JOBS make install fi @@ -88,14 +91,16 @@ echo '::endgroup::' echo '::group::Build and run project that uses Faster-RCNN' pushd test/tracing/frcnn/build -cmake .. -DTorch_DIR="${Torch_DIR}" -DWITH_CUDA="${WITH_CUDA}" \ - -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ - -DCMAKE_FIND_FRAMEWORK=NEVER if [[ $OS_TYPE == windows ]]; then + "${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PWD}/.github/scripts/cmake.bat" $Torch_DIR $WITH_CUDA "${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_frcnn.bat" $JOBS cd Release cp ../fasterrcnn_resnet50_fpn.pt . else + cmake .. -DTorch_DIR="${Torch_DIR}" -DWITH_CUDA="${WITH_CUDA}" \ + -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ + -DCMAKE_FIND_FRAMEWORK=NEVER + make -j$JOBS fi @@ -107,14 +112,16 @@ echo '::endgroup::' echo '::group::Build and run C++ example' pushd examples/cpp/hello_world/build -cmake .. -DTorch_DIR="${Torch_DIR}" \ - -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ - -DCMAKE_FIND_FRAMEWORK=NEVER if [[ $OS_TYPE == windows ]]; then + "${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PWD}/.github/scripts/cmake.bat" $Torch_DIR $WITH_CUDA "${PACKAGING_DIR}/windows/internal/vc_env_helper.bat" "${PACKAGING_DIR}/windows/internal/build_cpp_example.bat" $JOBS cd Release cp ../resnet18.pt . else + cmake .. -DTorch_DIR="${Torch_DIR}" \ + -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \ + -DCMAKE_FIND_FRAMEWORK=NEVER + make -j$JOBS fi