Commit 7ae1384e authored by Sergi Foix Salmerón's avatar Sergi Foix Salmerón
Browse files

updating gtest configuration

parent eff1b24e
......@@ -18,6 +18,8 @@ IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "DEBUG")
ENDIF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_CXX_FLAGS "-std=c++0x")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT")
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -D_REENTRANT -O0 --coverage -fprofile-arcs")
SET(CMAKE_LINK_FLAGS_DEBUG "--coverage -fprofile-arcs")
......@@ -29,7 +31,7 @@ INCLUDE(CTest)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test/gtest)
#ADD_SUBDIRECTORY(test/gtest)
ADD_SUBDIRECTORY(test)
......
......@@ -27,9 +27,8 @@ Execute the *new_project.sh* script with the following parameters:
* **-p "the project description"**: this parameter is required. It provides a short description of the project. This parameter will appear in all the associated documentation. For multi-word values, use the double quote.
* **-n project\_name**: this parameter is required. It specifies the name of the shared library or the binary file. **This parameter must not have any whitespace characters**.
* **-d comma,separated,dependencies**: this parameter is optional. It specifies a set of dependencies of the library or application. These depedencies will be automatically included inside the CMake structure. Only dependencies developed at IRI are currently supported. Other type of dependencies should better be added by hand once the project has been already created.
[//]: <> (Commented test option until it is operative again)
[//]: <> (* **-g**: this parameters is optional. Is specifies whether the test strcture is to be included into the project or not. This includes the necessaty CMake files to download and locally build the google test software and a basic test file for the generated project.)
* **-g**: this parameters is optional. Is specifies whether the test strcture is to be included into the project or not. This includes the necessaty CMake files to download and locally build the google test software and a basic test file for the generated project.
After executing the script, all the temporary and template files are removed, as well as the link to the remote GIT repository, so that the new project can be easily associated to another repository.
......
cmake_minimum_required(VERSION 2.8.2)
project(googletest-download NONE)
include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
include_directories(${GTEST_INCLUDE_DIRS})
include_directories(${GMOCK_INCLUDE_DIRS})
# Download and unpack googletest at configure time
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()
include_directories(${PROJECT_SOURCE_DIR}/include)
# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(CTEST_CUSTOM_COVERAGE_EXCLUDE *)
# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)
add_executable(library_name_tests library_name_test.cpp)
add_dependencies(library_name_tests googletest)
# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()
target_link_libraries(library_name_tests ${GTEST_LIBS_DIR}/libgtest.a ${GTEST_LIBS_DIR}/libgtest_main.a)
target_link_libraries(library_name_tests ${GMOCK_LIBS_DIR}/libgmock.a ${GMOCK_LIBS_DIR}/libgmock_main.a)
target_link_libraries(library_name_tests pthread)
# add the necessary project include directories
include_directories(../include)
# Now simply link against gtest or gtest_main as needed. Eg
add_executable(library_name_tests library_name_test.cpp)
target_link_libraries(library_name_tests gtest_main)
add_test(NAME Library_name_Test COMMAND library_name_tests)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment