[clblas] 114/125: build gtest with an external project

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Fri May 29 06:57:28 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository clblas.

commit 14fbe240a173a718cc07ea078cc3025da5fe5f55
Author: Gaëtan Lehmann <gaetan.lehmann at gmail.com>
Date:   Sat Mar 21 09:18:03 2015 +0100

    build gtest with an external project
---
 .travis.yml        | 10 +------
 src/CMakeLists.txt |  2 +-
 src/gtest.cmake    | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 10 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 33f44b5..811f85a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,18 +5,10 @@ compiler:
 
 before_install:
   - sudo apt-get update -qq
-  - sudo apt-get install -qq fglrx opencl-headers libboost-program-options-dev libgtest-dev
+  - sudo apt-get install -qq fglrx opencl-headers libboost-program-options-dev
 # Uncomment below to help verify the installs above work
 #  - ls -la /usr/lib/libboost*
 #  - ls -la /usr/include/boost
-#  - ls -la /usr/src/gtest
-
-install:
-  - mkdir -p bin/gTest
-  - cd bin/gTest
-  - cmake -DCMAKE_BUILD_TYPE=Release /usr/src/gtest
-  - make
-  - sudo mv libg* /usr/lib
 
 before_script:
   - cd ${TRAVIS_BUILD_DIR}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a23cd37..6e2c9a9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -198,7 +198,7 @@ endif( )
 find_package( OpenCL )
 
 # Find Google Test package
-find_package( GTest )
+include(gtest.cmake)
 
 # Find Boost on the system, and configure the type of boost build we want
 set( Boost_USE_MULTITHREADED ON )
diff --git a/src/gtest.cmake b/src/gtest.cmake
new file mode 100644
index 0000000..3661721
--- /dev/null
+++ b/src/gtest.cmake
@@ -0,0 +1,79 @@
+
+option(USE_SYSTEM_GTEST "Use system installed gtest when set to ON, or build gtest locally when set to OFF" OFF)
+
+if(USE_SYSTEM_GTEST)
+  if( (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8) )
+    message( STATUS "Cmake version 2.8 or greater needed to use GTest" )
+  else()
+    # This will define GTEST_FOUND
+    find_package( GTest )
+  endif()
+else()
+  if(CMAKE_VERSION VERSION_LESS 3.2 AND CMAKE_GENERATOR MATCHES "Ninja")
+    message(WARNING "Building GTest with Ninja has known issues with CMake older than 3.2")
+  endif()
+
+  include(ExternalProject)
+
+  set(GTEST_LIBRARIES gtest gtest_main)
+  # the binary dir must be know before creating the external project in order
+  # to pass the byproducts
+  set(prefix "${CMAKE_CURRENT_BINARY_DIR}/gtest-external-prefix")
+  set(binary_dir "${prefix}/src/gtest-external-build")
+
+  set(byproducts)
+  foreach(lib ${GTEST_LIBRARIES})
+    set(${lib}_location
+      ${binary_dir}/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
+    list(APPEND byproducts ${${lib}_location})
+  endforeach()
+
+  if( MSVC )
+	if( MSVC_VERSION LESS 1800 )  
+      set(EXTRA_FLAG "/D_VARIADIC_MAX=10 ")
+	else()
+	  set(EXTRA_FLAG "")
+	endif()
+  else()
+    set(EXTRA_FLAG "")
+  endif()
+  
+  ExternalProject_Add(
+    gtest-external
+    URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
+    URL_MD5 2d6ec8ccdf5c46b05ba54a9fd1d130d7
+    PREFIX ${prefix}
+    BINARY_DIR ${binary_dir}
+    CMAKE_CACHE_ARGS
+      -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
+      -DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
+      -DCMAKE_CXX_FLAGS_DEBUG:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_DEBUG}
+      -DCMAKE_CXX_FLAGS_MINSIZEREL:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_MINSIZEREL}
+      -DCMAKE_CXX_FLAGS_RELEASE:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_RELEASE}
+      -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=${EXTRA_FLAG}${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
+      -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
+      -DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
+      -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
+      -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
+      -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
+      -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_C_FLAGS_RELWITHDEBINFO}
+      -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
+      -Dgtest_force_shared_crt:BOOL=ON
+    BUILD_BYPRODUCTS ${byproducts}
+    INSTALL_COMMAND "")
+
+  foreach(lib ${GTEST_LIBRARIES})
+    add_library(${lib} IMPORTED STATIC)
+    add_dependencies(${lib} gtest-external)
+    set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${${lib}_location})
+  endforeach()
+
+  ExternalProject_Get_Property(gtest-external source_dir)
+  set(GTEST_INCLUDE_DIRS ${source_dir}/include)
+  set(GTEST_FOUND ON)
+endif()
+
+# Hack to get googletest v1.6 to work with vs2012
+if( MSVC11 )
+  add_definitions( "/D_VARIADIC_MAX=10" )
+endif( )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/clblas.git



More information about the debian-science-commits mailing list