Fixes linkage with FFTW + MKL for BLAS/LAPACK
authorRoland Schulz <roland@utk.edu>
Tue, 5 Mar 2013 09:15:01 +0000 (04:15 -0500)
committerChristoph Junghans <junghans@votca.org>
Tue, 5 Mar 2013 17:57:35 +0000 (10:57 -0700)
The order of linking was incorrect, when using both mkl and fftw
causing the mkl fftw wrapper to be used instead of fftw itself.

Removes all unnecessary transitive libraries (cmake adds those
automatically). Simplifies the target_link_libraries lines, and
makes it much easier to change the fft/blas link order.

Only remaining transitive libraries are gmx/md for binaries. This
is required because OpenMP_LINKER_FLAGS needs to be at the end
but transitive libraries are added at the end. Thus without listing
gmx/md manually the order is incorrect.

Also fixes that nbnxn_cuda has cuda_tools listed as library
dependency. Was prior working without it but now is needed and is
also anyhow the more corect way to do it.

Fixes #1067

Change-Id: I639b16f1460d27a15eb72cc00674c041266f6624

src/gmxlib/CMakeLists.txt
src/kernel/CMakeLists.txt
src/mdlib/CMakeLists.txt
src/mdlib/nbnxn_cuda/CMakeLists.txt
src/ngmx/CMakeLists.txt
src/tools/CMakeLists.txt

index f7a174b84f9582d27dbb60ea942b59721b21e69a..735ce020ff8ab53a14174af570898f65abfd64d9 100644 (file)
@@ -113,7 +113,7 @@ endif()
 
 # NONBONDED_SOURCES is imported from the nonbonded subdirectory.
 add_library(gmx ${GMXLIB_SOURCES} ${BLAS_SOURCES} ${LAPACK_SOURCES} ${THREAD_MPI_SRC} ${NONBONDED_SOURCES})
-target_link_libraries(gmx ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
+target_link_libraries(gmx ${FFT_LIBRARIES} ${GMX_GPU_LIBRARIES} ${GMX_EXTRA_LIBRARIES} ${THREAD_LIB} ${OpenMP_SHARED_LINKER_FLAGS})
 if(USE_VERSION_H)
        add_dependencies(gmx gmx_version) 
 endif()
index 01e290c9c534a1e0bbe78d3e19a357dee3ac8800..50624792f1189c574ad7d61ea40092ead9851b41 100644 (file)
@@ -102,8 +102,6 @@ if(GMX_FAHCORE)
   add_library(fahcore ${MDRUN_SOURCES})
 else(GMX_FAHCORE)
 
-list(APPEND GMX_EXTRA_LIBRARIES gmxpreprocess md ${OpenMP_LINKER_FLAGS})
-
 set(GMX_KERNEL_PROGRAMS
     grompp tpbconv pdb2gmx g_protonate gmxdump g_x2top gmxcheck)
 if (NOT GMX_NO_QUOTES)
@@ -116,13 +114,13 @@ foreach(PROGRAM ${GMX_KERNEL_PROGRAMS})
     if (NOT ${PROGRAM} STREQUAL "g_luck")
         gmx_add_man_page(${PROGRAM})
     endif()
-    target_link_libraries(${PROGRAM} ${GMX_EXTRA_LIBRARIES})
+    target_link_libraries(${PROGRAM} gmxpreprocess md gmx ${OpenMP_LINKER_FLAGS})
     set_target_properties(${PROGRAM} PROPERTIES OUTPUT_NAME "${PROGRAM}${GMX_BINARY_SUFFIX}")
 endforeach()
 
 add_executable(mdrun ${MDRUN_SOURCES} main.c)
 gmx_add_man_page(mdrun)
-target_link_libraries(mdrun ${GMX_EXTRA_LIBRARIES})
+target_link_libraries(mdrun gmxpreprocess md gmx ${OpenMP_LINKER_FLAGS})
 set_target_properties(mdrun PROPERTIES OUTPUT_NAME "mdrun${GMX_BINARY_SUFFIX}" COMPILE_FLAGS "${OpenMP_C_FLAGS}")
 
 # Construct component groups for installation; note that a component may
index 732624a99147b908ae4ddca1041baa350d27aaa7..617a0c7796bee3f247248d111cc983dfd8f17080 100644 (file)
@@ -57,7 +57,7 @@ endif()
 
 add_library(md ${MDLIB_SOURCES})
 
-target_link_libraries(md ${GMX_GPU_LIBRARIES} gmx ${GMX_EXTRA_LIBRARIES} ${FFT_LIBRARIES} ${OpenMP_SHARED_LINKER_FLAGS})
+target_link_libraries(md ${GMX_GPU_LIBRARIES} gmx)
 if(GMX_BUILD_OWN_FFTW)
     # This dependency has to be made here rather than the CMakeLists.txt that
     # does the FFTW build, because of the order in which
index 27df5c76e837a88312cf620c7800f3b012219f25..bbabac0188b9ed9c790bc6bcafc9d40e50ac1b22 100644 (file)
@@ -41,5 +41,6 @@ if(GMX_GPU)
             DEBUG -g -D_DEBUG_=1)
     #Because this is a static library linked into the (potential) shared library
     #it should have the export of the shared library.
+    target_link_libraries(nbnxn_cuda cuda_tools)
     SET_TARGET_PROPERTIES(nbnxn_cuda PROPERTIES DEFINE_SYMBOL "md_EXPORTS" )
 endif()
index ed28c41a9663de1e64d317324a4868f06ffaca0b..cfb344f9b6e628be2579c2f490591893ddddfd55 100644 (file)
@@ -54,7 +54,7 @@ set(NGMX_PROGRAMS
 foreach(PROG ${NGMX_PROGRAMS})
         add_executable(${PROG} ${PROG}.c ${NGMX_COMMON_SOURCE})
         gmx_add_man_page(${PROG})
-        target_link_libraries(${PROG} gmx ${GMX_EXTRA_LIBRARIES} ${X11_LIBRARIES})        
+        target_link_libraries(${PROG} gmx ${X11_LIBRARIES})
         set_target_properties(${PROG} PROPERTIES OUTPUT_NAME "${PROG}${GMX_BINARY_SUFFIX}")
 endforeach(PROG) 
 
index 2faf622f44ea2426644c3237ab7813dd6eefe4ad..b323ef79de8149d02f29bde01583f713e5e88049 100644 (file)
@@ -70,7 +70,7 @@ add_library(gmxana
             )
 
 
-target_link_libraries(gmxana md gmx ${GSL_LIBRARIES})
+target_link_libraries(gmxana md ${GSL_LIBRARIES})
 set_target_properties(gmxana PROPERTIES OUTPUT_NAME "gmxana${GMX_LIBS_SUFFIX}" SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${LIB_INSTALL_DIR}"
     COMPILE_FLAGS "${OpenMP_C_FLAGS}")
 
@@ -107,7 +107,7 @@ foreach(TOOL ${GMX_TOOLS_PROGRAMS} ${GMX_TOOLS_PROGRAMS_NOT_FOR_INSTALLATION})
         endif()
     endif()
     add_executable(${TOOL} ${TOOL}.c)
-    target_link_libraries(${TOOL} gmxana ${OpenMP_LINKER_FLAGS})
+    target_link_libraries(${TOOL} gmxana md gmx ${OpenMP_LINKER_FLAGS})
     set_target_properties(${TOOL} PROPERTIES OUTPUT_NAME "${TOOL}${GMX_BINARY_SUFFIX}")
 endforeach()