Skip to content

Commit

Permalink
compile gtest only once
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlevy committed May 18, 2018
1 parent 34fe5c0 commit 487f332
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ target_link_libraries(maxent libmaxent ${ALPSCore_LIBRARIES} ${GSL_LIBRARIES} ${
#testing setup
option(Testing "Enable testing" ON)

if (Testing)
add_library(gtest ./test/gtest-all.cc ./test/gtest_main.cc)
list(APPEND LINK_ALL libmaxent ${ALPSCore_LIBRARIES} ${GSL_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
enable_testing(test)
add_subdirectory(test)
endif (Testing)

list(APPEND LINK_ALL libmaxent ${ALPSCore_LIBRARIES} ${GSL_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
enable_testing(test)
add_subdirectory(test)

#add companion utilities
add_subdirectory(legendre_convert)
Expand Down
8 changes: 4 additions & 4 deletions cmake/EnableGtests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ function(add_gtest test)

if(${ARGC} EQUAL 2)
set(source "${ARGV1}/${test}")
set(gtest_src "${ARGV1}/gtest_main.cc;${ARGV1}/gtest-all.cc")
#set(gtest_src "${ARGV1}/gtest_main.cc;${ARGV1}/gtest-all.cc")
else(${ARGC} EQUAL 2)
set(source "${test}")
set(gtest_src "gtest_main.cc;gtest-all.cc")
#set(gtest_src "gtest_main.cc;gtest-all.cc")
endif(${ARGC} EQUAL 2)

add_executable(${test} ${source} ${gtest_src})
target_link_libraries(${test} ${LINK_ALL})
add_executable(${test} ${source})
target_link_libraries(${test} ${LINK_ALL} gtest)
add_test(NAME ${test} COMMAND ${test} ${test_xml_output})
endfunction(add_gtest)

0 comments on commit 487f332

Please sign in to comment.