Skip to content
Snippets Groups Projects
Commit 8569fa41 authored by Soeren Peters's avatar Soeren Peters
Browse files

Small clean ups for the test executable.

parent 8fcf5ed3
No related branches found
No related tags found
No related merge requests found
......@@ -10,3 +10,6 @@
target_link_directories(${library_name} PRIVATE ${GMOCK_ROOT}/build/lib)
target_link_libraries(${library_name} PRIVATE gtest gmock gmock_main)
#add_compile_options (-std=c++11)
add_definitions("-std=c++11") #TODO: Really necessary?
#################################################################################
## Helper functions for building source groups
## and extracting test/production files.
##
## After function call the files are stored in: MY_SRCS
#################################################################################
macro(includeAllFiles targetName file_path)
set(collectTestFiles ON)
set(collectProductionFiles ON)
......@@ -6,7 +13,6 @@ macro(includeAllFiles targetName file_path)
endmacro(includeAllFiles)
macro(includeProductionFiles targetName file_path)
set(collectTestFiles OFF)
set(collectProductionFiles ON)
......@@ -16,35 +22,31 @@ endmacro(includeProductionFiles)
macro(includeTestFiles targetName file_path)
macro(includeTestFiles targetName file_paths)
set(collectTestFiles ON)
set(collectProductionFiles OFF)
includeFiles(${targetName} "${file_path}")
includeFiles(${targetName} "${file_paths}")
endmacro(includeTestFiles)
macro(includeFiles targetName file_path)
foreach(file ${file_path})
#message("File: " ${file})
get_filename_component(package_dir ${file} DIRECTORY)
macro(includeFiles targetName file_paths)
foreach(file ${file_paths})
get_filename_component(package_dir ${file} DIRECTORY)
#message("File: " ${file})
#message("package_dir: " ${package_dir})
collectFilesFrom(${file})
collectFilesFrom(${file})
if (package_dir)
#setSourceGroupForFilesIn(${package_dir} ${targetName})
buildSourceGroup(${targetName} ${package_dir})
if(isAllTestSuite)
source_group(${targetName}\\${SOURCE_GROUP} FILES ${MY_SRCS})
else()
source_group(${SOURCE_GROUP} FILES ${file})
endif()
setSourceGroupForFilesIn(${package_dir} ${targetName})
endif()
endforeach()
endmacro(includeFiles)
......@@ -52,23 +54,20 @@ endmacro(includeFiles)
macro(collectFilesFrom path)
#input: path from files to collect
#foreach(_file ${path})
get_filename_component(fileName ${path} NAME)
if(collectTestFiles)
if(${fileName} MATCHES "Test" OR ${fileName} MATCHES "Mock")
set(MY_SRCS ${MY_SRCS} ${path})
endif()
get_filename_component(fileName ${path} NAME)
if(collectTestFiles)
if(${fileName} MATCHES "Test" OR ${fileName} MATCHES "Mock")
set(MY_SRCS ${MY_SRCS} ${path})
endif()
if(collectProductionFiles)
if(NOT ${fileName} MATCHES "Test" AND NOT ${fileName} MATCHES "Mock")
set(MY_SRCS ${MY_SRCS} ${path})
endif()
endif()
if(collectProductionFiles)
if(NOT ${fileName} MATCHES "Test" AND NOT ${fileName} MATCHES "Mock")
set(MY_SRCS ${MY_SRCS} ${path})
endif()
#endforeach()
#set(MY_SRCS ${MY_SRCS} ${COLLECTED_FILES_IN_PATH})
endif()
#output: MY_SRCS
endmacro(collectFilesFrom)
endmacro()
......
......@@ -8,7 +8,7 @@
#################################################################################
function(status msg)
message(STATUS " VF -- ${msg}")
message(STATUS " VF - ${msg}")
endfunction()
#################################################################################
......@@ -231,32 +231,33 @@ endfunction()
## Precondition: BUILD_VF_UNIT_TESTS needs to be ON
#################################################################################
function(vf_add_tests)
if (NOT BUILD_VF_UNIT_TESTS)
return()
endif()
# get the test library name
vf_get_library_test_name(library_test_name)
vf_get_library_name (folder_name)
status("Add test executable: ${library_test_name}")
# set test files to MY_SRCS
file ( GLOB_RECURSE all_files ${VIRTUAL_FLUIDS_GLOB_FILES} )
includeTestFiles (${folder_name} "${all_files}")
set(sourceFiles ${sourceFiles} ${all_files})
includeTestFiles (${folder_name} "${sourceFiles}")
cmake_print_variables(MY_SRCS)
# add the target
add_executable(${library_test_name} ${MY_SRCS})
# link tested library
target_link_libraries(${library_test_name} PRIVATE ${folder_name})
# link tested library
target_include_directories(${library_test_name} PRIVATE ${CMAKE_BINARY_DIR})
target_include_directories(${library_test_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${library_test_name} PRIVATE ${CMAKE_SOURCE_DIR}/src)
# link googlemock
include(${CMAKE_PATH}/3rd/gmock.cmake)
#add_compile_options (-std=c++11)
add_definitions("-std=c++11")
endfunction()
\ No newline at end of file
endfunction()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment