I'm trying to add openmpi as a static library to my c++ project on a Windows Visual Studio environment using the mscv compiler. However, the FetchContent_MakeAvailable command does not seem to be building the library from the dowloaded source.
My CMakeLists.txt
cmake_minimum_required(VERSION 3.18)
project(test)
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(
openmpi
GIT_REPOSITORY https://github.com/open-mpi/ompi.git
GIT_TAG v2.0.0
)
FetchContent_MakeAvailable(openmpi)
add_executable(test main.cpp)
target_link_libraries(
test
openmpi
)
Output
1> CMake generation started for default configuration: 'x64-Debug'.
1> Command line: "C:\Windows\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe" -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\dpope\source\repos\OpenMPItest\OpenMPItest\out\install\x64-Debug" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe" -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\Users\dpope\source\repos\OpenMPItest\OpenMPItest" 2>&1"
1> Working directory: C:\Users\dpope\source\repos\OpenMPItest\OpenMPItest\out\build\x64-Debug
1> [CMake] -- Populating openmpi
1> [CMake] -- Configuring done (0.1s)
1> [CMake] -- Generating done (0.0s)
1> [CMake] -- Build files have been written to: C:/Users/dpope/source/repos/OpenMPItest/OpenMPItest/out/build/x64-Debug/_deps/openmpi-subbuild
1> [CMake] [0/7] Performing update step for 'openmpi-populate'
1> [CMake] [1/7] No patch step for 'openmpi-populate'
1> [CMake] [3/7] No configure step for 'openmpi-populate'
1> [CMake] [4/7] No build step for 'openmpi-populate'
1> [CMake] [5/7] No install step for 'openmpi-populate'
1> [CMake] [6/7] No test step for 'openmpi-populate'
1> [CMake] [7/7] Completed 'openmpi-populate'
1> [CMake] -- Configuring done (0.6s)
1> [CMake] -- Generating done (0.0s)
1> [CMake] -- Build files have been written to: C:/Users/dpope/source/repos/OpenMPItest/OpenMPItest/out/build/x64-Debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.
In the build/x64-Debug/_deps folder the subfolders openmpi-src and openmpi-subbuild are populated but openmpi-build is empty with no library files to link to.
FetchContent_Declaremake other project to be part of your one. So, when you build your project, the other project will be building too.