mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-12 02:10:34 +00:00
Now gflags and google-glog are downloaded, configured, build and linked automatically when doing "make". Since gflags is a prerequisite for the proper functioning of glog, glog is always built locally when gflags is missing.
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@305 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
parent
74668e14dd
commit
6628e5e2d8
@ -97,17 +97,85 @@ find_package(Boost COMPONENTS date_time filesystem system thread REQUIRED)
|
||||
#endif()
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
# gflags - http://code.google.com/p/gflags/
|
||||
################################################################################
|
||||
|
||||
find_package(GFlags)
|
||||
|
||||
if (NOT GFlags_FOUND OR LOCAL_GFLAGS)
|
||||
message (" gflags library has not been found.")
|
||||
message (" gflags will be downloaded and built automatically ")
|
||||
message (" when doing 'make'. ")
|
||||
set(gflags_RELEASE 2.0 CACHE STRING "Local gflags release")
|
||||
set(gflags_MD5 "5fd4554d2ba84bf222a2fec0870d28df")
|
||||
ExternalProject_Add(
|
||||
gflags-${gflags_RELEASE}
|
||||
URL http://gflags.googlecode.com/files/gflags-${gflags_RELEASE}.zip
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download/gflags-${gflags_RELEASE}
|
||||
URL_MD5 ${gflags_MD5}
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${gflags_RELEASE}
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}
|
||||
#BUILD_IN_SOURCE 1
|
||||
BUILD_COMMAND make
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
|
||||
set(GFlags_INCLUDE_DIRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/src CACHE PATH "Local Gflags headers"
|
||||
)
|
||||
set(GFlags_LIBS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}gflags.a
|
||||
)
|
||||
set(GFlags_LIBRARY gflags-${gflags_RELEASE})
|
||||
set(gflags gflags-${gflags_RELEASE})
|
||||
set(GFlags_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/.libs )
|
||||
link_directories(${GFlags_LIBRARY_PATH})
|
||||
set(GFlags_lib ${GFlags_LIBS} CACHE FILEPATH "Local Gflags library")
|
||||
set(GFlags_LIBRARY_PATH ${GFlags_LIBS})
|
||||
set(LOCAL_GFLAGS true CACHE STRING "GFlags downloaded and build automatically")
|
||||
endif(NOT GFlags_FOUND OR LOCAL_GFLAGS)
|
||||
|
||||
include_directories(${GFlags_INCLUDE_DIRS})
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
# glog - http://code.google.com/p/google-glog/
|
||||
################################################################################
|
||||
|
||||
find_package(GLOG)
|
||||
if ( NOT GLOG_FOUND )
|
||||
message (" glog library has not been found.")
|
||||
if (NOT GLOG_FOUND OR LOCAL_GFLAGS)
|
||||
message (" glog library has not been found")
|
||||
if(LOCAL_GFLAGS)
|
||||
message(" or it is likely not linked to gflags.")
|
||||
endif(LOCAL_GFLAGS)
|
||||
message (" glog will be downloaded and built automatically ")
|
||||
message (" when doing 'make'. ")
|
||||
set(glog_RELEASE 0.3.2)
|
||||
set(glog_MD5 "897fbff90d91ea2b6d6e78c8cea641cc")
|
||||
if(LOCAL_GFLAGS)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
|
||||
"#!/bin/sh
|
||||
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
|
||||
export LDFLAGS=-L${CMAKE_CURRENT_BINARY_DIR}/gflags-${gflags_RELEASE}/.libs
|
||||
export LIBS=${GFlags_LIBS}
|
||||
export GFLAGS_LIBS=${GFlags_LIBS}
|
||||
../../thirdparty/glog/glog-${glog_RELEASE}/configure ")
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/tmp/configure_with_gflags
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
|
||||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
|
||||
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
||||
set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/configure_with_gflags)
|
||||
else(LOCAL_GFLAGS)
|
||||
set(GLOG_CONFIGURE ../../thirdparty/glog/glog-${glog_RELEASE}/configure)
|
||||
endif(LOCAL_GFLAGS)
|
||||
|
||||
ExternalProject_Add(
|
||||
glog-${glog_RELEASE}
|
||||
URL http://google-glog.googlecode.com/files/glog-${glog_RELEASE}.tar.gz
|
||||
@ -115,7 +183,7 @@ if ( NOT GLOG_FOUND )
|
||||
URL_MD5 ${glog_MD5}
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${glog_RELEASE}
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
|
||||
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR>
|
||||
BUILD_COMMAND make
|
||||
UPDATE_COMMAND ""
|
||||
PATCH_COMMAND ""
|
||||
@ -127,24 +195,11 @@ if ( NOT GLOG_FOUND )
|
||||
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/src
|
||||
)
|
||||
set(GLOG_LIBRARIES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog.so
|
||||
${CMAKE_CURRENT_BINARY_DIR}/glog-${glog_RELEASE}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog.a
|
||||
)
|
||||
set(glog ${GLOG_LIBRARIES})
|
||||
endif( NOT GLOG_FOUND)
|
||||
endif(NOT GLOG_FOUND OR LOCAL_GFLAGS)
|
||||
include_directories(${GLOG_INCLUDE_DIRS})
|
||||
|
||||
################################################################################
|
||||
# gflags - http://code.google.com/p/gflags/
|
||||
################################################################################
|
||||
|
||||
find_package(GFlags REQUIRED)
|
||||
if ( NOT GFlags_FOUND )
|
||||
message(FATAL_ERROR "gflags library not found! Please check http://code.google.com/p/gflags/")
|
||||
else( NOT GFlags_FOUND )
|
||||
message ( "gflags library found." )
|
||||
endif( NOT GFlags_FOUND )
|
||||
include_directories(${GFlags_INCLUDE_DIRS})
|
||||
|
||||
################################################################################
|
||||
# GPerftools - http://code.google.com/p/gperftools/
|
||||
################################################################################
|
||||
@ -248,7 +303,7 @@ include_directories(
|
||||
${GRUEL_INCLUDE_DIRS}
|
||||
${GNURADIO_CORE_INCLUDE_DIRS}
|
||||
${GLOG_INCLUDE_DIRS}
|
||||
${GFLAGS_INCLUDE_DIRS}
|
||||
${GFlags_INCLUDE_DIRS}
|
||||
${UHD_INCLUDE_DIRS}
|
||||
${GPERFTOOLS_INCLUDE_DIRS}
|
||||
)
|
||||
@ -296,8 +351,6 @@ list(APPEND CMAKE_CXX_FLAGS ${MY_CXX_FLAGS})
|
||||
########################################################################
|
||||
add_subdirectory(src)
|
||||
|
||||
#add_subdirectory(drivers)
|
||||
#add_subdirectory(firmware)
|
||||
|
||||
|
||||
|
||||
|
@ -7,92 +7,79 @@
|
||||
# GFlags_FOUND
|
||||
# GFlags_INCLUDE_DIRS
|
||||
# GFlags_LIBS
|
||||
# GFlags_MODEL_DIRS
|
||||
# GFlags_LIBRARY_DIRS
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_policy(SET CMP0011 OLD)
|
||||
|
||||
if (WIN32)
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
src/gflags.cc
|
||||
HINTS
|
||||
$ENV{GFLAGS_ROOT})
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
src/gflags.cc
|
||||
HINTS
|
||||
$ENV{GFLAGS_ROOT})
|
||||
else (WIN32)
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
libgflags.dylib
|
||||
HINTS
|
||||
/usr/local/lib
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
libgflags.dylib
|
||||
HINTS
|
||||
/usr/local/lib
|
||||
)
|
||||
endif (WIN32)
|
||||
|
||||
if (UNIX)
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
libgflags.so
|
||||
HINTS
|
||||
/usr/local/lib
|
||||
)
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
libgflags.so
|
||||
HINTS
|
||||
/usr/local/lib
|
||||
)
|
||||
endif (UNIX)
|
||||
|
||||
IF(GFlags_ROOT_DIR)
|
||||
# We are testing only a couple of files in the include directories
|
||||
if (WIN32)
|
||||
FIND_PATH(GFlags_INCLUDE_DIRS
|
||||
gflags/gflags.h
|
||||
HINTS
|
||||
${GFlags_ROOT_DIR}/src/windows
|
||||
)
|
||||
else (WIN32)
|
||||
FIND_PATH(GFlags_INCLUDE_DIRS
|
||||
gflags/gflags.h
|
||||
HINTS
|
||||
/usr/local/include
|
||||
${GFlags_ROOT_DIR}/src
|
||||
)
|
||||
endif (WIN32)
|
||||
# We are testing only a couple of files in the include directories
|
||||
if (WIN32)
|
||||
FIND_PATH(GFlags_INCLUDE_DIRS
|
||||
gflags/gflags.h
|
||||
HINTS
|
||||
${GFlags_ROOT_DIR}/src/windows
|
||||
)
|
||||
else (WIN32)
|
||||
FIND_PATH(GFlags_INCLUDE_DIRS
|
||||
gflags/gflags.h
|
||||
HINTS
|
||||
/usr/local/include
|
||||
${GFlags_ROOT_DIR}/src
|
||||
)
|
||||
endif (WIN32)
|
||||
|
||||
# Find the libraries
|
||||
SET(GFlags_LIBRARY_DIRS ${GFlags_ROOT_DIR})
|
||||
# Find the libraries
|
||||
SET(GFlags_LIBRARY_DIRS ${GFlags_ROOT_DIR})
|
||||
|
||||
# TODO: This can use some per-component linking
|
||||
if(MSVC)
|
||||
SET(_gflags_libpath_suffixes /Release /Debug)
|
||||
FIND_LIBRARY(GFlags_lib_release
|
||||
NAMES libgflags
|
||||
HINTS
|
||||
${GFlags_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES ${_gflags_libpath_suffixes})
|
||||
FIND_LIBRARY(GFlags_lib_debug
|
||||
NAMES libgflags-debug
|
||||
HINTS
|
||||
${GFlags_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES ${_gflags_libpath_suffixes})
|
||||
SET(GFlags_lib optimized ${GFlags_lib_release} debug ${GFlags_lib_debug})
|
||||
else()
|
||||
FIND_LIBRARY(GFlags_lib gflags ${GFlags_LIBRARY_DIRS})
|
||||
endif()
|
||||
# TODO: This can use some per-component linking
|
||||
if(MSVC)
|
||||
SET(_gflags_libpath_suffixes /Release /Debug)
|
||||
FIND_LIBRARY(GFlags_lib_release
|
||||
NAMES libgflags
|
||||
HINTS
|
||||
${GFlags_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES ${_gflags_libpath_suffixes})
|
||||
FIND_LIBRARY(GFlags_lib_debug
|
||||
NAMES libgflags-debug
|
||||
HINTS
|
||||
${GFlags_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES ${_gflags_libpath_suffixes})
|
||||
SET(GFlags_lib optimized ${GFlags_lib_release} debug ${GFlags_lib_debug})
|
||||
else()
|
||||
FIND_LIBRARY(GFlags_lib gflags ${GFlags_LIBRARY_DIRS})
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# set up include and link directory
|
||||
include_directories(
|
||||
${GFlags_INCLUDE_DIRS}
|
||||
)
|
||||
link_directories(${GFlags_LIBRARY_DIRS})
|
||||
|
||||
SET(GFlags_LIBS
|
||||
${GFlags_lib}
|
||||
)
|
||||
|
||||
SET(GFlags_FOUND true)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
GFlags_INCLUDE_DIRS
|
||||
)
|
||||
# set up include and link directory
|
||||
include_directories(${GFlags_INCLUDE_DIRS})
|
||||
link_directories(${GFlags_LIBRARY_DIRS})
|
||||
message("gflags library found at ${GFlags_lib}")
|
||||
SET(GFlags_LIBS ${GFlags_lib})
|
||||
SET(GFlags_FOUND true)
|
||||
MARK_AS_ADVANCED(GFlags_INCLUDE_DIRS)
|
||||
ELSE(GFlags_ROOT_DIR)
|
||||
FIND_PATH(GFlags_ROOT_DIR
|
||||
src
|
||||
)
|
||||
MARK_AS_ADVANCED(GFlags_ROOT_DIR)
|
||||
MESSAGE(SEND_ERROR "Cannot find Root directory of Google Flags")
|
||||
SET(GFlags_FOUND false)
|
||||
FIND_PATH(GFlags_ROOT_DIR src)
|
||||
MARK_AS_ADVANCED(GFlags_ROOT_DIR)
|
||||
MESSAGE(STATUS "Cannot find Root directory of gflags")
|
||||
SET(GFlags_FOUND false)
|
||||
ENDIF(GFlags_ROOT_DIR)
|
||||
|
@ -69,7 +69,7 @@ else(MSVC)
|
||||
endif(APPLE)
|
||||
endif(MSVC)
|
||||
|
||||
message("glog library = " ${GLOG_LIBRARIES})
|
||||
message("glog library found at ${GLOG_LIBRARIES}")
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set GLOG_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
|
@ -37,4 +37,4 @@ include_directories(
|
||||
)
|
||||
|
||||
add_library(pvt_lib ${PVT_LIB_SOURCES})
|
||||
target_link_libraries(pvt_lib ${Boost_LIBRARIES} ${ARMADILLO_LIBRARY})
|
||||
target_link_libraries(pvt_lib ${Boost_LIBRARIES} ${GFlags_LIBS} ${ARMADILLO_LIBRARY})
|
@ -29,10 +29,11 @@ include_directories(
|
||||
)
|
||||
|
||||
add_executable(gnss-sdr ${CMAKE_CURRENT_SOURCE_DIR}/main.cc)
|
||||
|
||||
target_link_libraries(gnss-sdr ${Boost_LIBRARIES} ${GLOG_LIBRARIES} gflags gnss_sp_libs gnss_rx)
|
||||
|
||||
target_link_libraries(gnss-sdr ${Boost_LIBRARIES} ${GLOG_LIBRARIES} ${GFlags_LIBS} gnss_sp_libs gnss_rx)
|
||||
#add_dependencies(gnss-sdr gflags-${glags_RELEASE} glog-${glog_RELEASE} STATIC)############
|
||||
install(TARGETS gnss-sdr
|
||||
DESTINATION ${CMAKE_SOURCE_DIR}/install
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -80,8 +80,10 @@ include_directories(
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc)
|
||||
target_link_libraries(run_tests ${Boost_LIBRARIES} ${GLOG_LIBRARIES} gflags ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx)
|
||||
target_link_libraries(run_tests ${Boost_LIBRARIES} ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx)
|
||||
|
||||
install(TARGETS run_tests DESTINATION ${CMAKE_SOURCE_DIR}/install)
|
||||
|
||||
#########################################################
|
||||
@ -96,7 +98,7 @@ add_executable(control_thread_test EXCLUDE_FROM_ALL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/control_thread/control_message_factory_test.cc
|
||||
)
|
||||
target_link_libraries(control_thread_test ${Boost_LIBRARIES} ${GLOG_LIBRARIES} gflags ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx)
|
||||
target_link_libraries(control_thread_test ${Boost_LIBRARIES} ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx)
|
||||
add_test(control_thread_test control_thread_test)
|
||||
|
||||
add_executable(gnss_block_test EXCLUDE_FROM_ALL
|
||||
@ -110,7 +112,7 @@ add_executable(gnss_block_test EXCLUDE_FROM_ALL
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/file_output_filter_test.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/gnss_block/gnss_block_factory_test.cc
|
||||
)
|
||||
target_link_libraries(gnss_block_test ${Boost_LIBRARIES} ${GLOG_LIBRARIES} gflags ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx)
|
||||
target_link_libraries(gnss_block_test ${Boost_LIBRARIES} ${GFLAGS_LIBS} ${GLOG_LIBRARIES} ${GTEST_LIBRARIES} gnss_sp_libs gnss_rx)
|
||||
add_test(gnss_block_test gnss_block_test)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user