Migrate boost unit test to google test with cmake (ctest)
[anna.git] / CMakeLists.txt
index 7acd9b1..dbce3e3 100644 (file)
@@ -178,7 +178,10 @@ ENDFOREACH()
 
 
 # <test>
-find_package(Boost COMPONENTS system filesystem REQUIRED)
+enable_testing()
+find_package(GTest REQUIRED)
+include_directories(${GTEST_INCLUDE_DIRS})
+
 SUBDIRLIST(MODULES ${CMAKE_CURRENT_SOURCE_DIR}/test)
 FOREACH(module ${MODULES})
 
@@ -188,21 +191,18 @@ FOREACH(module ${MODULES})
   file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/*.cpp)
 
   # Executable
-  set(target "${module}")
-  find_package(Boost COMPONENTS system filesystem unit_test_framework REQUIRED)
+  set(target "test_${module}")
   add_executable(${target} "${SRCS}")
-  set_target_properties(${target} PROPERTIES LINKER_LANGUAGE CXX)
-
-
-  set(libraries_file "${CMAKE_CURRENT_SOURCE_DIR}/example/${module}/${subdir}/libraries.txt")
+  target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} pthread)
+  set(libraries_file "${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/libraries.txt")
 
   if(EXISTS "${libraries_file}")
     file (STRINGS "${libraries_file}" LIBS)
     #message(STATUS "Libraries: ${LIBS}")
-    target_link_libraries(${target} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${LIBS})
+    target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} pthread ${LIBS})
   endif()
 
-  add_test(tester tester)
+  add_test(${target} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target})
 
 ENDFOREACH()