Commit 561fb597 authored by Rashad Kanavath's avatar Rashad Kanavath
Browse files

COMP: add FindGBenchmark.cmake and put find_package there

parent aa14a3e0
# Find the Google Benchmark library
# Defines:
# GBENCHMARK_INCLUDE_DIR - gbenchmark include directory
# GBENCHMARK_LIBRARY - gbenchmark library file
# GBENCHMARK_FOUND - TRUE if gbenchmark is found
if (GBENCHMARK_INCLUDE_DIR)
#check cache
set(GBENCHMARK_FIND_QUIETLY TRUE)
endif ()
if (NOT GBENCHMARK_INCLUDE_DIR)
find_path(GBENCHMARK_INCLUDE_DIR NAMES benchmark.h PATH_SUFFIXES benchmark)
set(GBENCHMARK_INCLUDE_DIR ${GBENCHMARK_INCLUDE_DIR}/benchmark CACHE PATH "Google.benchmark include direcory")
endif ()
mark_as_advanced(GBENCHMARK_INCLUDE_DIR)
find_library(GBENCHMARK_LIBRARY NAMES benchmark)
mark_as_advanced(GBENCHMARK_LIBRARY)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GBENCHMARK
REQUIRED_VARS GBENCHMARK_LIBRARY GBENCHMARK_INCLUDE_DIR
)
#VERSION_VAR GBENCHMARK_VERSION_STRING
set(GBENCHMARK_LIBRARIES ${GBENCHMARK_LIBRARY})
set(GBENCHMARK_INCLUDE_DIRS ${GBENCHMARK_INCLUDE_DIR})
# cmake_minimum_required(VERSION 2.6)
# SET(CMAKE_MODULE_PATH "${${PROJECT_NAME}_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
otb_module_test()
message(STATUS "UT: ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
#===== find_cots function
include(FindPackageHandleStandardArgs)
function(find_cots NAME inc_file lib_file target)
string(TOLOWER ${NAME} name)
MESSAGE(STATUS "search: ${NAME}/${name} in: VAR=${${NAME}_DIR} $VAR=$ENV{${NAME}_DIR}")
set(THE_ENV "$ENV{${NAME}_DIR}")
# MESSAGE(STATUS "THE_ENV: ${THE_ENV}")
# The root directory
if ((NOT "${${NAME}_DIR}" STREQUAL "") AND EXISTS "${${NAME}_DIR}" AND IS_DIRECTORY "${${NAME}_DIR}")
set(DIR "${${NAME}_DIR}")
# nothing more to do
elseif((NOT "${THE_ENV}" STREQUAL "") AND EXISTS "${THE_ENV}" AND IS_DIRECTORY "${THE_ENV}")
# MESSAGE(STATUS "setting from ${NAME}_DIR: ${THE_ENV}")
set(DIR "${THE_ENV}")
endif()
# MESSAGE(STATUS "DIR: ${DIR}")
set(${NAME}_DIR ${DIR} )
# The include/ dir
find_path(${NAME}_INCLUDE_DIR
NAMES ${inc_file}
HINTS ${DIR}/include
PATHS ${DIR}/include)
# The lib/ dir
find_library(${NAME}_LIBRARY
NAMES ${lib_file}
HINTS ${DIR}/lib
PATHS ${DIR}/lib)
find_package_handle_standard_args(${NAME} DEFAULT_MSG ${NAME}_DIR ${NAME}_LIBRARY ${NAME}_INCLUDE_DIR)
if (FIND_COTS_DEBUG)
message(STATUS "${NAME}_DIR: ${${NAME}_DIR}")
message(STATUS "${NAME}_INCLUDE_DIR: ${${NAME}_INCLUDE_DIR}")
message(STATUS "${NAME}_LIBRARY: ${${NAME}_LIBRARY}")
endif()
if(${NAME}_FOUND)
set(${NAME}_DIR ${${NAME}_DIR} CACHE PATH "Path to ${NAME} root installation directory" FORCE)
set(${NAME}_LIBRARY_DIRS ${${NAME}_DIR}/lib CACHE PATH "Path to ${NAME} libraries" FORCE)
endif()
# set(${NAME}_INCLUDE_DIR ${NAME}_INCLUDE_DIR PARENT_SCOPE)
# set(${NAME}_LIBRARY ${NAME}_LIBRARY PARENT_SCOPE)
set(${NAME}_FOUND ${${NAME}_FOUND} PARENT_SCOPE)
endfunction()
# Common dirs
include_directories(${PROJECT_SOURCE_DIR}/Modules/ThirdParty/OssimPlugins/src/ossim ${OSSIM_INCLUDE_DIR})
#include_directories(${PROJECT_SOURCE_DIR}/Modules/ThirdParty/OssimPlugins/src/ossim ${OSSIM_INCLUDE_DIR})
#==== UT for utilities
add_executable(ossimStringUtilitiesTest ossimStringUtilitiesTest.cpp)
target_link_libraries(ossimStringUtilitiesTest
otbossimplugins
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
otb_module_target_label(ossimStringUtilitiesTest)
otb_add_test(NAME ossimStringUtilitiesTest COMMAND ossimStringUtilitiesTest )
add_executable(ossimTimeUtilitiesTest ossimTimeUtilitiesTest.cpp)
target_link_libraries(ossimTimeUtilitiesTest
# ${OTBOssim_LIBRARIES}
otbossimplugins
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
otb_module_target_label(ossimTimeUtilitiesTest)
otb_add_test(NAME ossimTimeUtilitiesTest COMMAND ossimTimeUtilitiesTest )
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
add_executable(ossimStringUtilitiesTest ossimStringUtilitiesTest.cpp)
target_link_libraries(ossimStringUtilitiesTest
otbossimplugins
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
otb_module_target_label(ossimStringUtilitiesTest)
otb_add_test(NAME ossimStringUtilitiesTest COMMAND ossimStringUtilitiesTest )
add_executable(ossimTimeUtilitiesTest ossimTimeUtilitiesTest.cpp)
target_link_libraries(ossimTimeUtilitiesTest
# ${OTBOssim_LIBRARIES}
otbossimplugins
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
otb_module_target_label(ossimTimeUtilitiesTest)
otb_add_test(NAME ossimTimeUtilitiesTest COMMAND ossimTimeUtilitiesTest )
else()
message(STATUS "Boost unit test framework not found, ossimStringUtilitiesTest and ossimTimeUtilitiesTest will be skipped.")
endif()
#==== Benchmarking Time conversion
# (requires google.benchmark)
find_cots(GBenchmark benchmark/benchmark.h benchmark "OSSIM Time utilities")
if (GBenchmark_FOUND)
find_package(GBenchmark)
if (GBENCHMARK_FOUND)
add_executable(ossimTimeUtilitiesBench ossimTimeUtilitiesBench.cpp)
include_directories(${GBenchmark_INCLUDE_DIR})
include_directories(${GBENCHMARK_INCLUDE_DIRS})
target_link_libraries(ossimTimeUtilitiesBench
otbossimplugins
${GBenchmark_LIBRARY})
${GBENCHMARK_LIBRARIES})
otb_module_target_label(ossimTimeUtilitiesBench)
else()
message(STATUS "Google.benchmark not found, OSSIM Time utilities benchmarking ignored.")
message(STATUS "Google.benchmark not found, ossimTimeUtilitiesBench will be skipped.")
endif()
......@@ -102,8 +54,6 @@ add_executable(ossimTerraSarXSarSensorModelTest ossimTerraSarXSarSensorModelTest
target_link_libraries(ossimTerraSarXSarSensorModelTest otbossimplugins)
otb_module_target_label(ossimTerraSarXSarSensorModelTest)
#Use ctest
# enable_testing()
otb_add_test(NAME ossimSarSensorModelTest COMMAND ossimSarSensorModelTest )
#S1 tests
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment