+# Defines the gtest & gtest_main libraries. User tests should link
+# with one of them.
+function(cxx_library_with_type name type cxx_flags)
+ # type can be either STATIC or SHARED to denote a static or shared library.
+ # ARGN refers to additional arguments after 'cxx_flags'.
+ add_library(${name} ${type} ${ARGN})
+ set_target_properties(${name}
+ PROPERTIES
+ COMPILE_FLAGS "${cxx_flags}")
+ if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
+ set_target_properties(${name}
+ PROPERTIES
+ COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
+ endif()
+ if (CMAKE_USE_PTHREADS_INIT)
+ target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})
+ endif()
+endfunction()
+
+########################################################################
+#
+# Helper functions for creating build targets.
+
+function(cxx_library name cxx_flags)
+ cxx_library_with_type(${name} "" "${cxx_flags}" ${ARGN})
+endfunction()
+
+
set(GROMACS_CXX_FLAGS "${GROMACS_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-set(SOURCES
- src/domains.cpp
- src/domaintype.cpp
- src/newfit.cpp)
-set(HEADERS
- src/domaintype.h
- src/newfit.h)
+
add_executable(domains domains.cpp domaintype.cpp newfit.cpp)
include_directories(
${GROMACS_INCLUDE_DIRS}
set_target_properties(domains PROPERTIES
COMPILE_FLAGS "${GROMACS_CXX_FLAGS}")
target_link_libraries(domains ${GROMACS_LIBRARIES} ${OpenMP_CXX_LIBRARIES})
+
+
+cxx_library(gtest "${cxx_strict}" gtest/src/gtest-all.cc)
+add_executable(domaintests domaintests.cpp domaintype.cpp newfit.cpp)
+include_directories(
+ ${GROMACS_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/src/gtest/include
+ ${CMAKE_SOURCE_DIR}/src/gtest)
+target_link_libraries(domaintests ${GROMACS_LIBRARIES} ${OpenMP_CXX_LIBRARIES} gtest)