mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-20 22:17:03 +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 ../' ")
|
message(WARNING "In-tree build is bad practice. Try 'cd build && cmake ../' ")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
project(gnss-sdr CXX C)
|
project(gnss-sdr CXX C)
|
||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||||
file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
file(RELATIVE_PATH RELATIVE_CMAKE_CALL ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
@ -324,7 +324,7 @@ endif()
|
|||||||
################################################################################
|
################################################################################
|
||||||
# Minimum required versions
|
# 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_GCC_MIN_VERSION "4.7.2")
|
||||||
set(GNSSSDR_CLANG_MIN_VERSION "3.4.0")
|
set(GNSSSDR_CLANG_MIN_VERSION "3.4.0")
|
||||||
set(GNSSSDR_APPLECLANG_MIN_VERSION "500")
|
set(GNSSSDR_APPLECLANG_MIN_VERSION "500")
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
########################################################################
|
########################################################################
|
||||||
# Project setup
|
# 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")
|
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose build type: None Debug Release RelWithDebInfo MinSizeRel")
|
||||||
project(volk_gnsssdr)
|
project(volk_gnsssdr)
|
||||||
enable_language(CXX)
|
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_MAJOR_VERSION 0)
|
||||||
set(VERSION_INFO_MINOR_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
|
include(VolkVersion) #setup version info
|
||||||
|
|
||||||
|
|
||||||
@ -369,6 +369,10 @@ install(
|
|||||||
COMPONENT "volk_gnsssdr_devel"
|
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
|
# Option to enable QA testing, on by default
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -15,33 +15,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
include(FindPkgConfig)
|
get_filename_component(VOLK_GNSSSDR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||||
pkg_check_modules(PC_VOLK_GNSSSDR volk_gnsssdr)
|
|
||||||
|
|
||||||
find_path(
|
if(NOT TARGET VolkGnsssdr::volkgnsssdr)
|
||||||
VOLK_GNSSSDR_INCLUDE_DIRS
|
include("${VOLK_GNSSSDR_CMAKE_DIR}/VolkGnsssdrTargets.cmake")
|
||||||
NAMES volk_gnsssdr/volk_gnsssdr.h
|
endif()
|
||||||
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)
|
|
||||||
|
@ -569,14 +569,28 @@ if(MSVC)
|
|||||||
set_source_files_properties(${volk_gnsssdr_sources} PROPERTIES LANGUAGE CXX)
|
set_source_files_properties(${volk_gnsssdr_sources} PROPERTIES LANGUAGE CXX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#Use object library for faster overall build in newer versions of cmake
|
#Create a volk_gnsssdr object library
|
||||||
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})
|
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 dynamic library
|
||||||
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||||
target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries} ${Boost_LIBRARIES})
|
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
|
#Configure target properties
|
||||||
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
|
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
|
||||||
@ -585,6 +599,7 @@ if(CMAKE_VERSION VERSION_GREATER "2.8.7")
|
|||||||
|
|
||||||
#Install locations
|
#Install locations
|
||||||
install(TARGETS volk_gnsssdr
|
install(TARGETS volk_gnsssdr
|
||||||
|
EXPORT VOLK_GNSSSDR-export
|
||||||
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file
|
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file
|
||||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
|
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
|
||||||
RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file
|
RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file
|
||||||
@ -593,47 +608,28 @@ if(CMAKE_VERSION VERSION_GREATER "2.8.7")
|
|||||||
#Configure static library
|
#Configure static library
|
||||||
if(ENABLE_STATIC_LIBS)
|
if(ENABLE_STATIC_LIBS)
|
||||||
add_library(volk_gnsssdr_static STATIC $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
add_library(volk_gnsssdr_static STATIC $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||||
|
target_link_libraries(volk_gnsssdr_static ${volk_gnsssdr_libraries} pthread m)
|
||||||
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
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}
|
||||||
|
)
|
||||||
|
|
||||||
install(TARGETS volk_gnsssdr_static
|
install(TARGETS volk_gnsssdr_static
|
||||||
|
EXPORT VOLK_GNSSSDR-export
|
||||||
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel"
|
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel"
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
#Older cmake versions (slower to build when building dynamic/static libs)
|
set_target_properties(volk_gnsssdr_static PROPERTIES OUTPUT_NAME volk_gnsssdr)
|
||||||
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
|
|
||||||
)
|
|
||||||
|
|
||||||
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()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Build the QA test application
|
# Build the QA test application
|
||||||
########################################################################
|
########################################################################
|
||||||
if(ENABLE_TESTING)
|
if(ENABLE_TESTING)
|
||||||
|
|
||||||
#include Boost headers
|
#include Boost headers
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.unittest)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.unittest)
|
||||||
@ -648,10 +644,10 @@ if(ENABLE_TESTING)
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc
|
${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc
|
||||||
TARGET_DEPS volk_gnsssdr
|
TARGET_DEPS volk_gnsssdr
|
||||||
)
|
)
|
||||||
|
|
||||||
foreach(kernel ${h_files})
|
foreach(kernel ${h_files})
|
||||||
get_filename_component(kernel ${kernel} NAME)
|
get_filename_component(kernel ${kernel} NAME)
|
||||||
string(REPLACE ".h" "" kernel ${kernel})
|
string(REPLACE ".h" "" kernel ${kernel})
|
||||||
volk_add_test(${kernel} "volk_gnsssdr_test_all")
|
volk_add_test(${kernel} "volk_gnsssdr_test_all")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user