From 82fdaa94e91c53ad79b8cca936ee35f18732f9cd Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Mon, 15 Sep 2014 20:08:19 -0400 Subject: [PATCH] Fix double linkage for tests cmake automatically adds libraries required by a required library to the exe linker flags. If the same dependent library is also added for the exe and it is listed first for the exe, cmake links twice for static libs (for a cyclic dependency it would be required and cmake can't know). Under certain conditions (e.g. ICC 15 with static libraries and offload enabled) this can cause linker errors. We don't have a cyclic dependency and thus by listing libgromacs after testutils we avoid the potential problematic double linking. Also fixes that TESTUTILS_LIBS contains the transitive dependencies, because that is not necessary (they are anyhow added automatically). Change-Id: I0327b2dba0538a2c6652c484fd7be7ae4a6cfb5b --- src/testutils/CMakeLists.txt | 2 +- src/testutils/TestMacros.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/testutils/CMakeLists.txt b/src/testutils/CMakeLists.txt index 1941dbcb2f..6366b97084 100644 --- a/src/testutils/CMakeLists.txt +++ b/src/testutils/CMakeLists.txt @@ -37,7 +37,7 @@ include_directories(${LIBXML2_INCLUDE_DIR}) file(GLOB TESTUTILS_SOURCES *.cpp) add_library(testutils STATIC ${UNITTEST_TARGET_OPTIONS} ${TESTUTILS_SOURCES}) -set(TESTUTILS_LIBS testutils ${GMOCK_LIBRARIES} ${LIBXML2_LIBRARIES}) +set(TESTUTILS_LIBS testutils) set_property(TARGET testutils APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}") target_link_libraries(testutils libgromacs ${GMOCK_LIBRARIES} ${LIBXML2_LIBRARIES}) diff --git a/src/testutils/TestMacros.cmake b/src/testutils/TestMacros.cmake index 0796c6993c..b3acdbefd1 100644 --- a/src/testutils/TestMacros.cmake +++ b/src/testutils/TestMacros.cmake @@ -45,7 +45,7 @@ function (gmx_build_unit_test NAME EXENAME) include_directories(BEFORE ${GMOCK_INCLUDE_DIRS}) add_executable(${EXENAME} ${UNITTEST_TARGET_OPTIONS} ${ARGN} ${TESTUTILS_DIR}/unittest_main.cpp) set_property(TARGET ${EXENAME} APPEND PROPERTY COMPILE_DEFINITIONS "${GMOCK_COMPILE_DEFINITIONS}") - target_link_libraries(${EXENAME} libgromacs ${TESTUTILS_LIBS} ${GMOCK_LIBRARIES} ${GMX_EXE_LINKER_FLAGS}) + target_link_libraries(${EXENAME} ${TESTUTILS_LIBS} libgromacs ${GMOCK_LIBRARIES} ${GMX_EXE_LINKER_FLAGS}) set(_temporary_files_path "${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary") file(MAKE_DIRECTORY ${_temporary_files_path}) -- 2.22.0