1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-29 18:34:51 +00:00

Merge branch 'cmake-glog' into next

Make it easier to build the code with Xcode and in Debug mode.
This commit is contained in:
Carles Fernandez 2019-11-11 08:31:38 +01:00
commit 2e4517a3b9
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 178 additions and 113 deletions

View File

@ -373,6 +373,9 @@ endif()
if(CMAKE_MAKE_PROGRAM MATCHES "ninja") if(CMAKE_MAKE_PROGRAM MATCHES "ninja")
set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "ninja") set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "ninja")
endif() endif()
if(CMAKE_MAKE_PROGRAM MATCHES "xcodebuild")
set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "xcodebuild")
endif()
if(NOT CMAKE_MAKE_PROGRAM_PRETTY_NAME) if(NOT CMAKE_MAKE_PROGRAM_PRETTY_NAME)
set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "${CMAKE_MAKE_PROGRAM}") set(CMAKE_MAKE_PROGRAM_PRETTY_NAME "${CMAKE_MAKE_PROGRAM}")
endif() endif()
@ -1079,7 +1082,11 @@ set_package_properties(GFLAGS PROPERTIES
if(NOT GFLAGS_FOUND) if(NOT GFLAGS_FOUND)
message(STATUS " gflags library has not been found.") message(STATUS " gflags library has not been found.")
message(STATUS " gflags v${GNSSSDR_GFLAGS_LOCAL_VERSION} will be downloaded and built automatically") message(STATUS " gflags v${GNSSSDR_GFLAGS_LOCAL_VERSION} will be downloaded and built automatically")
message(STATUS " when doing 'make'.") message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'.")
set(GFLAGS_BUILD_COMMAND ${CMAKE_MAKE_PROGRAM})
if(CMAKE_GENERATOR STREQUAL Xcode)
set(GFLAGS_BUILD_COMMAND "xcodebuild" "-configuration" "${CMAKE_BUILD_TYPE}")
endif()
if(CMAKE_VERSION VERSION_LESS 3.2) if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} ExternalProject_Add(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
@ -1088,8 +1095,8 @@ if(NOT GFLAGS_FOUND)
GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} BUILD_COMMAND ${GFLAGS_BUILD_COMMAND}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
@ -1101,8 +1108,8 @@ if(NOT GFLAGS_FOUND)
GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION} GIT_TAG v${GNSSSDR_GFLAGS_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}
CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=ON -DBUILD_gflags_nothreads_LIB=OFF -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} BUILD_COMMAND ${GFLAGS_BUILD_COMMAND}
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX} BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""
@ -1113,21 +1120,28 @@ if(NOT GFLAGS_FOUND)
set(GFlags_INCLUDE_DIRS set(GFlags_INCLUDE_DIRS
${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include CACHE PATH "Local Gflags headers" ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include CACHE PATH "Local Gflags headers"
) )
if((CMAKE_BUILD_TYPE MATCHES Debug) AND (CMAKE_VERSION VERSION_GREATER "3.0.2"))
file(GLOB GFlags_SHARED_LIBS set(GFLAGS_DEBUG_POSTFIX "_debug")
"${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_SHARED_LIBRARY_SUFFIX}*" endif()
set(GFlags_LIBS
"${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${GFLAGS_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
) )
if(CMAKE_GENERATOR STREQUAL Xcode)
set(GFlags_LIBS
"${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_BUILD_TYPE}/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${GFLAGS_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
endif()
if(NOT TARGET Gflags::gflags) if(NOT TARGET Gflags::gflags)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include) file(MAKE_DIRECTORY ${GFlags_INCLUDE_DIRS})
add_library(Gflags::gflags STATIC IMPORTED) add_library(Gflags::gflags STATIC IMPORTED)
add_dependencies(Gflags::gflags gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) add_dependencies(Gflags::gflags gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION})
set_target_properties(Gflags::gflags PROPERTIES set_target_properties(Gflags::gflags PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}" IMPORTED_LOCATION "${GFlags_LIBS}"
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include" INCLUDE_DIRECTORIES "${GFlags_INCLUDE_DIRS}"
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/include" INTERFACE_INCLUDE_DIRECTORIES "${GFlags_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gflags${CMAKE_STATIC_LIBRARY_SUFFIX}" INTERFACE_LINK_LIBRARIES "${GFlags_LIBS}"
) )
endif() endif()
@ -1142,11 +1156,8 @@ endif()
################################################################################ ################################################################################
# glog - https://github.com/google/glog # glog - https://github.com/google/glog
################################################################################ ################################################################################
if(NOT ${ENABLE_OWN_GLOG}) if(NOT ENABLE_OWN_GLOG AND NOT ${LOCAL_GFLAGS})
find_package(GLOG) find_package(GLOG)
if(GLOG_INCLUDE_DIRS)
set(GLOG_FOUND ON)
endif()
endif() endif()
set_package_properties(GLOG PROPERTIES set_package_properties(GLOG PROPERTIES
PURPOSE "Used for runtime internal logging." PURPOSE "Used for runtime internal logging."
@ -1158,29 +1169,44 @@ if(NOT GLOG_FOUND OR ${LOCAL_GFLAGS})
message(STATUS " or it is likely not linked to gflags.") message(STATUS " or it is likely not linked to gflags.")
endif() endif()
message(STATUS " glog v${GNSSSDR_GLOG_LOCAL_VERSION} will be downloaded and built automatically") message(STATUS " glog v${GNSSSDR_GLOG_LOCAL_VERSION} will be downloaded and built automatically")
message(STATUS " when doing 'make'.") message(STATUS " when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'.")
if(NOT ${LOCAL_GFLAGS}) if(NOT ${LOCAL_GFLAGS})
add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED) add_library(gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} UNKNOWN IMPORTED)
set_property(TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}") set_property(TARGET gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION} PROPERTY IMPORTED_LOCATION "${GFlags_LIBS}")
string(REPLACE /include "" GFLAGS_PREFIX_PATH ${GFlags_INCLUDE_DIRS})
else()
set(GFLAGS_PREFIX_PATH ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION})
endif() endif()
set(TARGET_GFLAGS gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}) set(TARGET_GFLAGS gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION})
if(${LOCAL_GFLAGS}) set(GLOG_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM})
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS}) set(GLOG_BUILD_BYPRODUCTS
set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib) ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
else() )
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS}) if(CMAKE_GENERATOR STREQUAL Xcode)
set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS}) set(GLOG_MAKE_PROGRAM "xcodebuild" "-configuration" "${CMAKE_BUILD_TYPE}")
endif() endif()
if(OS_IS_MACOSX) if(CMAKE_BUILD_TYPE MATCHES Debug)
set(GFLAGS_LIBRARIES_TO_LINK "${GFLAGS_LIBRARIES_TO_LINK} -lc++") set(GLOG_DEBUG_POSTFIX "d")
set(GLOG_EXPORT_CXX_LIBRARIES "export CXXFLAGS=\"-stdlib=libc++\"")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(GLOG_EXPORT_C_COMPILER "export CC=clang")
set(GLOG_EXPORT_CXX_COMPILER "export CXX=clang++")
endif() endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags if(CMAKE_VERSION VERSION_LESS 3.2)
if(CMAKE_VERSION VERSION_LESS 3.0)
if(${LOCAL_GFLAGS})
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_SHARED_LIBS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${CMAKE_CURRENT_BINARY_DIR}/gflags-${GNSSSDR_GFLAGS_LOCAL_VERSION}/lib)
else()
set(GFLAGS_LIBRARIES_TO_LINK ${GFlags_LIBS})
set(GFLAGS_LIBRARY_DIR_TO_LINK ${GFlags_LIBRARY_DIRS})
endif()
if(OS_IS_MACOSX)
set(GFLAGS_LIBRARIES_TO_LINK "${GFLAGS_LIBRARIES_TO_LINK} -lc++")
set(GLOG_EXPORT_CXX_LIBRARIES "export CXXFLAGS=\"-stdlib=libc++\"")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(GLOG_EXPORT_C_COMPILER "export CC=clang")
set(GLOG_EXPORT_CXX_COMPILER "export CXX=clang++")
endif()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
"#!/bin/sh "#!/bin/sh
export CPPFLAGS=-I${GFlags_INCLUDE_DIRS} export CPPFLAGS=-I${GFlags_INCLUDE_DIRS}
export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK} export LDFLAGS=-L${GFLAGS_LIBRARY_DIR_TO_LINK}
@ -1194,67 +1220,108 @@ automake --add-missing
autoreconf -vfi autoreconf -vfi
cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} cd ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure" ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure"
) )
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags file(COPY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/tmp/configure_with_gflags
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
GROUP_EXECUTE WORLD_READ WORLD_EXECUTE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
) )
set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure_with_gflags) set(GLOG_CONFIGURE ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/configure_with_gflags)
# Ensure that aclocal and libtool are present # Ensure that aclocal and libtool are present
if(OS_IS_LINUX) if(OS_IS_LINUX)
if(EXISTS "/usr/bin/libtoolize") if(EXISTS "/usr/bin/libtoolize")
if(EXISTS "/usr/bin/aclocal" OR if(EXISTS "/usr/bin/aclocal" OR
EXISTS "/usr/bin/aclocal-1.16" OR EXISTS "/usr/bin/aclocal-1.16" OR
EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.15" OR
EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.14" OR
EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.13" OR
EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.11" OR
EXISTS "/usr/bin/aclocal-1.10") EXISTS "/usr/bin/aclocal-1.10")
# Everything ok, we can move on # Everything ok, we can move on
else() else()
message(" aclocal has not been found.") message(" aclocal has not been found.")
message(" You can try to install it by typing:") message(" You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum groupinstall 'Development Tools'") message(" sudo yum groupinstall 'Development Tools'")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(" sudo zypper install automake") message(" sudo zypper install automake")
else()
message(" sudo apt-get install automake")
endif()
message(FATAL_ERROR "aclocal is required to build glog from source")
endif()
else() else()
message(" sudo apt-get install automake") message(" libtool has not been found.")
message(" You can try to install it by typing:")
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat")
message(" sudo yum groupinstall 'Development Tools'")
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE")
message(" sudo zypper install libtoool")
else()
message(" sudo apt-get install libtool")
endif()
message(FATAL_ERROR "libtool is required to build glog from source")
endif() endif()
message(FATAL_ERROR "aclocal is required to build glog from source")
endif() endif()
else()
message(" libtool has not been found.") if(GLOG_MAKE_PROGRAM MATCHES "ninja")
message(" You can try to install it by typing:") find_program(GLOG_MAKE_EXECUTABLE make
if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") PATHS
message(" sudo yum groupinstall 'Development Tools'") /usr/bin
elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") /usr/local/bin
message(" sudo zypper install libtoool") )
else() if(NOT GLOG_MAKE_EXECUTABLE)
message(" sudo apt-get install libtool") message(FATAL_ERROR "make is required to build Glog from source.")
endif()
set(GLOG_MAKE_PROGRAM ${GLOG_MAKE_EXECUTABLE})
endif() endif()
message(FATAL_ERROR "libtool is required to build glog from source") ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION}
DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/google/glog/
GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR>
BUILD_COMMAND "${GLOG_MAKE_PROGRAM}"
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
set(GLOG_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
)
set(GLOG_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src
)
else() # CMake > 3.0 but < 3.2
ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION}
DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
GIT_REPOSITORY https://github.com/google/glog/
GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_PREFIX_PATH=${GFLAGS_PREFIX_PATH}
BUILD_COMMAND "${GLOG_MAKE_PROGRAM}"
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
set(GLOG_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}glog${GLOG_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
)
set(GLOG_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
${GFlags_INCLUDE_DIRS}
)
endif() endif()
endif() else() # CMake > 3.2
set(GLOG_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM})
if(GLOG_MAKE_PROGRAM MATCHES "ninja")
find_program(GLOG_MAKE_EXECUTABLE make
PATHS
/usr/bin
/usr/local/bin
)
if(NOT GLOG_MAKE_EXECUTABLE)
message(FATAL_ERROR "make is required to build Glog from source.")
endif()
set(GLOG_MAKE_PROGRAM ${GLOG_MAKE_EXECUTABLE})
endif()
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION} ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION}
DEPENDS ${TARGET_GFLAGS} DEPENDS ${TARGET_GFLAGS}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
@ -1262,51 +1329,42 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/c
GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR> CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_PREFIX_PATH=${GFLAGS_PREFIX_PATH}
BUILD_COMMAND "${GLOG_MAKE_PROGRAM}" BUILD_COMMAND "${GLOG_MAKE_PROGRAM}"
BUILD_BYPRODUCTS ${GLOG_BUILD_BYPRODUCTS}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""
INSTALL_COMMAND "" INSTALL_COMMAND ""
) )
else() set(GLOG_LIBRARIES
ExternalProject_Add(glog-${GNSSSDR_GLOG_LOCAL_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/${CMAKE_FIND_LIBRARY_PREFIXES}glog${GLOG_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
DEPENDS ${TARGET_GFLAGS} )
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION} set(GLOG_INCLUDE_DIRS
GIT_REPOSITORY https://github.com/google/glog/ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src
GIT_TAG v${GNSSSDR_GLOG_LOCAL_VERSION} ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION} ${GFlags_INCLUDE_DIRS}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}
CONFIGURE_COMMAND ${GLOG_CONFIGURE} --prefix=<INSTALL_DIR>
BUILD_COMMAND "${GLOG_MAKE_PROGRAM}"
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
) )
endif() endif()
add_dependencies(glog-${GNSSSDR_GLOG_LOCAL_VERSION} Gflags::gflags) add_dependencies(glog-${GNSSSDR_GLOG_LOCAL_VERSION} Gflags::gflags)
# Set up variables if(CMAKE_GENERATOR STREQUAL Xcode)
set(GLOG_INCLUDE_DIRS set(GLOG_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src/ ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/${CMAKE_BUILD_TYPE}/${CMAKE_FIND_LIBRARY_PREFIXES}glog${GLOG_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src )
) endif()
set(GLOG_LIBRARIES
${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}
)
# Create Glog::glog target # Create Glog::glog target
if(NOT TARGET Glog::glog) if(NOT TARGET Glog::glog)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src) file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/src) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION})
add_library(Glog::glog STATIC IMPORTED) add_library(Glog::glog STATIC IMPORTED)
add_dependencies(Glog::glog glog-${GNSSSDR_GLOG_LOCAL_VERSION}) add_dependencies(Glog::glog glog-${GNSSSDR_GLOG_LOCAL_VERSION})
set_target_properties(Glog::glog PROPERTIES set_target_properties(Glog::glog PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}" IMPORTED_LOCATION "${GLOG_LIBRARIES}"
INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}" INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}"
INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}" INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${CMAKE_CURRENT_BINARY_DIR}/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/.libs/${CMAKE_FIND_LIBRARY_PREFIXES}glog${CMAKE_STATIC_LIBRARY_SUFFIX}" INTERFACE_LINK_LIBRARIES "${GLOG_LIBRARIES}"
) )
endif() endif()

View File

@ -263,6 +263,10 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
set(TOOLCHAIN_ARG "-DCMAKE_CXX_FLAGS=-Wno-deprecated") set(TOOLCHAIN_ARG "-DCMAKE_CXX_FLAGS=-Wno-deprecated")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
endif() endif()
set(GPSTK_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM}")
if(CMAKE_GENERATOR STREQUAL Xcode)
set(GPSTK_BUILD_COMMAND "xcodebuild" "-configuration" "${CMAKE_BUILD_TYPE}")
endif()
include(GNUInstallDirs) include(GNUInstallDirs)
if(CMAKE_VERSION VERSION_LESS 3.2) if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} ExternalProject_Add(gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
@ -270,7 +274,8 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND ${GPSTK_BUILD_COMMAND}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""
) )
@ -280,7 +285,8 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA)
GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION} GIT_TAG v${GNSSSDR_GPSTK_LOCAL_VERSION}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}
CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF CMAKE_ARGS ${GTEST_COMPILER} ${TOOLCHAIN_ARG} -DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install -DBUILD_EXT=OFF -DBUILD_PYTHON=OFF -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
BUILD_COMMAND ${GPSTK_BUILD_COMMAND}
BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX} BUILD_BYPRODUCTS ${CMAKE_SOURCE_DIR}/thirdparty/gpstk-${GNSSSDR_GPSTK_LOCAL_VERSION}/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}gpstk${CMAKE_SHARED_LIBRARY_SUFFIX}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PATCH_COMMAND "" PATCH_COMMAND ""

View File

@ -65,6 +65,7 @@ if(Boost_FOUND)
Boost::serialization Boost::serialization
${GPSTK_LIBRARY} ${GPSTK_LIBRARY}
Gflags::gflags Gflags::gflags
Threads::Threads
algorithms_libs algorithms_libs
core_receiver core_receiver
core_system_parameters core_system_parameters