Fix FindGMock.cmake and the CMake modules installation. (#112)

master
Wolfgang Hess 2016-10-28 15:43:13 +02:00 committed by GitHub
parent b94880c56e
commit 1081473be9
2 changed files with 19 additions and 13 deletions

View File

@ -319,7 +319,13 @@ function(google_proto_library NAME)
endfunction() endfunction()
macro(google_initialize_cartographer_project) macro(google_initialize_cartographer_project)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) if(CARTOGRAPHER_CMAKE_DIR)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CARTOGRAPHER_CMAKE_DIR}/modules)
else()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
endif()
set(GOOG_CXX_FLAGS "-pthread -std=c++11 ${GOOG_CXX_FLAGS}") set(GOOG_CXX_FLAGS "-pthread -std=c++11 ${GOOG_CXX_FLAGS}")
google_add_flag(GOOG_CXX_FLAGS "-Wall") google_add_flag(GOOG_CXX_FLAGS "-Wall")

View File

@ -30,6 +30,16 @@ find_library(GMOCK_LIBRARIES
/usr /usr
) )
# Find system-wide gtest header.
find_path(GTEST_INCLUDE_DIRS gtest/gtest.h
HINTS
ENV GTEST_DIR
PATH_SUFFIXES include
PATHS
/usr
)
list(APPEND GMOCK_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS})
if(NOT GMOCK_LIBRARIES) if(NOT GMOCK_LIBRARIES)
# If no system-wide gmock found, then find src version. # If no system-wide gmock found, then find src version.
# Ubuntu might have this. # Ubuntu might have this.
@ -43,26 +53,16 @@ if(NOT GMOCK_LIBRARIES)
if(GMOCK_SRC_DIR) if(GMOCK_SRC_DIR)
# If src version found, build it. # If src version found, build it.
add_subdirectory(${GMOCK_SRC_DIR}/gmock "${CMAKE_CURRENT_BINARY_DIR}/gmock") add_subdirectory(${GMOCK_SRC_DIR}/gmock "${CMAKE_CURRENT_BINARY_DIR}/gmock")
set(GMOCK_INCLUDE_DIRS "${GMOCK_SRC_DIR}/gmock/gtest/include")
set(GMOCK_LIBRARIES gmock_main) set(GMOCK_LIBRARIES gmock_main)
endif() endif()
endif() endif()
# Find gtest header.
# It is contained in gmock src dir in Ubuntu environment.
find_path(GTEST_INCLUDE_DIRS gtest/gtest.h
HINTS
ENV GTEST_DIR
PATH_SUFFIXES include
PATHS
/usr ${GMOCK_SRC_DIR}/gmock/gtest
)
list(APPEND GMOCK_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS})
# System-wide installed gmock library might require pthreads. # System-wide installed gmock library might require pthreads.
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
list(APPEND GMOCK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) list(APPEND GMOCK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GMock DEFAULT_MSG GMOCK_LIBRARIES find_package_handle_standard_args(GMock DEFAULT_MSG GMOCK_LIBRARIES
GMOCK_INCLUDE_DIRS GTEST_INCLUDE_DIRS) GMOCK_INCLUDE_DIRS)