diff --git a/CMake/3rd/gmock.cmake b/CMake/3rd/gmock.cmake index 2809898b682c62d823aae28cb11a5afbdfc2a6bf..c74f67607a549d59f75d6c21685878643923bb59 100644 --- a/CMake/3rd/gmock.cmake +++ b/CMake/3rd/gmock.cmake @@ -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? diff --git a/CMake/FileUtilities.cmake b/CMake/FileUtilities.cmake index 2a72a047230aadcd7e0ffea403ae0fd67b0df24c..676d1ab567482492cc94c033b19486d2869c5e4c 100644 --- a/CMake/FileUtilities.cmake +++ b/CMake/FileUtilities.cmake @@ -1,3 +1,10 @@ +################################################################################# +## 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() diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index f01ab981946a12ba3ced3a8eb50b133f40f1adfe..5734fc4659eae4db68cd653d963513fdfe093bbc 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -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()