small medium large xlarge

24 Feb 2016, 01:11
Philip Slingerland (1 post)

If anyone else was recently having trouble getting the provided CMake files to build properly on Linux, I would like to share my CMakeLists.txt file:

project(chapterFirstExample) cmake_minimum_required(VERSION 2.6)

include_directories($ENV{GMOCK_HOME}/include $ENV{GTEST_HOME}/include) link_directories($ENV{GTEST_LIB}) add_definitions(-std=c++0x) set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -Wall -pthread”)

set(sources main.cpp SoundexTest.cpp) add_executable(test ${sources}) target_link_libraries(test pthread) target_link_libraries(test gmock) target_link_libraries(test gtest)

Things to note: 1. -pthread 2. The directory structure of googletest/mock has changed so that, on my system, I defined the following:

export GMOCK_HOME=/home/phil/Workspaces/google/googletest/googlemock/ export GTEST_HOME=/home/phil/Workspaces/google/googletest/googletest/

Also, I put my built libraries into a lib folder, such that on my system:

export GTEST_LIB=/home/phil/Workspaces/google/googletest/lib/

Hopefully that helps!

You must be logged in to comment