From a7edafc4bf653c05444939c5fd6dc5482f6a51cb Mon Sep 17 00:00:00 2001 From: liaogang Date: Thu, 18 May 2017 00:34:43 +0800 Subject: [PATCH] add cc_test --- cmake/CMakeDetermineGoCompiler.cmake | 10 ++++++---- cmake/generic.cmake | 5 +++-- paddle/CMakeLists.txt | 2 +- paddle/go/CMakeLists.txt | 14 +++++--------- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/cmake/CMakeDetermineGoCompiler.cmake b/cmake/CMakeDetermineGoCompiler.cmake index b3f8fbe271d..9196880c0ec 100644 --- a/cmake/CMakeDetermineGoCompiler.cmake +++ b/cmake/CMakeDetermineGoCompiler.cmake @@ -28,10 +28,12 @@ if(NOT CMAKE_Go_COMPILER) NAMES go PATHS ${Go_BIN_PATH} ) - EXEC_PROGRAM(${CMAKE_Go_COMPILER} ARGS version OUTPUT_VARIABLE GOLANG_VERSION) - STRING(REGEX MATCH "go[0-9]+.[0-9]+.[0-9]+[ /A-Za-z0-9]*" VERSION "${GOLANG_VERSION}") - message("-- The Golang compiler identification is ${VERSION}") - message("-- Check for working Golang compiler: ${CMAKE_Go_COMPILER}") + if(CMAKE_Go_COMPILER) + EXEC_PROGRAM(${CMAKE_Go_COMPILER} ARGS version OUTPUT_VARIABLE GOLANG_VERSION) + STRING(REGEX MATCH "go[0-9]+[.0-9]*[ /A-Za-z0-9]*" VERSION "${GOLANG_VERSION}") + message("-- The Golang compiler identification is ${VERSION}") + message("-- Check for working Golang compiler: ${CMAKE_Go_COMPILER}") + endif() endif() endif() diff --git a/cmake/generic.cmake b/cmake/generic.cmake index 555faff499e..e4c1e2b41a1 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -163,8 +163,9 @@ function(go_library TARGET_NAME) WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) add_custom_target(${TARGET_NAME}_lib ALL DEPENDS ${TARGET_NAME}_timestamp ${go_library_DEPS}) add_library(${TARGET_NAME} STATIC IMPORTED) - set_target_properties(${TARGET_NAME} PROPERTIES - IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}) + set_property(TARGET ${TARGET_NAME} PROPERTY + IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}") + add_dependencies(${TARGET_NAME} ${TARGET_NAME}_lib) endfunction(go_library) function(go_binary TARGET_NAME) diff --git a/paddle/CMakeLists.txt b/paddle/CMakeLists.txt index 694ebb9ba04..cf31b4a3429 100644 --- a/paddle/CMakeLists.txt +++ b/paddle/CMakeLists.txt @@ -9,7 +9,7 @@ add_subdirectory(pserver) add_subdirectory(trainer) add_subdirectory(scripts) -if(${CMAKE_Go_COMPILER}) +if(CMAKE_Go_COMPILER) add_subdirectory(go) endif() diff --git a/paddle/go/CMakeLists.txt b/paddle/go/CMakeLists.txt index 482c948a516..20f14769433 100644 --- a/paddle/go/CMakeLists.txt +++ b/paddle/go/CMakeLists.txt @@ -2,12 +2,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}) go_library(adder SRCS adder.go) -# cc_test(cgo_test -# SRCS -# cgo_test.cc -# DEPS -# adder) -add_executable(cgo_test cgo_test.cc) -add_dependencies(cgo_test adder) -target_link_libraries(cgo_test ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} adder) -add_test(cgo_test cgo_test) +cc_test(cgo_test + SRCS + cgo_test.cc + DEPS + adder) -- GitLab