Fail gracefully when nblib cannot be built
authorejjordan <ejjordan@kth.se>
Tue, 29 Sep 2020 09:36:43 +0000 (11:36 +0200)
committerArtem Zhmurov <zhmurov@gmail.com>
Tue, 29 Sep 2020 14:14:38 +0000 (14:14 +0000)
api/CMakeLists.txt

index 327282eea8f36ac6cabe0fd9a26c982d7c65d534..557e6bb44e57c9d9f22815db283a643de7556319 100644 (file)
@@ -47,8 +47,20 @@ if (GMXAPI)
     add_subdirectory(gmxapi)
 endif()
 
-add_subdirectory(nblib)
-if(GMX_INSTALL_NBLIB_API)
-    install(FILES
-            DESTINATION include/nblib)
+# Activate targets NBLIB
+if(GMX_NATIVE_WINDOWS OR GMX_BUILD_MDRUN_ONLY)
+    # NBLIB has not been tested in Microsoft environments.
+    # NBLIB relies on libgromacs and is incompatible with an `mdrun`-only build.
+    # NBLIB requires position-independent code
+    set(_NBLIB_DEFAULT OFF)
+else()
+    set(_NBLIB_DEFAULT ON)
+endif()
+option(GMX_INSTALL_NBLIB_API "Install nblib headers" ${_NBLIB_DEFAULT})
+if (GMX_INSTALL_NBLIB_API)
+    if(NOT ${BUILD_SHARED_LIBS})
+        message(FATAL_ERROR "NBLIB requires position-independent code. Set -GMX_INSTALL_NBLIB_API=OFF or -DBUILD_SHARED_LIBS=ON.")
+    else()
+        add_subdirectory(nblib)
+    endif()
 endif()