Improvements for missing gtest resources and other stuff
authorEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Thu, 22 Jun 2017 09:41:46 +0000 (11:41 +0200)
committerEduardo Ramos Testillano <eduardo.ramos.testillano@ericsson.com>
Thu, 22 Jun 2017 09:41:46 +0000 (11:41 +0200)
CMakeLists.txt

index 576325c..968a7c5 100644 (file)
@@ -108,7 +108,7 @@ ENDMACRO()
 add_definitions(-DLDAP_DEPRECATED)
 
 # General includes:
-include_directories(include/anna)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 include_directories(/usr/include/libxml2)
 include_directories(/usr/lib/oracle/12.1/client64/include)
 
@@ -153,7 +153,7 @@ FOREACH(module ${MODULES})
 
     # Executable
     set(target "anna_${module}_${subdir}")
-    add_executable(${target} "${SRCS}")
+    add_executable(${target} ${SRCS})
     set_target_properties(${target} PROPERTIES LINKER_LANGUAGE CXX)
     set(libraries_file "${CMAKE_CURRENT_SOURCE_DIR}/example/${module}/${subdir}/libraries.txt")
     set(includes_file "${CMAKE_CURRENT_SOURCE_DIR}/example/${module}/${subdir}/includes.txt")
@@ -183,33 +183,36 @@ ENDFOREACH()
 
 
 # <test>
-enable_testing()
-find_package(GTest REQUIRED)
-include_directories(${GTEST_INCLUDE_DIRS})
+find_package(GTest)
+IF(GTest_FOUND)
 
-SUBDIRLIST(MODULES ${CMAKE_CURRENT_SOURCE_DIR}/test)
-FOREACH(module ${MODULES})
+  enable_testing()
+  include_directories(${GTEST_INCLUDE_DIRS})
 
-  message(STATUS "Processing basic test at: test/${module}")
+  SUBDIRLIST(MODULES ${CMAKE_CURRENT_SOURCE_DIR}/test)
+  FOREACH(module ${MODULES})
 
-  # Sources
-  file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/*.cpp)
+    message(STATUS "Processing basic test at: test/${module}")
 
-  # Executable
-  set(target "anna_test_${module}")
-  add_executable(${target} "${SRCS}")
-  target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} pthread)
-  set(libraries_file "${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/libraries.txt")
+    # Sources
+    file(GLOB_RECURSE SRCS ${CMAKE_CURRENT_SOURCE_DIR}/test/${module}/*.cpp)
 
-  if(EXISTS "${libraries_file}")
-    file (STRINGS "${libraries_file}" LIBS)
-    #message(STATUS "Libraries: ${LIBS}")
-    target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} pthread ${LIBS})
-  endif()
+    # Executable
+    set(target "anna_test_${module}")
+    add_executable(${target} ${SRCS})
+    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} ${GTEST_BOTH_LIBRARIES} pthread ${LIBS})
+    endif()
 
-  add_test(${target} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target})
+    add_test(${target} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target})
 
-ENDFOREACH()
+  ENDFOREACH()
+ENDIF(GTest_FOUND)
 
 
 # Install
@@ -229,11 +232,11 @@ install(FILES ${LIBRARIES} DESTINATION lib)
 
 # Add target for API documentation with Doxygen
 find_package(Doxygen)
-if(DOXYGEN_FOUND)
-add_custom_target(doc
-  ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen/Doxyfile
-  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen
-  COMMENT "Generating API documentation with Doxygen" VERBATIM
-)
-endif(DOXYGEN_FOUND)
+IF(Doxygen_FOUND)
+  add_custom_target(doc
+    ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen/Doxyfile
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/doxygen
+    COMMENT "Generating API documentation with Doxygen" VERBATIM
+  )
+ENDIF(Doxygen_FOUND)