diff --git a/cmake/Finddecomp2d.cmake b/cmake/Finddecomp2d.cmake new file mode 100644 index 00000000..7db9cbb9 --- /dev/null +++ b/cmake/Finddecomp2d.cmake @@ -0,0 +1,27 @@ +# - Find the 2decomp-fft library +find_package(decomp2d + PATHS ${CMAKE_SOURCE_DIR}/decomp2d/build) +if (decomp2d_FOUND) + message(STATUS "2decomp-fft FOUND") +else(decomp2d_FOUND) + message(STATUS "2decomp-fft PATH not available we'll try to download and install") + configure_file(${CMAKE_SOURCE_DIR}/cmake/decomp2d/downloadBuild2decomp.cmake.in decomp2d-build/CMakeLists.txt) + #message("Second CMAKE_GENERATOR ${CMAKE_GENERATOR}") + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/decomp2d-build ) + if(result) + message(FATAL_ERROR "CMake step for 2decomp-fft failed: ${result}") + else() + message("CMake step for 2decomp-fft completed (${result}).") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/decomp2d-build ) + if(result) + message(FATAL_ERROR "Build step for 2decomp-fft failed: ${result}") + endif() + set(D2D_ROOT ${CMAKE_CURRENT_BINARY_DIR}/decomp2d-build/downloadBuild2decomp-prefix/src/downloadBuild2decomp-build) + find_package(decomp2d REQUIRED + PATHS ${D2D_ROOT}) +endif(decomp2d_FOUND) diff --git a/cmake/decomp2d/downloadBuild2decomp.cmake.in b/cmake/decomp2d/downloadBuild2decomp.cmake.in new file mode 100644 index 00000000..5af4e115 --- /dev/null +++ b/cmake/decomp2d/downloadBuild2decomp.cmake.in @@ -0,0 +1,26 @@ +# downloadBuild2decomp.cmake.in +# +cmake_minimum_required(VERSION 3.0.2) + +project(downloadBuild2decomp NONE) + +include(ExternalProject) + +ExternalProject_Add(downloadBuild2decomp + GIT_REPOSITORY "https://github.com/xcompact3d/2decomp-fft" + GIT_TAG "v2.0.3" + SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/decomp2d-src" + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/decomp2d-opt" + TEST_COMMAND "" +) + +#ExternalProject_Add(downloadBuild2decomp +# GIT_REPOSITORY "https://github.com/xcompact3d/2decomp-fft" +# GIT_TAG "main" +# CONFIGURE_COMMAND "cmake -S ${CMAKE_CURRENT_BINARY_DIR}/decomp2d-src " +# BUILD_COMMAND "" +# INSTALL_COMMAND "" +# TEST_COMMAND "" +# SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/decomp2d-src" +# BINARY_DIR "" +# INSTALL_DIR "" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 28d453c0..27f93a02 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -76,6 +76,7 @@ endif() if (${POISSON_SOLVER} STREQUAL "FFT" AND ${BACKEND} STREQUAL "OMP") message(STATUS "Using the FFT poisson solver with 2decomp&fft") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") find_package(decomp2d REQUIRED) include_directories(${decomp2d_INCLUDE_DIRS}) target_link_libraries(decomp2d)