diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c07176f8..984b2770c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,17 +27,6 @@ endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) cmake_minimum_required(VERSION 2.6) project(gnss-sdr CXX) -################################################################################ -# GTest - http://code.google.com/p/googletest/ -################################################################################ -set(GTEST_DIR $ENV{GTEST_DIR}) -set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) -include_directories(${GTEST_INCLUDE_DIRECTORIES}) -message("GTEST found at ${GTEST_DIR}") -add_library(gtest ${GTEST_DIR}/src/gtest-all.cc ${GTEST_DIR}/src/gtest_main.cc) -enable_testing(true) -#enable_testing() ? - #select the release build type by default to get optimization flags if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") @@ -50,7 +39,7 @@ list(APPEND CMAKE_MODULE_PATH ${gnss-sdr_project_SOURCE_DIR}/cmake/Modules) # Set the version information here set(VERSION_INFO_MAJOR_VERSION 0) -#set(VERSION_INFO_API_COMPAT 7) +#set(VERSION_INFO_API_COMPAT 1) set(VERSION_INFO_MINOR_VERSION 1) @@ -63,6 +52,21 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2") # Environment setup ######################################################################## + +################################################################################ +# Googletest - http://code.google.com/p/googletest/ +################################################################################ +set(GTEST_DIR $ENV{GTEST_DIR}) +if(GTEST_DIR) + set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) + include_directories(${GTEST_INCLUDE_DIRECTORIES}) + message("GTEST sources at ${GTEST_DIR}") +else() + # Download gtest ? + message( " GTEST_DIR environment variable not set. ") +endif(GTEST_DIR) + + ################################################################################ # Boost - http://www.boost.org ################################################################################ @@ -84,7 +88,7 @@ if(NOT Boost_FOUND) endif() set(Boost_USE_MULTITHREAD ON) set(Boost_USE_STATIC_LIBS OFF) -FIND_PACKAGE ( Boost COMPONENTS date_time filesystem system thread) +find_package(Boost COMPONENTS date_time filesystem system thread REQUIRED) #if ( NOT BOOST_DATE_TIME_FOUND ) # message(FATAL_ERROR "Boost date_time library not found " ) @@ -136,12 +140,17 @@ list(APPEND CMAKE_CXX_FLAGS ${GCC_GPERFTOOLS_FLAGS}) # Doxygen - http://www.stack.nl/~dimitri/doxygen/index.html ################################################################################ -include(FindDoxygen) -IF (DOXYGEN_EXECUTABLE) - message( STATUS "Setting Doxygen Generator" ) - add_custom_target(docs - COMMAND ${DOXYGEN_EXECUTABLE} VERBATIM) -ENDIF(DOXYGEN_EXECUTABLE) +find_package(Doxygen) +if(DOXYGEN_FOUND) + message( "Doxygen found" ) + configure_file(#${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in + ${CMAKE_SOURCE_DIR}/Doxyfile @ONLY) + add_custom_target(doc + ${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Generating API documentation with Doxygen" VERBATIM + ) +ENDIF(DOXYGEN_FOUND) @@ -247,6 +256,12 @@ endif(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) # For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall") + +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + #http://gcc.gnu.org/wiki/Visibility + add_definitions(-fvisibility=hidden) +endif() + # Set GPerftools related flags if it is available # See http://gperftools.googlecode.com/svn/trunk/README if(GPERFTOOLS_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e86bf6b6..cb55b915d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,5 @@ add_subdirectory(algorithms) add_subdirectory(core) add_subdirectory(main) - -#add_subdirectory(tests) +add_subdirectory(tests) #add_subdirectory(utils) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8f07399a1..c2ba5def3 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -17,35 +17,40 @@ # set(GTEST_DIR $ENV{GTEST_DIR}) -set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) -#add_library(gtest ${GTEST_DIR}/src/gtest-all.cc ${GTEST_DIR}/src/gtest_main.cc) - - -include_directories( - ${GTEST_INCLUDE_DIRECTORIES} - ${CMAKE_SOURCE_DIR}/src/core/system_parameters - ${CMAKE_SOURCE_DIR}/src/core/interfaces - ${CMAKE_SOURCE_DIR}/src/core/receiver - ${CMAKE_SOURCE_DIR}/src/core/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/resampler/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/libs - ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters - ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks - ${CMAKE_SOURCE_DIR}/src/algorithms/output_filter/adapters - ${GLOG_INCLUDE_DIRS} - ${GFlags_INCLUDE_DIRS} - ${GNURADIO_CORE_INCLUDE_DIRS} - ${GNURADIO_GRUEL_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} -) - -add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc) -target_link_libraries(run_tests ${Boost_LIBRARIES} glog gflags gtest gnss_sp_libs gnss_rx) - -install(TARGETS run_tests - DESTINATION ${CMAKE_SOURCE_DIR}/install - ) \ No newline at end of file +if(GTEST_DIR) + set(GTEST_INCLUDE_DIRECTORIES ${GTEST_DIR}/include ${GTEST_DIR} ${GTEST_DIR}/src) + add_library(gtest ${GTEST_DIR}/src/gtest-all.cc ${GTEST_DIR}/src/gtest_main.cc) + include_directories( + ${GTEST_INCLUDE_DIRECTORIES} + ${CMAKE_SOURCE_DIR}/src/core/system_parameters + ${CMAKE_SOURCE_DIR}/src/core/interfaces + ${CMAKE_SOURCE_DIR}/src/core/receiver + ${CMAKE_SOURCE_DIR}/src/core/libs + ${CMAKE_SOURCE_DIR}/src/algorithms/libs + ${CMAKE_SOURCE_DIR}/src/algorithms/resampler/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/tracking/libs + ${CMAKE_SOURCE_DIR}/src/algorithms/signal_source/adapters + ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/adapters + ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters + ${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks + ${CMAKE_SOURCE_DIR}/src/algorithms/output_filter/adapters + ${GLOG_INCLUDE_DIRS} + ${GFlags_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GNURADIO_GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ) + add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc) + target_link_libraries(run_tests ${Boost_LIBRARIES} glog gflags gtest gnss_sp_libs gnss_rx) + add_dependencies(run_tests googletest) + #add_test(tests_gnss ${CMAKE_SOURCE_DIR}/install/run_tests) + install(TARGETS run_tests DESTINATION ${CMAKE_SOURCE_DIR}/install) +else() + message (" ################################ ") + message (" Googletest not found! ") + message (" ################################ ") + message (" GNSS-SDR test system is based on Googletest, which has not been found ") + message (" Tests will not be build. Please download Googletest source code ") + message (" and define the environment variable GTEST_DIR pointing to its root folder") +endif(GTEST_DIR) \ No newline at end of file