Merge commit d30f2cb6 from release-2020 into master
[alexxy/gromacs.git] / src / api / cpp / CMakeLists.txt
index 273d8382b826764a916b88453df76027a886bb0d..1f6e172060ac0fbb0655ca783d05d17e753edec2 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -91,21 +91,19 @@ install(DIRECTORY include/gmxapi
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/gmxapi/version.h
         DESTINATION include/gmxapi)
 
-# Ref. https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
-# use, i.e. don't skip the full RPATH for the build tree
-set_target_properties(gmxapi PROPERTIES SKIP_BUILD_RPATH FALSE)
-
-# when building, don't use the install RPATH already
-# (but later on when installing)
-set_target_properties(gmxapi PROPERTIES BUILD_WITH_INSTALL_RPATH FALSE)
-
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
     # Instruct a linking client to use its RPATH to resolve the libgmxapi location.
+    #
+    # Explicitly specify library "install name" so that the correct loading
+    # instruction is produced in client code. Client code should be able to find the
+    # library relative to the client code RPATH. Without explicitly specifying,
+    # INSTALL_NAME_DIR is inherited from the global CMAKE_INSTALL_NAME_DIR, which is
+    # not appropriate for libgmxapi if it uses an install name relative to the
+    # executable_path or loader_path.
     set_target_properties(gmxapi PROPERTIES INSTALL_NAME_DIR "@rpath")
 endif()
 
 set_target_properties(gmxapi PROPERTIES
-                      INSTALL_RPATH_USE_LINK_PATH TRUE
                       SOVERSION ${GMXAPI_MAJOR}
                       VERSION ${GMXAPI_RELEASE}
                       )