这是我的项目的链接,以防万一。
所以,这是我的CMakeLists.txt
文件:
cmake_minimum_required (VERSION 2.6)
enable_testing()
project (IeiuniumTela)
set (IeiuniumTela_VERSION_MAJOR 1)
set (IeiuniumTela_VERSION_MINOR 0)
set (IeiuniumTela_VERSION_PATCH 0)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/bin)
# TODO: Make conditional for OS X compilation
set(CMAKE_CXX_COMPILER g++-4.7)
set(CMAKE_CC_COMPILER gcc-4.7)
# TODO: Require gcc >= 4.7
set(SOURCES "${SOURCES}" "${CMAKE_BINARY_DIR}/src/http/request.cpp")
set(SOURCES "${SOURCES}" "${CMAKE_BINARY_DIR}/src/http/response.cpp")
set(SOURCES "${SOURCES}" "${CMAKE_BINARY_DIR}/src/http/server.cpp")
set(SOURCES "${SOURCES}" "${CMAKE_BINARY_DIR}/src/log.cpp")
set(SOURCES "${SOURCES}" "${CMAKE_BINARY_DIR}/src/main.cpp")
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}")
add_executable(ieiunium_tela.srv ${SOURCES})
target_link_libraries(ieiunium_tela.srv yaml-cpp)
target_link_libraries(ieiunium_tela.srv boost_system-mt)
set(GTEST_DIR "${CMAKE_BINARY_DIR}/../gtest-1.6.0")
include_directories(SYSTEM "${GTEST_DIR}/include")
find_library(GTEST_LIBRARY
NAMES gtest
libgtest
libgtest.a
PATHS "${GTEST_DIR}")
find_library(GTEST_LIBRARY_MAIN
NAMES gtest_main
libgtest_main
libgtest.a
PATHS "${GTEST_DIR}")
set(GMOCK_DIR "${CMAKE_BINARY_DIR}/../gmock-1.6.0")
include_directories(SYSTEM "${GMOCK_DIR}/include")
include_directories(SYSTEM "${GMOCK_DIR}/gtest/include")
find_library(GMOCK_LIBRARY
NAMES gmock
libgmock
libgmock.a
PATHS "${GMOCK_DIR}")
find_library(GMOCK_LIBRARY_MAIN
NAMES gmock_main
libgmock_main
libgmock_main.a
PATHS "${GMOCK_DIR}")
set(TEST_SOURCES "${TEST_SOURCES}" "${CMAKE_BINARY_DIR}/test/unit/http/test_request.cpp")
set(TEST_SOURCES "${TEST_SOURCES}" "${CMAKE_BINARY_DIR}/test/unit/http/test_response.cpp")
set(TEST_SOURCES "${TEST_SOURCES}" "${CMAKE_BINARY_DIR}/test/unit/http/test_server.cpp")
set(TEST_SOURCES "${TEST_SOURCES}" "${CMAKE_BINARY_DIR}/test/unit/test_log.cpp")
set(TEST_SOURCES "${TEST_SOURCES}" "${CMAKE_BINARY_DIR}/test/unit/test_main.cpp")
add_executable(ieiunium_tela.srv_TEST ${TEST_SOURCES})
target_link_libraries(ieiunium_tela.srv_TEST ${GTEST_LIBRARY} ${GTEST_LIBRARY_MAIN})
target_link_libraries(ieiunium_tela.srv_TEST ${GMOCK_LIBRARY} ${GMOCK_LIBRARY_MAIN})
而且,这是我的问题:为什么 cmake 找不到我的 gtest/gmock 库?
我已经进入了他们各自的目录并使用它们构建了它们,共享库./configure && make -j4
的简要说明在那里显示了它们。find