mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Merge branch 'volk-noboost' into next
This commit is contained in:
		| @@ -27,6 +27,20 @@ enable_language(CXX) | ||||
| enable_language(C) | ||||
| enable_testing() | ||||
|  | ||||
| set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # allows this to be a sub-project | ||||
| set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) # allows this to be a sub-project | ||||
| list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) # location for custom "Modules" | ||||
|  | ||||
| if(POLICY CMP0042) | ||||
|     cmake_policy(SET CMP0042 NEW) | ||||
| endif() | ||||
| if(POLICY CMP0068) | ||||
|     cmake_policy(SET CMP0068 NEW) | ||||
| endif() | ||||
| if(POLICY CMP0057) | ||||
|     cmake_policy(SET CMP0057 NEW) | ||||
| endif() | ||||
|  | ||||
| # Set compiler flags | ||||
| set(GNSSSDR_CLANG_MIN_VERSION "3.4.0") | ||||
| set(GNSSSDR_APPLECLANG_MIN_VERSION "500") | ||||
| @@ -63,26 +77,12 @@ endif() | ||||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||||
|  | ||||
| # Check if we have std::filesystem | ||||
| if(POLICY CMP0075) | ||||
|     cmake_policy(SET CMP0075 NEW) | ||||
| endif() | ||||
| if(CMAKE_VERSION VERSION_LESS 3.8) | ||||
|     set(has_std_filesystem FALSE) | ||||
|     set(FILESYSTEM_FOUND FALSE) | ||||
| else() | ||||
|     set(CMAKE_REQUIRED_FLAGS "-std=c++17") | ||||
|     if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")) | ||||
|         set(CMAKE_REQUIRED_LIBRARIES -lstdc++fs) | ||||
|     endif() | ||||
|     if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
|         if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||||
|             set(CMAKE_REQUIRED_LIBRARIES -lc++) | ||||
|         endif() | ||||
|     endif() | ||||
|     include(CheckCXXSymbolExists) | ||||
|     check_cxx_symbol_exists(std::filesystem::path::preferred_separator filesystem has_std_filesystem) | ||||
|     find_package(FILESYSTEM) | ||||
| endif() | ||||
|  | ||||
| set(USE_CXX17 FALSE) | ||||
| if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) | ||||
|     if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") | ||||
|         if(CMAKE_VERSION VERSION_LESS "3.1") | ||||
| @@ -94,10 +94,9 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) | ||||
|         if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") | ||||
|             set(CMAKE_CXX_STANDARD 14) | ||||
|         else() | ||||
|             if(${has_std_filesystem}) | ||||
|             if(${FILESYSTEM_FOUND}) | ||||
|                 set(CMAKE_CXX_STANDARD 17) | ||||
|                 set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||
|                 set(USE_CXX17 TRUE) | ||||
|             else() | ||||
|                 set(CMAKE_CXX_STANDARD 14) | ||||
|             endif() | ||||
| @@ -115,10 +114,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||||
|             if(CLANG_VERSION VERSION_LESS "1000") | ||||
|                 set(CMAKE_CXX_STANDARD 14) | ||||
|             else() | ||||
|                 if(${has_std_filesystem}) | ||||
|                 if(${FILESYSTEM_FOUND}) | ||||
|                     set(CMAKE_CXX_STANDARD 17) | ||||
|                     set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||
|                     set(USE_CXX17 TRUE) | ||||
|                 else() | ||||
|                     set(CMAKE_CXX_STANDARD 14) | ||||
|                 endif() | ||||
| @@ -126,17 +124,18 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||||
|         endif() | ||||
|     else() | ||||
|         if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") | ||||
|             set(CMAKE_CXX_STANDARD 11) | ||||
|             if(CMAKE_VERSION VERSION_LESS "3.1") | ||||
|                 set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") | ||||
|             else() | ||||
|                 set(CMAKE_CXX_STANDARD 11) | ||||
|             endif() | ||||
|         else() | ||||
|             if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") | ||||
|                 set(CMAKE_CXX_STANDARD 14) | ||||
|             else() | ||||
|                 if(${has_std_filesystem}) | ||||
|                 if(${FILESYSTEM_FOUND}) | ||||
|                     set(CMAKE_CXX_STANDARD 17) | ||||
|                     set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||
|                     if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT WIN32) | ||||
|                         set(USE_CXX17 TRUE) | ||||
|                     endif() | ||||
|                 else() | ||||
|                     set(CMAKE_CXX_STANDARD 14) | ||||
|                 endif() | ||||
| @@ -155,19 +154,8 @@ endif() | ||||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS} -Wall") | ||||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") | ||||
|  | ||||
| if(POLICY CMP0042) | ||||
|     cmake_policy(SET CMP0042 NEW) | ||||
| endif() | ||||
| if(POLICY CMP0068) | ||||
|     cmake_policy(SET CMP0068 NEW) | ||||
| endif() | ||||
|  | ||||
| option(ENABLE_STRIP "Create a stripped volk_gnsssdr_profile binary (without shared libraries)" OFF) | ||||
|  | ||||
| set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # allows this to be a sub-project | ||||
| set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) # allows this to be a sub-project | ||||
| list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) # location for custom "Modules" | ||||
|  | ||||
| include(VolkBuildTypes) | ||||
| # select the release build type by default to get optimization flags | ||||
| if(NOT CMAKE_BUILD_TYPE) | ||||
| @@ -254,7 +242,7 @@ if(MSVC) | ||||
|         unset(BOOST_REQUIRED_COMPONENTS) # empty components list for static link | ||||
|     endif() | ||||
| endif() | ||||
| if(${USE_CXX17}) | ||||
| if(${FILESYSTEM_FOUND}) | ||||
|     set(Boost_LIBRARIES "") | ||||
|     set(Boost_INCLUDE_DIRS "") | ||||
|     set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}) | ||||
|   | ||||
| @@ -35,22 +35,6 @@ include_directories( | ||||
| ) | ||||
|  | ||||
|  | ||||
| set(CXX_REQUIRED_LINK "") | ||||
| if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||||
|     if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||||
|         set(CXX_REQUIRED_LINK "c++") | ||||
|     else() | ||||
|         if(${USE_CXX17} AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")) | ||||
|             set(CXX_REQUIRED_LINK "stdc++fs") | ||||
|         endif() | ||||
|     endif() | ||||
| endif() | ||||
| if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")) | ||||
|     if(${USE_CXX17}) | ||||
|         set(CXX_REQUIRED_LINK "stdc++fs") | ||||
|     endif() | ||||
| endif() | ||||
|  | ||||
| if(ORC_FOUND) | ||||
|     set(orc_lib ${ORC_LIBRARIES}) | ||||
| else() | ||||
| @@ -74,14 +58,15 @@ add_executable(volk_gnsssdr_profile | ||||
|     ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc | ||||
| ) | ||||
|  | ||||
| if(${USE_CXX17}) | ||||
| if(${FILESYSTEM_FOUND}) | ||||
|     add_definitions(-DHAS_STD_FILESYSTEM=1) | ||||
|     target_link_libraries(volk_gnsssdr_profile PRIVATE std::filesystem) | ||||
| endif() | ||||
|  | ||||
| if(ENABLE_STATIC_LIBS) | ||||
|     target_link_libraries(volk_gnsssdr_profile ${CXX_REQUIRED_LINK} volk_gnsssdr_static ${Boost_LIBRARIES} ${orc_lib}) | ||||
|     target_link_libraries(volk_gnsssdr_profile PUBLIC volk_gnsssdr_static ${Boost_LIBRARIES} ${orc_lib}) | ||||
| else() | ||||
|     target_link_libraries(volk_gnsssdr_profile ${CXX_REQUIRED_LINK} volk_gnsssdr ${Boost_LIBRARIES} ${orc_lib}) | ||||
|     target_link_libraries(volk_gnsssdr_profile PUBLIC volk_gnsssdr ${Boost_LIBRARIES} ${orc_lib}) | ||||
|     add_dependencies(volk_gnsssdr_profile volk_gnsssdr) | ||||
| endif() | ||||
|  | ||||
| @@ -103,10 +88,12 @@ install( | ||||
|  | ||||
| # MAKE volk_gnsssdr-config-info | ||||
| add_executable(volk_gnsssdr-config-info volk_gnsssdr-config-info.cc ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc) | ||||
|  | ||||
|  | ||||
| if(ENABLE_STATIC_LIBS) | ||||
|     target_link_libraries(volk_gnsssdr-config-info ${CXX_REQUIRED_LINK} volk_gnsssdr_static ${orc_lib}) | ||||
|     target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr_static ${orc_lib}) | ||||
| else() | ||||
|     target_link_libraries(volk_gnsssdr-config-info ${CXX_REQUIRED_LINK} volk_gnsssdr ${orc_lib}) | ||||
|     target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${orc_lib}) | ||||
|     add_dependencies(volk_gnsssdr-config-info volk_gnsssdr) | ||||
| endif() | ||||
|  | ||||
|   | ||||
| @@ -0,0 +1,245 @@ | ||||
| # Copyright (C) 2019 (see AUTHORS file for a list of contributors) | ||||
| # | ||||
| # This file is part of GNSS-SDR. | ||||
| # | ||||
| # GNSS-SDR is free software: you can redistribute it and/or modify | ||||
| # it under the terms of the GNU General Public License as published by | ||||
| # the Free Software Foundation, either version 3 of the License, or | ||||
| # (at your option) any later version. | ||||
| # | ||||
| # GNSS-SDR is distributed in the hope that it will be useful, | ||||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
| # GNU General Public License for more details. | ||||
| # | ||||
| # You should have received a copy of the GNU General Public License | ||||
| # along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>. | ||||
|  | ||||
| # Original Source: https://github.com/vector-of-bool/CMakeCM | ||||
| # Modified by C. Fernandez-Prades. | ||||
|  | ||||
| #[=======================================================================[.rst: | ||||
|  | ||||
| FindFILESYSTEM | ||||
| ############## | ||||
|  | ||||
| This module supports the C++17 standard library's filesystem utilities. Use the | ||||
| :imp-target:`std::filesystem` imported target to | ||||
|  | ||||
| Options | ||||
| ******* | ||||
|  | ||||
| The ``COMPONENTS`` argument to this module supports the following values: | ||||
|  | ||||
| .. find-component:: Experimental | ||||
|     :name: fs.Experimental | ||||
|  | ||||
|     Allows the module to find the "experimental" Filesystem TS version of the | ||||
|     Filesystem library. This is the library that should be used with the | ||||
|     ``std::experimental::filesystem`` namespace. | ||||
|  | ||||
| .. find-component:: Final | ||||
|     :name: fs.Final | ||||
|  | ||||
|     Finds the final C++17 standard version of the filesystem library. | ||||
|  | ||||
| If no components are provided, behaves as if the | ||||
| :find-component:`fs.Final` component was specified. | ||||
|  | ||||
| If both :find-component:`fs.Experimental` and :find-component:`fs.Final` are | ||||
| provided, first looks for ``Final``, and falls back to ``Experimental`` in case | ||||
| of failure. If ``Final`` is found, :imp-target:`std::filesystem` and all | ||||
| :ref:`variables <fs.variables>` will refer to the ``Final`` version. | ||||
|  | ||||
|  | ||||
| Imported Targets | ||||
| **************** | ||||
|  | ||||
| .. imp-target:: std::filesystem | ||||
|  | ||||
|     The ``std::filesystem`` imported target is defined when any requested | ||||
|     version of the C++ filesystem library has been found, whether it is | ||||
|     *Experimental* or *Final*. | ||||
|  | ||||
|     If no version of the filesystem library is available, this target will not | ||||
|     be defined. | ||||
|  | ||||
|     .. note:: | ||||
|         This target has ``cxx_std_17`` as an ``INTERFACE`` | ||||
|         :ref:`compile language standard feature <req-lang-standards>`. Linking | ||||
|         to this target will automatically enable C++17 if no later standard | ||||
|         version is already required on the linking target. | ||||
|  | ||||
|  | ||||
| .. _fs.variables: | ||||
|  | ||||
| Variables | ||||
| ********* | ||||
|  | ||||
| .. variable:: CXX_FILESYSTEM_IS_EXPERIMENTAL | ||||
|  | ||||
|     Set to ``TRUE`` when the :find-component:`fs.Experimental` version of C++ | ||||
|     filesystem library was found, otherwise ``FALSE``. | ||||
|  | ||||
| .. variable:: CXX_FILESYSTEM_HAVE_FS | ||||
|  | ||||
|     Set to ``TRUE`` when a filesystem header was found. | ||||
|  | ||||
| .. variable:: CXX_FILESYSTEM_HEADER | ||||
|  | ||||
|     Set to either ``filesystem`` or ``experimental/filesystem`` depending on | ||||
|     whether :find-component:`fs.Final` or :find-component:`fs.Experimental` was | ||||
|     found. | ||||
|  | ||||
| .. variable:: CXX_FILESYSTEM_NAMESPACE | ||||
|  | ||||
|     Set to either ``std::filesystem`` or ``std::experimental::filesystem`` | ||||
|     depending on whether :find-component:`fs.Final` or | ||||
|     :find-component:`fs.Experimental` was found. | ||||
|  | ||||
|  | ||||
| Examples | ||||
| ******** | ||||
|  | ||||
| Using `find_package(FILESYSTEM)` with no component arguments: | ||||
|  | ||||
| .. code-block:: cmake | ||||
|  | ||||
|     find_package(FILESYSTEM REQUIRED) | ||||
|  | ||||
|     add_executable(my-program main.cpp) | ||||
|     target_link_libraries(my-program PRIVATE std::filesystem) | ||||
|  | ||||
|  | ||||
| #]=======================================================================] | ||||
|  | ||||
|  | ||||
| if(TARGET std::filesystem) | ||||
|     # This module has already been processed. Don't do it again. | ||||
|     return() | ||||
| endif() | ||||
|  | ||||
| include(CMakePushCheckState) | ||||
| include(CheckIncludeFileCXX) | ||||
| include(CheckCXXSourceCompiles) | ||||
|  | ||||
| cmake_push_check_state() | ||||
|  | ||||
| set(CMAKE_REQUIRED_QUIET ${FILESYSTEM_FIND_QUIETLY}) | ||||
|  | ||||
| # All of our tests require C++17 or later | ||||
| set(CMAKE_CXX_STANDARD 17) | ||||
|  | ||||
| # Normalize and check the component list we were given | ||||
| set(want_components ${FILESYSTEM_FIND_COMPONENTS}) | ||||
| if(FILESYSTEM_FIND_COMPONENTS STREQUAL "") | ||||
|     set(want_components Final) | ||||
| endif() | ||||
|  | ||||
| # Warn on any unrecognized components | ||||
| set(extra_components ${want_components}) | ||||
| list(REMOVE_ITEM extra_components Final Experimental) | ||||
| foreach(component IN LISTS extra_components) | ||||
|     message(WARNING "Extraneous find_package component for FILESYSTEM: ${component}") | ||||
| endforeach() | ||||
|  | ||||
| # Detect which of Experimental and Final we should look for | ||||
| set(find_experimental TRUE) | ||||
| set(find_final TRUE) | ||||
| if(NOT "Final" IN_LIST want_components) | ||||
|     set(find_final FALSE) | ||||
| endif() | ||||
| if(NOT "Experimental" IN_LIST want_components) | ||||
|     set(find_experimental FALSE) | ||||
| endif() | ||||
|  | ||||
| if(find_final) | ||||
|     check_include_file_cxx("filesystem" _CXX_FILESYSTEM_HAVE_HEADER) | ||||
|     mark_as_advanced(_CXX_FILESYSTEM_HAVE_HEADER) | ||||
|     if(_CXX_FILESYSTEM_HAVE_HEADER) | ||||
|         # We found the non-experimental header. Don't bother looking for the | ||||
|         # experimental one. | ||||
|         set(find_experimental FALSE) | ||||
|     endif() | ||||
| else() | ||||
|     set(_CXX_FILESYSTEM_HAVE_HEADER FALSE) | ||||
| endif() | ||||
|  | ||||
| if(find_experimental) | ||||
|     check_include_file_cxx("experimental/filesystem" _CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) | ||||
|     mark_as_advanced(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) | ||||
| else() | ||||
|     set(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER FALSE) | ||||
| endif() | ||||
|  | ||||
| if(_CXX_FILESYSTEM_HAVE_HEADER) | ||||
|     set(_have_fs TRUE) | ||||
|     set(_fs_header filesystem) | ||||
|     set(_fs_namespace std::filesystem) | ||||
| elseif(_CXX_FILESYSTEM_HAVE_EXPERIMENTAL_HEADER) | ||||
|     set(_have_fs TRUE) | ||||
|     set(_fs_header experimental/filesystem) | ||||
|     set(_fs_namespace std::experimental::filesystem) | ||||
| else() | ||||
|     set(_have_fs FALSE) | ||||
| endif() | ||||
|  | ||||
| set(CXX_FILESYSTEM_HAVE_FS ${_have_fs} CACHE BOOL "TRUE if we have the C++ filesystem headers") | ||||
| set(CXX_FILESYSTEM_HEADER ${_fs_header} CACHE STRING "The header that should be included to obtain the filesystem APIs") | ||||
| set(CXX_FILESYSTEM_NAMESPACE ${_fs_namespace} CACHE STRING "The C++ namespace that contains the filesystem APIs") | ||||
|  | ||||
| set(_found FALSE) | ||||
|  | ||||
| if(CXX_FILESYSTEM_HAVE_FS) | ||||
|     # We have some filesystem library available. Do link checks | ||||
|     string(CONFIGURE [[ | ||||
|         #include <@CXX_FILESYSTEM_HEADER@> | ||||
|  | ||||
|         int main() { | ||||
|             auto cwd = @CXX_FILESYSTEM_NAMESPACE@::current_path(); | ||||
|             return static_cast<int>(cwd.string().size()); | ||||
|         } | ||||
|     ]] code @ONLY) | ||||
|  | ||||
|     # Try to compile a simple filesystem program without any linker flags | ||||
|     check_cxx_source_compiles("${code}" CXX_FILESYSTEM_NO_LINK_NEEDED) | ||||
|  | ||||
|     set(can_link ${CXX_FILESYSTEM_NO_LINK_NEEDED}) | ||||
|  | ||||
|     if(NOT CXX_FILESYSTEM_NO_LINK_NEEDED) | ||||
|         set(prev_libraries ${CMAKE_REQUIRED_LIBRARIES}) | ||||
|         set(CMAKE_REQUIRED_FLAGS "-std=c++17") | ||||
|         # Add the libstdc++ flag | ||||
|         set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lstdc++fs) | ||||
|         check_cxx_source_compiles("${code}" CXX_FILESYSTEM_STDCPPFS_NEEDED) | ||||
|         set(can_link ${CXX_FILESYSTEM_STDCPPFS_NEEDED}) | ||||
|         if(NOT CXX_FILESYSTEM_STDCPPFS_NEEDED) | ||||
|             # Try the libc++ flag | ||||
|             set(CMAKE_REQUIRED_LIBRARIES ${prev_libraries} -lc++fs) | ||||
|             check_cxx_source_compiles("${code}" CXX_FILESYSTEM_CPPFS_NEEDED) | ||||
|             set(can_link ${CXX_FILESYSTEM_CPPFS_NEEDED}) | ||||
|         endif() | ||||
|     endif() | ||||
|  | ||||
|     if(can_link) | ||||
|         add_library(std::filesystem INTERFACE IMPORTED) | ||||
|         target_compile_features(std::filesystem INTERFACE cxx_std_17) | ||||
|         set(_found TRUE) | ||||
|  | ||||
|         if(CXX_FILESYSTEM_NO_LINK_NEEDED) | ||||
|             # Nothing to add... | ||||
|         elseif(CXX_FILESYSTEM_STDCPPFS_NEEDED) | ||||
|             target_link_libraries(std::filesystem INTERFACE -lstdc++fs) | ||||
|         elseif(CXX_FILESYSTEM_CPPFS_NEEDED) | ||||
|             target_link_libraries(std::filesystem INTERFACE -lc++fs) | ||||
|         endif() | ||||
|     endif() | ||||
| endif() | ||||
|  | ||||
| cmake_pop_check_state() | ||||
|  | ||||
| set(FILESYSTEM_FOUND ${_found} CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE) | ||||
|  | ||||
| if(FILESYSTEM_FIND_REQUIRED AND NOT FILESYSTEM_FOUND) | ||||
|     message(FATAL_ERROR "Cannot compile a simple program using std::filesystem") | ||||
| endif() | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez