mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 12:10:34 +00:00
Add modern CMake targets for volk_gnsssdr
This commit is contained in:
parent
928c545c84
commit
f3eef2f513
@ -23,7 +23,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
||||
message(WARNING "In-tree build is bad practice. Try 'cd build && cmake ../' ")
|
||||
endif()
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
project(gnss-sdr CXX C)
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||
file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@ -324,7 +324,7 @@ endif()
|
||||
################################################################################
|
||||
# Minimum required versions
|
||||
################################################################################
|
||||
set(GNSSSDR_CMAKE_MIN_VERSION "2.8.8")
|
||||
set(GNSSSDR_CMAKE_MIN_VERSION "2.8.12")
|
||||
set(GNSSSDR_GCC_MIN_VERSION "4.7.2")
|
||||
set(GNSSSDR_CLANG_MIN_VERSION "3.4.0")
|
||||
set(GNSSSDR_APPLECLANG_MIN_VERSION "500")
|
||||
|
@ -20,7 +20,7 @@
|
||||
########################################################################
|
||||
# Project setup
|
||||
########################################################################
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel")
|
||||
project(volk_gnsssdr)
|
||||
enable_language(CXX)
|
||||
@ -135,7 +135,7 @@ message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.")
|
||||
|
||||
set(VERSION_INFO_MAJOR_VERSION 0)
|
||||
set(VERSION_INFO_MINOR_VERSION 0)
|
||||
set(VERSION_INFO_MAINT_VERSION 10)
|
||||
set(VERSION_INFO_MAINT_VERSION 10.git)
|
||||
include(VolkVersion) #setup version info
|
||||
|
||||
|
||||
@ -369,6 +369,10 @@ install(
|
||||
COMPONENT "volk_gnsssdr_devel"
|
||||
)
|
||||
|
||||
install(EXPORT VOLK_GNSSSDR-export FILE VolkGnsssdrTargets.cmake
|
||||
NAMESPACE VolkGnsssdr:: DESTINATION ${CMAKE_MODULES_DIR}/volk_gnsssdr
|
||||
)
|
||||
|
||||
########################################################################
|
||||
# Option to enable QA testing, on by default
|
||||
########################################################################
|
||||
|
@ -15,33 +15,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(PC_VOLK_GNSSSDR volk_gnsssdr)
|
||||
get_filename_component(VOLK_GNSSSDR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
find_path(
|
||||
VOLK_GNSSSDR_INCLUDE_DIRS
|
||||
NAMES volk_gnsssdr/volk_gnsssdr.h
|
||||
HINTS $ENV{VOLK_DIR}/include
|
||||
${PC_VOLK_INCLUDEDIR}
|
||||
PATHS /usr/local/include
|
||||
/usr/include
|
||||
/opt/local/include
|
||||
"@CMAKE_INSTALL_PREFIX@/include"
|
||||
)
|
||||
|
||||
find_library(
|
||||
VOLK_GNSSSDR_LIBRARIES
|
||||
NAMES volk_gnsssdr
|
||||
HINTS $ENV{VOLK_DIR}/lib
|
||||
${PC_VOLK_LIBDIR}
|
||||
PATHS /usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
/opt/local/lib
|
||||
"@CMAKE_INSTALL_PREFIX@/lib"
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VOLKGNSSSDR DEFAULT_MSG VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS)
|
||||
mark_as_advanced(VOLK_GNSSSDR_LIBRARIES VOLK_GNSSSDR_INCLUDE_DIRS)
|
||||
if(NOT TARGET VolkGnsssdr::volkgnsssdr)
|
||||
include("${VOLK_GNSSSDR_CMAKE_DIR}/VolkGnsssdrTargets.cmake")
|
||||
endif()
|
||||
|
@ -569,71 +569,67 @@ if(MSVC)
|
||||
set_source_files_properties(${volk_gnsssdr_sources} PROPERTIES LANGUAGE CXX)
|
||||
endif()
|
||||
|
||||
#Use object library for faster overall build in newer versions of cmake
|
||||
if(CMAKE_VERSION VERSION_GREATER "2.8.7")
|
||||
#Create a volk_gnsssdr object library (requires cmake >= 2.8.8)
|
||||
add_library(volk_gnsssdr_obj OBJECT ${volk_gnsssdr_sources})
|
||||
#Create a volk_gnsssdr object library
|
||||
add_library(volk_gnsssdr_obj OBJECT ${volk_gnsssdr_sources})
|
||||
target_include_directories(volk_gnsssdr_obj
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/kernels
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
#Add dynamic library
|
||||
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries} ${Boost_LIBRARIES})
|
||||
#Add dynamic library
|
||||
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries} m)
|
||||
target_include_directories(volk_gnsssdr
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/kernels
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
#Configure target properties
|
||||
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
|
||||
set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER})
|
||||
set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS")
|
||||
#Configure target properties
|
||||
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
|
||||
set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER})
|
||||
set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS")
|
||||
|
||||
#Install locations
|
||||
install(TARGETS volk_gnsssdr
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
|
||||
RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file
|
||||
#Install locations
|
||||
install(TARGETS volk_gnsssdr
|
||||
EXPORT VOLK_GNSSSDR-export
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
|
||||
RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file
|
||||
)
|
||||
|
||||
#Configure static library
|
||||
if(ENABLE_STATIC_LIBS)
|
||||
add_library(volk_gnsssdr_static STATIC $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
target_link_libraries(volk_gnsssdr_static ${volk_gnsssdr_libraries} pthread m)
|
||||
target_include_directories(volk_gnsssdr_static
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
PUBLIC $<INSTALL_INTERFACE:include>
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/kernels
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
#Configure static library
|
||||
if(ENABLE_STATIC_LIBS)
|
||||
add_library(volk_gnsssdr_static STATIC $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
|
||||
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
||||
|
||||
install(TARGETS volk_gnsssdr_static
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel"
|
||||
)
|
||||
endif()
|
||||
|
||||
#Older cmake versions (slower to build when building dynamic/static libs)
|
||||
else()
|
||||
#create the volk_gnsssdr runtime library
|
||||
add_library(volk_gnsssdr SHARED ${volk_gnsssdr_sources})
|
||||
target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries})
|
||||
set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER})
|
||||
set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS")
|
||||
|
||||
install(TARGETS volk_gnsssdr
|
||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
|
||||
RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file
|
||||
install(TARGETS volk_gnsssdr_static
|
||||
EXPORT VOLK_GNSSSDR-export
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel"
|
||||
)
|
||||
|
||||
if(ENABLE_STATIC_LIBS)
|
||||
add_library(volk_gnsssdr_static STATIC ${volk_gnsssdr_sources})
|
||||
|
||||
if(NOT WIN32)
|
||||
set_target_properties(volk_gnsssdr_static
|
||||
PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
||||
endif()
|
||||
|
||||
install(TARGETS volk_gnsssdr_static
|
||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
|
||||
)
|
||||
endif()
|
||||
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
||||
endif()
|
||||
|
||||
########################################################################
|
||||
# Build the QA test application
|
||||
########################################################################
|
||||
if(ENABLE_TESTING)
|
||||
|
||||
#include Boost headers
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.unittest)
|
||||
@ -647,11 +643,11 @@ if(ENABLE_TESTING)
|
||||
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc
|
||||
TARGET_DEPS volk_gnsssdr
|
||||
)
|
||||
)
|
||||
|
||||
foreach(kernel ${h_files})
|
||||
get_filename_component(kernel ${kernel} NAME)
|
||||
string(REPLACE ".h" "" kernel ${kernel})
|
||||
volk_add_test(${kernel} "volk_gnsssdr_test_all")
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user