Fix for MSVC linking and release-build OpenMM plugin dir.
authorSzilard Pall <pszilard@cbr.su.se>
Sun, 30 May 2010 12:55:49 +0000 (14:55 +0200)
committerSzilard Pall <pszilard@cbr.su.se>
Sun, 30 May 2010 12:55:49 +0000 (14:55 +0200)
src/kernel/CMakeLists.txt

index 1d171340e619b9ce06a46a3ef624f9d5a99cb8ad..7f1e27e0b3878f124562624e63cd82432ee236b4 100644 (file)
@@ -44,7 +44,14 @@ if(GMX_OPENMM)
     add_subdirectory(gmx_gpu_utils)
     include_directories(./gmx_gpu_utils ${OpenMM_INCLUDE_DIR})
     link_directories(${OpenMM_LIBRARY_DIR}) 
-    add_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" ) 
+    # only define if this is a local build not a release 
+    # we assume that the auto-generated version is not used && 
+    # version string does not contain "-dev" => it's a release build
+    if(NOT USE_VERSION_H AND NOT PROJECT_VERSION MATCHES ".*-dev.*")  
+        add_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" ) 
+    else()
+        add_definitions( -DOPENMM_PLUGIN_DIR="" )
+    endif()
     add_library(openmm_api_wrapper openmm_wrapper.cpp)
 #    remove_definitions( -DOPENMM_PLUGIN_DIR="${OpenMM_PLUGIN_DIR}" )  # TODO where should this go?!
     set(GMX_OPENMM_LIBRARIES openmm_api_wrapper gmx_gpu_utils OpenMM)   
@@ -83,6 +90,12 @@ target_link_libraries(gmxcheck ${GMX_EXTRA_LIBRARIES})
 
 add_executable(mdrun ${MDRUN_SOURCES})
 target_link_libraries(mdrun ${GMX_EXTRA_LIBRARIES} ${GMX_OPENMM_LIBRARIES})
+# this is to circumvent the following MSVC error: 
+# warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs
+# fatal error LNK1169: one or more multiply defined symbols found
+if(GMX_OPENMM AND MSVC)
+    set_target_properties(mdrun PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LBCMT")
+endif()
 
 install(TARGETS 
         grompp