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

Merge pull request 'Add 3rd library cmake functions.' (#19) from...

Merge pull request 'Add 3rd library cmake functions.' (#19) from peters/VirtualFluids_dev:feature/clean_3rd_cmake_macros into open_source
parents 0b737089 bf1ded08
No related branches found
No related tags found
No related merge requests found
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
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
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()
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
......@@ -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
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
......@@ -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()
......
......@@ -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)
......
......@@ -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
......@@ -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;
};
......
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()
......@@ -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
......@@ -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
......
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