mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-26 08:56:58 +00:00
Fix building with Xcode
Now gnss-sdr can be built with Xcode (using the CMake flag -GXcode). Before this commit, this was only possible with volk_gnsssdr already installed. Reason of failing was that Xcode does not like targets that have only object files. See https://gitlab.kitware.com/cmake/cmake/issues/17457
This commit is contained in:
parent
862a7155ea
commit
c1a26e01ff
@ -282,7 +282,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
||||
if(${DARWIN_VERSION} MATCHES "19")
|
||||
set(MACOS_CATALINA TRUE)
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
|
||||
message(STATUS "Configuring GNSS-SDR v${VERSION} to be built on macOS Catalina 10.15")
|
||||
endif()
|
||||
@ -957,7 +957,7 @@ if(NOT VOLKGNSSSDR_FOUND)
|
||||
endif()
|
||||
if(OS_IS_MACOSX)
|
||||
if(CMAKE_GENERATOR STREQUAL Xcode)
|
||||
set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" "-configuration" "Debug" "-target")
|
||||
set(VOLK_GNSSSDR_BUILD_COMMAND "xcodebuild" "-configuration" "${CMAKE_BUILD_TYPE}" "-target")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -426,7 +426,9 @@ foreach(machine_name ${available_machines})
|
||||
--mode "machine_flags" --machine "${machine_name}" --compiler "${COMPILER_NAME}"
|
||||
OUTPUT_VARIABLE ${machine_name}_flags OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
message(STATUS "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}")
|
||||
if(NOT (CMAKE_GENERATOR STREQUAL Xcode))
|
||||
message(STATUS "BUILD INFO ::: ${machine_name} ::: ${COMPILER_NAME} ::: ${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}")
|
||||
endif()
|
||||
set(COMPILER_INFO "${COMPILER_INFO}${machine_name}:::${COMPILER_NAME}:::${CMAKE_C_FLAGS_${CBTU}} ${CMAKE_C_FLAGS} ${${machine_name}_flags}\n")
|
||||
if(${machine_name}_flags AND NOT MSVC)
|
||||
set_source_files_properties(${machine_source} PROPERTIES COMPILE_FLAGS "${${machine_name}_flags}")
|
||||
@ -573,18 +575,24 @@ if(MSVC)
|
||||
endif()
|
||||
|
||||
#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}
|
||||
)
|
||||
if(NOT (CMAKE_GENERATOR STREQUAL Xcode))
|
||||
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}
|
||||
)
|
||||
endif()
|
||||
|
||||
#Add dynamic library
|
||||
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
if(CMAKE_GENERATOR STREQUAL Xcode)
|
||||
add_library(volk_gnsssdr SHARED ${volk_gnsssdr_sources})
|
||||
else()
|
||||
add_library(volk_gnsssdr SHARED $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
endif()
|
||||
target_link_libraries(volk_gnsssdr ${volk_gnsssdr_libraries})
|
||||
target_include_directories(volk_gnsssdr
|
||||
PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
|
||||
@ -597,7 +605,9 @@ target_include_directories(volk_gnsssdr
|
||||
|
||||
#Configure target properties
|
||||
if(NOT MSVC)
|
||||
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
|
||||
if(NOT (CMAKE_GENERATOR STREQUAL Xcode))
|
||||
set_target_properties(volk_gnsssdr_obj PROPERTIES COMPILE_FLAGS "-fPIC")
|
||||
endif()
|
||||
target_link_libraries(volk_gnsssdr m)
|
||||
endif()
|
||||
set_target_properties(volk_gnsssdr PROPERTIES SOVERSION ${LIBVER})
|
||||
@ -613,7 +623,11 @@ install(TARGETS volk_gnsssdr
|
||||
|
||||
#Configure static library
|
||||
if(ENABLE_STATIC_LIBS)
|
||||
add_library(volk_gnsssdr_static STATIC $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
if(CMAKE_GENERATOR STREQUAL Xcode)
|
||||
add_library(volk_gnsssdr_static STATIC ${volk_gnsssdr_sources})
|
||||
else()
|
||||
add_library(volk_gnsssdr_static STATIC $<TARGET_OBJECTS:volk_gnsssdr_obj>)
|
||||
endif()
|
||||
target_link_libraries(volk_gnsssdr_static ${volk_gnsssdr_libraries} pthread)
|
||||
if(NOT MSVC)
|
||||
target_link_libraries(volk_gnsssdr_static m)
|
||||
|
Loading…
Reference in New Issue
Block a user