Skip to content

Commit

Permalink
EHN: make Google test a static build, refer to ISSUE openigtlink#122.
Browse files Browse the repository at this point in the history
  • Loading branch information
leochan2009 committed Feb 27, 2017
1 parent 90fb1b3 commit 895e412
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 15 additions & 6 deletions Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,19 @@ IF(OpenIGTLink_USE_GTEST)
# Add googletest directly to our build. This adds
# the following targets: gtest, gtest_main, gmock
# and gmock_main
add_subdirectory("${PROJECT_BINARY_DIR}/gmock"
"${PROJECT_BINARY_DIR}/gmock-build" )

execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" "-DBUILD_SHARED_LIBS:BOOL=OFF" .
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/gmock" )
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/gmock" )
execute_process(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" "-DBUILD_SHARED_LIBS:BOOL=OFF" .
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/gtest" )
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/gtest" )
# The gtest/gmock targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
include_directories("${gtest_SOURCE_DIR}/include")
include_directories("${gmock_SOURCE_DIR}/include")
include_directories("${PROJECT_BINARY_DIR}/gtest/include")
include_directories("${PROJECT_BINARY_DIR}/gmock/include")
#---------------
ENDIF()

Expand Down Expand Up @@ -89,7 +94,11 @@ ENDIF()


IF(USE_GTEST)
SET(GTEST_LINK OpenIGTLink gtest_main gtest gmock_main gmock)
IF(OpenIGTLink_PLATFORM_WIN32) # for Windows
SET(GTEST_LINK OpenIGTLink "${PROJECT_BINARY_DIR}/gtest/${CMAKE_CFG_INTDIR}/gtest_main.lib" "${PROJECT_BINARY_DIR}/gtest/${CMAKE_CFG_INTDIR}/gtest.lib" "${PROJECT_BINARY_DIR}/gmock/${CMAKE_CFG_INTDIR}/gmock_main.lib" "${PROJECT_BINARY_DIR}/gmock/${CMAKE_CFG_INTDIR}/gmock.lib")
ELSE() # for POSIX-compatible OSs
SET(GTEST_LINK OpenIGTLink "${PROJECT_BINARY_DIR}/gtest/${CMAKE_CFG_INTDIR}/libgtest_main.a" "${PROJECT_BINARY_DIR}/gtest/${CMAKE_CFG_INTDIR}/libgtest.a" "${PROJECT_BINARY_DIR}/gmock/${CMAKE_CFG_INTDIR}/libgmock_main.a" "${PROJECT_BINARY_DIR}/gmock/${CMAKE_CFG_INTDIR}/libgmock.a")
ENDIF()
ELSE()
SET(GTEST_LINK OpenIGTLink)
ENDIF()
Expand Down
4 changes: 2 additions & 2 deletions Testing/CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ExternalProject_Add(googletest
#GIT_REPOSITORY https://github.com/google/googletest.git
#GIT_TAG master
SOURCE_DIR "${PROJECT_BINARY_DIR}/gtest"
BINARY_DIR "${PROJECT_BINARY_DIR}/gtest-build"
BINARY_DIR ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand All @@ -17,7 +17,7 @@ ExternalProject_Add(googletest
ExternalProject_Add(googlemock
URL https://github.com/google/googlemock/archive/release-1.7.0.zip
SOURCE_DIR "${PROJECT_BINARY_DIR}/gmock"
BINARY_DIR "${PROJECT_BINARY_DIR}/gmock-build"
BINARY_DIR ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
Expand Down

0 comments on commit 895e412

Please sign in to comment.