From a975e33dabf5bc8bb20cd940d8365b9a76e571ab Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 29 Nov 2022 23:38:27 +0100 Subject: [PATCH] Fix for Xcode new build system CI: add new build-macos-xcode job --- .github/workflows/main.yml | 15 +++ CMakeLists.txt | 18 +-- .../volk_gnsssdr/apps/CMakeLists.txt | 10 -- .../volk_gnsssdr/lib/CMakeLists.txt | 113 +++++++++--------- 4 files changed, 80 insertions(+), 76 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f86d3192..b8dff7302 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,21 @@ jobs: - name: default position_test run: cd build && cmake -DENABLE_SYSTEM_TESTING_EXTRA=ON .. && ninja && ../install/position_test + build-macos-xcode: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: install dependencies + run: brew update && brew install ninja pkg-config hdf5 automake armadillo lapack gflags glog gnuradio log4cpp openssl pugixml protobuf && pip3 install mako + - name: configure + run: cd build && cmake -GXcode .. + - name: build + run: cd build && xcodebuild -configuration Release + - name: check + run: cd build && xcodebuild -configuration Release -target check && ../install/volk_gnsssdr_profile && ../install/run_tests + - name: default position_test + run: cd build && cmake -DENABLE_SYSTEM_TESTING_EXTRA=ON .. && xcodebuild -configuration Release -target position_test && ../install/position_test + clang-format: runs-on: macos-latest steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b3aeb7e8..8662fe08f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1115,13 +1115,11 @@ if(NOT VOLKGNSSSDR_FOUND) if(PYTHON_EXECUTABLE) set(USE_THIS_PYTHON "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") endif() - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(CMAKE_GENERATOR STREQUAL Xcode) - set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" - "-configuration" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel> - "-alltargets" - ) - endif() + + if(CMAKE_GENERATOR STREQUAL Xcode) + set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" + "-configuration" $<$:Debug>$<$:Release>$<$:RelWithDebInfo>$<$:MinSizeRel> + ) endif() if(CMAKE_TOOLCHAIN_FILE) @@ -1155,11 +1153,7 @@ if(NOT VOLKGNSSSDR_FOUND) ${STRIP_VOLK_GNSSSDR_PROFILE} ${USE_THIS_PYTHON} ) - if(CMAKE_VERSION VERSION_GREATER 3.18.99 AND CMAKE_GENERATOR STREQUAL Xcode) - if(XCODE_VERSION VERSION_GREATER 11) - set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} -T buildsystem=1) - endif() - endif() + if(DEFINED ENV{OECORE_TARGET_SYSROOT}) set(VOLK_GNSSSDR_CMAKE_ARGS ${VOLK_GNSSSDR_CMAKE_ARGS} -DCROSSCOMPILE_MULTILIB=TRUE diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt index 56f672e80..3ed4dafd6 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt @@ -35,8 +35,6 @@ add_executable(volk_gnsssdr_profile ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc ) -add_dependencies(volk_gnsssdr_profile volk_gnsssdr) - if(MSVC) target_include_directories(volk_gnsssdr_profile PRIVATE $ @@ -59,7 +57,6 @@ if(NOT FILESYSTEM_FOUND) target_link_libraries(volk_gnsssdr_profile PRIVATE ${Boost_LIBRARIES}) endif() - if(FILESYSTEM_FOUND) add_definitions(-DHAS_STD_FILESYSTEM=1) if(${find_experimental}) @@ -72,10 +69,8 @@ if(ENABLE_STATIC_LIBS) target_link_libraries(volk_gnsssdr_profile PRIVATE volk_gnsssdr_static ${orc_lib}) else() target_link_libraries(volk_gnsssdr_profile PRIVATE volk_gnsssdr ${orc_lib}) - add_dependencies(volk_gnsssdr_profile volk_gnsssdr) endif() - if(ENABLE_STRIP) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) set_target_properties(volk_gnsssdr_profile @@ -84,23 +79,19 @@ if(ENABLE_STRIP) endif() endif() - install( TARGETS volk_gnsssdr_profile DESTINATION bin COMPONENT "volk_gnsssdr" ) - # 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 volk_gnsssdr_static ${orc_lib}) else() target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${orc_lib}) - add_dependencies(volk_gnsssdr-config-info volk_gnsssdr) endif() if(ENABLE_STRIP) @@ -117,7 +108,6 @@ install( COMPONENT "volk_gnsssdr" ) - # Launch volk_gnsssdr_profile if requested to do so if(ENABLE_PROFILING) if(DEFINED VOLK_CONFIGPATH) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index b9da1426d..ae570c455 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -558,65 +558,70 @@ else() endif() # Add dynamic library -if(CMAKE_GENERATOR STREQUAL Xcode) - add_library(volk_gnsssdr SHARED ${volk_gnsssdr_sources}) -else() - add_library(volk_gnsssdr SHARED $) -endif() -if(USE_CPU_FEATURES) - if(CPUFEATURES_FOUND) - target_link_libraries(volk_gnsssdr - PUBLIC ${volk_gnsssdr_libraries} - PRIVATE CpuFeature::cpu_features - ) +# Note: new Xcode buildsystem does not allow building both static and dynamic libraries +# so we only build dynamic if ENABLE_STATIC_LIBS is not enabled in that generator. +# For other generators than XCode, the dynamic library is always built. +if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode))) + if(CMAKE_GENERATOR STREQUAL Xcode) + add_library(volk_gnsssdr SHARED ${volk_gnsssdr_sources}) else() - target_link_libraries(volk_gnsssdr - PUBLIC ${volk_gnsssdr_libraries} - PRIVATE cpu_features - ) + add_library(volk_gnsssdr SHARED $) endif() -else() - target_link_libraries(volk_gnsssdr PUBLIC ${volk_gnsssdr_libraries}) -endif() -target_include_directories(volk_gnsssdr - PUBLIC $ - PUBLIC $ - PUBLIC $ - PRIVATE ${CMAKE_CURRENT_BINARY_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PUBLIC $ -) -if(USE_CPU_FEATURES) - if(CPUFEATURES_FOUND) - target_include_directories(volk_gnsssdr - PRIVATE - $ - ) + if(USE_CPU_FEATURES) + if(CPUFEATURES_FOUND) + target_link_libraries(volk_gnsssdr + PUBLIC ${volk_gnsssdr_libraries} + PRIVATE CpuFeature::cpu_features + ) + else() + target_link_libraries(volk_gnsssdr + PUBLIC ${volk_gnsssdr_libraries} + PRIVATE cpu_features + ) + endif() else() - target_include_directories(volk_gnsssdr - PRIVATE - $ - ) + target_link_libraries(volk_gnsssdr PUBLIC ${volk_gnsssdr_libraries}) endif() -endif() -# Configure target properties -if(ORC_FOUND) - target_link_libraries(volk_gnsssdr PRIVATE ${ORC_LIBRARIES}) -endif() -if(NOT MSVC) - target_link_libraries(volk_gnsssdr PUBLIC m) -endif() -set_target_properties(volk_gnsssdr PROPERTIES VERSION ${VERSION}) -set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${SOVERSION}) -set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS") + target_include_directories(volk_gnsssdr + PUBLIC $ + PUBLIC $ + PUBLIC $ + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PUBLIC $ + ) + if(USE_CPU_FEATURES) + if(CPUFEATURES_FOUND) + target_include_directories(volk_gnsssdr + PRIVATE + $ + ) + else() + target_include_directories(volk_gnsssdr + PRIVATE + $ + ) + endif() + endif() + # Configure target properties + if(ORC_FOUND) + target_link_libraries(volk_gnsssdr PRIVATE ${ORC_LIBRARIES}) + endif() + if(NOT MSVC) + target_link_libraries(volk_gnsssdr PUBLIC m) + endif() + set_target_properties(volk_gnsssdr PROPERTIES VERSION ${VERSION}) + set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${SOVERSION}) + set_target_properties(volk_gnsssdr PROPERTIES DEFINE_SYMBOL "volk_gnsssdr_EXPORTS") -# 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 -) + # 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 + ) +endif() # Configure static library if(ENABLE_STATIC_LIBS)