diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
index ab6a313f1..664294d1a 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
@@ -303,6 +303,8 @@ ExternalProject_Add(mgcxx-proj
     "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
     "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
     "-DENABLE_TESTS=OFF"
+    "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}"
+    "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
   INSTALL_DIR    "${PROJECT_BINARY_DIR}/mgcxx"
 )
 ExternalProject_Get_Property(mgcxx-proj install_dir)