Skip to content

Commit

Permalink
Build gtest from source in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenlau committed Oct 21, 2020
1 parent 22d822a commit 7a14938
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- conda install gtest cmake -c conda-forge
- conda install cmake -c conda-forge
- conda install xtensor=0.21.4 -c conda-forge
- conda install m2w64-openblas -c msys2
# Patch OpenBLASConfig.cmake
- ps: (Get-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake).replace('mingw64', 'mingw-w64') | Set-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake
- ps: (Get-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake).replace('mingw32', 'mingw-w64') | Set-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake
- ps: (Get-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake).replace('bin', 'lib') | Set-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake
- ps: (Get-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake).replace('dll', 'dll.a') | Set-Content $Env:MINICONDA\Library\mingw-w64\lib\cmake\openblas\OpenBLASConfig.cmake
- cmake -G "NMake Makefiles" -DOpenBLAS_DIR=%MINICONDA%\Library\mingw-w64\lib\cmake\openblas -DCMAKE_INSTALL_PREFIX=%MINICONDA%\Library -DBUILD_TESTS=ON .
- cmake -G "NMake Makefiles" -DOpenBLAS_DIR=%MINICONDA%\Library\mingw-w64\lib\cmake\openblas -DCMAKE_INSTALL_PREFIX=%MINICONDA%\Library -DBUILD_TESTS=ON -DDOWNLOAD_GTEST=ON .
- nmake test_xtensor_blas
- cd test

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
# Note: conda activate doesn't work here, because it creates a new shell!
- script: |
conda install cmake==3.14.0 ^
gtest==1.10.0 ^
mkl-devel ^
ninja ^
xtensor=0.21.4 ^
Expand All @@ -66,6 +65,7 @@ jobs:
-DCMAKE_C_COMPILER=clang-cl ^
-DCMAKE_CXX_COMPILER=clang-cl ^
-DBUILD_TESTS=ON ^
-DDOWNLOAD_GTEST=ON ^
$(Build.SourcesDirectory)
displayName: "Configure xtensor-blas"
workingDirectory: $(Build.BinariesDirectory)
Expand Down
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} -march=native -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast -Wunused-variable")
else() # We are using clang-cl
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /EHsc /MP /bigobj")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_cxx_std_flag} /EHsc /MP /bigobj -Wno-unused-command-line-argument")
set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
Expand Down Expand Up @@ -71,6 +71,8 @@ if(DOWNLOAD_GTEST OR GTEST_SRC_DIR)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
Expand Down

0 comments on commit 7a14938

Please sign in to comment.