diff --git a/CMake/3rd.cmake b/CMake/3rd.cmake new file mode 100644 index 0000000000000000000000000000000000000000..6cc488f94716f7cec973874b0930ed8f9b719d08 --- /dev/null +++ b/CMake/3rd.cmake @@ -0,0 +1,5 @@ +include(${VF_CMAKE_DIR}/3rd/boost.cmake) +include(${VF_CMAKE_DIR}/3rd/cuda.cmake) +include(${VF_CMAKE_DIR}/3rd/gmock.cmake) +include(${VF_CMAKE_DIR}/3rd/mpi.cmake) +include(${VF_CMAKE_DIR}/3rd/OpenMP.cmake) \ No newline at end of file diff --git a/CMake/3rd/OpenMP.cmake b/CMake/3rd/OpenMP.cmake index fce16693d4eb5b8d61187ed198811e44de96f124..bd7781b959907eedb2b5475d6ea106d03641cbe3 100644 --- a/CMake/3rd/OpenMP.cmake +++ b/CMake/3rd/OpenMP.cmake @@ -1,13 +1,10 @@ +function (linkOpenMP) -find_package(OpenMP) -if (OPENMP_FOUND) - #set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - #set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - #set (CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler ${OpenMP_CXX_FLAGS}") -endif() + find_package(OpenMP REQUIRED) -#message (Cuda Flags: ${OpenMP_CXX_FLAGS}) -vf_get_library_name(library_name) -if(OpenMP_CXX_FOUND) - target_link_libraries(${library_name} PUBLIC OpenMP::OpenMP_CXX) -endif() + if(OpenMP_CXX_FOUND) + vf_get_library_name(library_name) + target_link_libraries(${library_name} PUBLIC OpenMP::OpenMP_CXX) + endif() + +endfunction() \ No newline at end of file diff --git a/CMake/3rd/boost.cmake b/CMake/3rd/boost.cmake index fae5cdf658dcb1e33ce25cc45317cd4f524e4829..544ae2d97b3b8ef0277445cf252149986c8dfb3a 100644 --- a/CMake/3rd/boost.cmake +++ b/CMake/3rd/boost.cmake @@ -1,4 +1,4 @@ -macro(linkBoost components) +function(linkBoost components) if(BUILD_SHARED_LIBS) if (WIN32) set(Boost_USE_STATIC_LIBS ON) @@ -17,8 +17,9 @@ macro(linkBoost components) add_definitions( -DBOOST_ALL_NO_LIB ) # add_definitions( -DBOOST_ALL_DYN_LINK ) endif() + vf_get_library_name(library_name) find_package( Boost REQUIRED COMPONENTS ${components}) target_include_directories(${library_name} PRIVATE ${Boost_INCLUDE_DIR}) target_link_libraries(${library_name} PRIVATE ${Boost_LIBRARIES}) -endmacro(linkBoost) +endfunction() diff --git a/CMake/3rd/cuda.cmake b/CMake/3rd/cuda.cmake index 32b2e82d4f8ef0e2ec4c258ad19e99ae5938d9fc..f39e4c417134511e4dd8f37cc3a081479d037147 100644 --- a/CMake/3rd/cuda.cmake +++ b/CMake/3rd/cuda.cmake @@ -1,4 +1,5 @@ +function(linkCUDA) find_path(CUDA_CUT_INCLUDE_DIR helper_cuda.h @@ -11,8 +12,7 @@ vf_get_library_name(library_name) target_include_directories(${library_name} PRIVATE ${CUDA_INCLUDE_DIRS} ${CUDA_CUT_INCLUDE_DIR}) - #set_property(TARGET ${targetName} PROPERTY CUDA_SEPARABLE_COMPILATION ON) - #set_property(TARGET ${targetName} PROPERTY CUDA_64_BIT_DEVICE_CODE ON) - - #set(CUDA_NVCC_FLAGS "-G" CACHE TYPE INTERNAL FORCE) - #set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -gencode arch=compute_13,code=sm_13 ) + # set the following properties only for specific targets + # set_property(TARGET ${targetName} PROPERTY CUDA_SEPARABLE_COMPILATION ON) + # set_property(TARGET ${targetName} PROPERTY CUDA_64_BIT_DEVICE_CODE ON) +endfunction() \ No newline at end of file diff --git a/CMake/3rd/gmock.cmake b/CMake/3rd/gmock.cmake index b87f284921fe56bb09fa8f4d2c2f29b8733faa0c..205a3b9a17d872d77df114517d8d7dba0de255bf 100644 --- a/CMake/3rd/gmock.cmake +++ b/CMake/3rd/gmock.cmake @@ -3,14 +3,15 @@ # Note: gmock has to be build by the project itself (Located in 3rd). ################################################################################# -vf_get_library_test_name(library_name) -target_link_libraries(${library_name} PRIVATE gtest gmock gmock_main) +function (linkGMOCK) + vf_get_library_test_name(library_name) + target_link_libraries(${library_name} PRIVATE gtest gmock gmock_main) - -if(BUILD_SHARED_LIBS) - # add compile option according to - # https://github.com/google/googletest/blob/master/googletest/README.md#as-a-shared-library-dll - set_target_properties(${library_name} - PROPERTIES - COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") -endif() + if(BUILD_SHARED_LIBS) + # add compile option according to + # https://github.com/google/googletest/blob/master/googletest/README.md#as-a-shared-library-dll + set_target_properties(${library_name} + PROPERTIES + COMPILE_DEFINITIONS "GTEST_LINKED_AS_SHARED_LIBRARY=1") + endif() +endfunction() \ No newline at end of file diff --git a/CMake/3rd/mpi.cmake b/CMake/3rd/mpi.cmake index a3c8826b6fe31f19c7d3d5e42c691796f395b49d..93b3ee386cc46623ed02bbbffb88996328f03e52 100644 --- a/CMake/3rd/mpi.cmake +++ b/CMake/3rd/mpi.cmake @@ -1,10 +1,9 @@ +function (linkMPI) + find_package(MPI REQUIRED) -vf_get_library_name(library_name) + vf_get_library_name(library_name) + target_include_directories(${library_name} PUBLIC ${MPI_CXX_INCLUDE_PATH}) + target_link_libraries(${library_name} PRIVATE MPI::MPI_CXX) -find_package(MPI REQUIRED) -target_include_directories(${library_name} PUBLIC ${MPI_CXX_INCLUDE_PATH}) - -#target_link_libraries(${library_name} PUBLIC ${MPI_CXX_LIBRARIES}) - -target_link_libraries(${library_name} PRIVATE MPI::MPI_CXX) +endfunction() \ No newline at end of file diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index 721d56b89ee22f491c4c984de67fa6ee27fa3b74..83274c2fb21a54d8aead43e1215c3f1c53cea4f3 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -222,7 +222,7 @@ function(vf_add_tests) target_include_directories(${library_test_name} PRIVATE ${VF_SRC_DIR}) # link googlemock - include(${VF_CMAKE_DIR}/3rd/gmock.cmake) + linkGMOCK() endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index 4219695ee306e8fc48c8ac210521a36a460d203b..9faf348c02c77cb89a2e0a2c985cb09b528d3132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ include(CMakePrintHelpers) include(${VF_CMAKE_DIR}/CMakeCABMacros.cmake) include(${VF_CMAKE_DIR}/FileUtilities.cmake) include(${VF_CMAKE_DIR}/VirtualFluidsMacros.cmake) +include(${VF_CMAKE_DIR}/3rd.cmake) include(${VF_CMAKE_DIR}/CMakeMacros_old/general/FindCompiler.cmake) configure_file(src/basics/VirtualFluidsDefinitions.in.h ${CMAKE_BINARY_DIR}/VirtualFluidsDefinitions.h) diff --git a/src/basics/CMakeLists.txt b/src/basics/CMakeLists.txt index eb1ef8d2adbc60e002b779b070e9a8faca2eb682..30fc6e9d17a76fae3626533d1d0238e99eb422ac 100644 --- a/src/basics/CMakeLists.txt +++ b/src/basics/CMakeLists.txt @@ -17,6 +17,7 @@ IF(MSVC) target_compile_definitions(${library_name} PUBLIC NOMINMAX) # Disable Min/Max-Macros ENDIF(MSVC) -include (${VF_CMAKE_DIR}/3rd/mpi.cmake) + +linkMPI() vf_add_tests() \ No newline at end of file diff --git a/src/basics/Core/Input/Input.h b/src/basics/Core/Input/Input.h index 7adbc305f84f4a5cd8136e044c13a3b197277cab..9c95e2a167139b9ba3bab2937ed5d666ba1e1022 100644 --- a/src/basics/Core/Input/Input.h +++ b/src/basics/Core/Input/Input.h @@ -15,6 +15,8 @@ namespace input public: static BASICS_EXPORT std::unique_ptr<Input> makeInput(std::istream &stream, const std::string &inputType); + virtual ~Input() = default; + virtual bool hasValue(const std::string &key) const = 0; virtual std::string getValue(const std::string &key) = 0; }; diff --git a/src/gpu/GksGpu/CMakeLists.txt b/src/gpu/GksGpu/CMakeLists.txt index 682bcccabd2cc7d77decd1b59adddec47c5521b2..353a5c8424f8c454d21e58b1acb405611414462c 100644 --- a/src/gpu/GksGpu/CMakeLists.txt +++ b/src/gpu/GksGpu/CMakeLists.txt @@ -1,6 +1,6 @@ vf_add_library(BUILDTYPE shared DEPENDS basics GksMeshAdapter) -include (${VF_CMAKE_DIR}/3rd/cuda.cmake) -include (${VF_CMAKE_DIR}/3rd/mpi.cmake) -include (${VF_CMAKE_DIR}/3rd/OpenMP.cmake) +linkCUDA() +linkMPI() +linkOpenMP() diff --git a/src/gpu/GridGenerator/CMakeLists.txt b/src/gpu/GridGenerator/CMakeLists.txt index c974d02d62bea58e91847c341355588880ce7c46..86b49cc4712e4ec23df96ba5a9bfa912ee23029f 100644 --- a/src/gpu/GridGenerator/CMakeLists.txt +++ b/src/gpu/GridGenerator/CMakeLists.txt @@ -2,8 +2,7 @@ vf_add_library(BUILDTYPE shared DEPENDS basics) -include (${VF_CMAKE_DIR}/3rd/cuda.cmake) -include (${VF_CMAKE_DIR}/3rd/OpenMP.cmake) - +linkCUDA() +linkOpenMP() set_property(TARGET ${library_name} PROPERTY CUDA_SEPARABLE_COMPILATION ON) \ No newline at end of file diff --git a/src/gpu/VirtualFluids_GPU/CMakeLists.txt b/src/gpu/VirtualFluids_GPU/CMakeLists.txt index ebe26edce1edf26e2b018ae1407c04955c00eafc..be3a46dfc05f46ce0786c433851a6b54e7cf9d19 100644 --- a/src/gpu/VirtualFluids_GPU/CMakeLists.txt +++ b/src/gpu/VirtualFluids_GPU/CMakeLists.txt @@ -9,8 +9,7 @@ ENDIF(MSVC) vf_add_library(BUILDTYPE shared DEPENDS ${libsToLink}) -include (${VF_CMAKE_DIR}/3rd/cuda.cmake) - +linkCUDA() #SET(TPN_WIN32 "/EHsc") #https://stackoverflow.com/questions/6832666/lnk2019-when-including-asio-headers-solution-generated-with-cmake