Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion FindBoost-Math.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ endif()

add_library(boost-math INTERFACE)

target_include_directories(boost-math SYSTEM INTERFACE
if (DEFINED THIRD_PARTY_INCLUDES_AS_SYSTEM AND NOT THIRD_PARTY_INCLUDES_AS_SYSTEM)
target_include_directories(boost-math INTERFACE
${PROJECT_SOURCE_DIR}/third_party/boost-math/include/)
else()
target_include_directories(boost-math SYSTEM INTERFACE
${PROJECT_SOURCE_DIR}/third_party/boost-math/include/)
endif()
11 changes: 3 additions & 8 deletions FindEigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ endif()

add_library(eigen INTERFACE)

# Include Eigen library as system headers to suppress warnings when not
# cross-compiling. GNU ARM toolchain wraps system headers with `extern "C"`,
# causing errors, so in this case Eigen must be #included using
# `#pragma GCC system_header` in the source.
# See https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html
if (NOT CMAKE_CROSSCOMPILING OR THIRD_PARTY_INCLUDES_AS_SYSTEM)
target_include_directories(eigen SYSTEM INTERFACE
if (DEFINED THIRD_PARTY_INCLUDES_AS_SYSTEM AND NOT THIRD_PARTY_INCLUDES_AS_SYSTEM)
target_include_directories(eigen INTERFACE
${PROJECT_SOURCE_DIR}/third_party/eigen/)
else()
target_include_directories(eigen INTERFACE
target_include_directories(eigen SYSTEM INTERFACE
${PROJECT_SOURCE_DIR}/third_party/eigen/)
endif()

21 changes: 4 additions & 17 deletions FindGFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
include("GenericFindDependency")
GenericFindDependency(
TARGET gflags
SOURCE_DIR "googleflags"
)

if(NOT CMAKE_CROSSCOMPILING OR THIRD_PARTY_INCLUDES_AS_SYSTEM)
# Change all of GoogleFlags's include directories to be system includes, to avoid
# compiler errors. The generalised version of this in GenericFindDependency won't
# work here because we are dealing with an aliased target
get_target_property(_aliased gflags ALIASED_TARGET)
if(_aliased)
get_target_property(gflags_include_directories ${_aliased} INTERFACE_INCLUDE_DIRECTORIES)
if(gflags_include_directories)
set_target_properties(${_aliased} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
target_include_directories(${_aliased} SYSTEM INTERFACE ${gflags_include_directories})
endif()
endif()
endif()
TARGET gflags
SOURCE_DIR "googleflags"
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindGnss-converters.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ GenericFindDependency(
TARGET gnss_converters
SOURCE_DIR "gnss-converters/c"
SYSTEM_HEADER_FILE "gnss-converters/nmea.h"
SYSTEM_INCLUDES
)
4 changes: 2 additions & 2 deletions FindGoogletest.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include("GenericFindDependency")
GenericFindDependency(
TARGET gtest
ADDITIONAL_TARGETS gmock
SOURCE_DIR "googletest"
SYSTEM_INCLUDES
)
mark_target_as_system_includes(gmock)
)
1 change: 0 additions & 1 deletion FindIxcom.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ option(libixcom_ENABLE_TESTS "" OFF)
GenericFindDependency(
TARGET ixcom
SOURCE_DIR "c"
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindOrion-Proto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ include("GenericFindDependency")
GenericFindDependency(
TARGET orion-proto
SOURCE_DIR "orion_proto"
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindPal++.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ option(pal++_ENABLE_TESTS "" OFF)
GenericFindDependency(
TARGET pal++
SOURCE_DIR libpal_cpp
SYSTEM_INCLUDES
)
3 changes: 1 addition & 2 deletions FindPal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ option(pal_ENABLE_TESTS "" OFF)
option(pal_ENABLE_EXAMPLES "" OFF)
GenericFindDependency(
TARGET pal
SYSTEM_INCLUDES
)
)
28 changes: 5 additions & 23 deletions FindRapidCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,9 @@ include("GenericFindDependency")
set(RC_ENABLE_GTEST ON CACHE BOOL "" FORCE)

GenericFindDependency(
TARGET rapidcheck
)

# Change all of rapidcheck's include directories to be system includes, to avoid
# compiler errors. The generalised version in GenericFindDependency isn't suitable
# in this instance.
get_target_property(rapidcheck_interface_includes rapidcheck INTERFACE_INCLUDE_DIRECTORIES)
if(rapidcheck_interface_includes)
set_target_properties(rapidcheck PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
target_include_directories(rapidcheck SYSTEM INTERFACE ${rapidcheck_interface_includes})
else()
message(WARNING "No include directories in rapidcheck, this seems wrong")
endif()
unset(rapidcheck_interface_includes)

get_target_property(rapidcheck_gtest_interface_includes rapidcheck_gtest INTERFACE_INCLUDE_DIRECTORIES)
if(rapidcheck_gtest_interface_includes)
set_target_properties(rapidcheck_gtest PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "")
target_include_directories(rapidcheck_gtest SYSTEM INTERFACE ${rapidcheck_gtest_interface_includes})
else()
message(WARNING "No include directories in rapidcheck_gtest, this seems wrong")
endif()
unset(rapidcheck_gtest_interface_includes)
TARGET rapidcheck
ADDITIONAL_TARGETS
rapidcheck_gtest
SYSTEM_INCLUDES
)

1 change: 0 additions & 1 deletion FindRtcm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ GenericFindDependency(
TARGET rtcm
SOURCE_DIR "c"
SYSTEM_HEADER_FILE "rtcm3/bits.h"
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindSbp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ option(libsbp_ENABLE_DOCS "" OFF)
GenericFindDependency(
TARGET sbp
SOURCE_DIR "c"
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ include("GenericFindDependency")
option(libsettings_ENABLE_TESTS "" OFF)
GenericFindDependency(
TARGET settings
SYSTEM_INCLUDES
)
22 changes: 12 additions & 10 deletions FindStarling.cmake
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
include("GenericFindDependency")

option(starling_ENABLE_TESTS "" OFF)
option(starling_ENABLE_TEST_LIBS "" OFF)
option(starling_ENABLE_EXAMPLES "" OFF)

GenericFindDependency(
TARGET pvt-runner-lib
SOURCE_DIR starling
SYSTEM_HEADER_FILE "pvt_driver/runner/pvt_runner.h"
SYSTEM_INCLUDES
TARGET pvt-runner-lib
ADDITIONAL_TARGETS
sensorfusion
pvt_driver
pvt-engine
pvt-common
starling-util
SOURCE_DIR starling
SYSTEM_HEADER_FILE "pvt_driver/runner/pvt_runner.h"
)

mark_target_as_system_includes(sensorfusion)
mark_target_as_system_includes(pvt_driver)
mark_target_as_system_includes(pvt-engine)
mark_target_as_system_includes(pvt-common)
mark_target_as_system_includes(starling-util)
1 change: 0 additions & 1 deletion FindSwiftlets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ option(swiftlets_ENABLE_TESTS "" OFF)
GenericFindDependency(
TARGET swiftlets
SOURCE_DIR swiftlets
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindSwiftnav.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ option(libswiftnav_ENABLE_TESTS "" OFF)
GenericFindDependency(
TARGET swiftnav
SYSTEM_HEADER_FILE "swiftnav/bits.h"
SYSTEM_INCLUDES
)
1 change: 0 additions & 1 deletion FindUbx.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ option(libubx_ENABLE_TESTS "" OFF)
GenericFindDependency(
TARGET ubx
SOURCE_DIR "c"
SYSTEM_INCLUDES
)
3 changes: 2 additions & 1 deletion FindVariant.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include("GenericFindDependency")
GenericFindDependency(
TARGET variant
)
SYSTEM_INCLUDES
)
55 changes: 45 additions & 10 deletions GenericFindDependency.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# cmake -DSWIFT_PREFERRED_DEPENDENCY_SOURCE=system <path>
#
# will try to use depenedencies from the system libraries rather than bundled
# will try to use dependencies from the system libraries rather than bundled
# source code.
#
# If the dependency is picked up from the system libraries this function will
Expand All @@ -37,12 +37,14 @@
#
# The target name can be controlled by the option "TARGET". When using
# bundled source code this is used to verify the target was created properly
# after calling add_subdirectory
# after calling add_subdirectory. If the add_subdirectory exposes a number of
# other targets, you can use the "ADDITIONAL_TARGETS" option to list them, this
# function will apply the "SYSTEM_INCLUDES" option to each of the targets.
#
# Passing the option SYSTEM_INCLUDES will rewrite the target include directories
# so that they are marked as system headers. This will usually be passed to
# the compiler as an command line option as decided by cmake. Be careful with
# this option, it will supress warning which might otherwise be helpful.
# this option, it will suppress warning which might otherwise be helpful.
#
# The option REQUIRED can be passed which will cause this function to fail
# if the dependency was not found for any reason.
Expand Down Expand Up @@ -267,12 +269,43 @@ endmacro()

#
# Helper function to mark the specified target's include directories as system. This is
# then passed to the compiler which will surpress warnings generated from any header file
# then passed to the compiler which will suppress warnings generated from any header file
# included by this path. Use with care
#
# Should only be called from GenericFindDependency
#
function(mark_target_as_system_includes TGT)
#
# We will determine if a target is to be set as a system target based on if
# THIRD_PARTY_INCLUDES_AS_SYSTEM is explicitly set, otherwise the decision is
# delegated to whether or not the SYSTEM_INCLUDES option was specified via
# GenericFindDependency. The term "explicitly" is used since in cmake, an
# undefined variable is interpreted as false, which is undesirable effect in
# this case as we intend to use tri-state property of a variable (undefined/true/false).
#
if (DEFINED THIRD_PARTY_INCLUDES_AS_SYSTEM)
if (THIRD_PARTY_INCLUDES_AS_SYSTEM)
set (mark_as_system true)
else()
set (mark_as_system false)
endif()
else()
if (x_SYSTEM_INCLUDES)
set (mark_as_system true)
else()
set (mark_as_system false)
endif()
endif()

if (NOT mark_as_system)
return()
endif()

get_target_property(aliased_target ${TGT} ALIASED_TARGET)
if (aliased_target)
set (TGT ${aliased_target})
endif()

get_target_property(directories ${TGT} INTERFACE_INCLUDE_DIRECTORIES)
if(directories)
message(STATUS "Marking ${TGT} include directories as system")
Expand All @@ -284,7 +317,7 @@ endfunction()
function(GenericFindDependency)
set(argOptions "REQUIRED" "SYSTEM_INCLUDES")
set(argSingleArguments "TARGET" "PREFER" "SOURCE_DIR" "SYSTEM_HEADER_FILE" "SYSTEM_LIB_NAMES")
set(argMultiArguments "EXCLUDE")
set(argMultiArguments "ADDITIONAL_TARGETS" "EXCLUDE")

cmake_parse_arguments(x "${argOptions}" "${argSingleArguments}" "${argMultiArguments}" ${ARGN})

Expand Down Expand Up @@ -346,11 +379,7 @@ function(GenericFindDependency)

# Final validation that the target was properly created from some source
if(TARGET ${x_TARGET})
if(x_SYSTEM_INCLUDES)
if(NOT CMAKE_CROSSCOMPILING OR THIRD_PARTY_INCLUDES_AS_SYSTEM)
mark_target_as_system_includes(${x_TARGET})
endif()
endif()
mark_target_as_system_includes(${x_TARGET})
else()
# Target not found in any location
if(x_REQUIRED OR ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
Expand All @@ -359,5 +388,11 @@ function(GenericFindDependency)
message(WARNING "Could not find dependency ${x_TARGET} in any available location")
endif()
endif()

# If the primary target exposes additional targets, mark them as system
# targets in accordance to how the primary target was marked
foreach(additional_target IN LISTS x_ADDITIONAL_TARGETS)
mark_target_as_system_includes(${additional_target})
endforeach()
endfunction()