Skip to content

Commit

Permalink
Merge pull request #1968 from qnx-ports/develop
Browse files Browse the repository at this point in the history
QNX Compatibility
  • Loading branch information
dellaert authored Jan 24, 2025
2 parents 99c4f7f + 4367d94 commit b762707
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 36 deletions.
3 changes: 2 additions & 1 deletion cmake/GtsamBuildTypes.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
endif()
endif()

if (NOT MSVC)
if ((NOT MSVC) AND (NOT QNX))
option(GTSAM_BUILD_WITH_MARCH_NATIVE "Enable/Disable building with all instructions supported by native architecture (binary may not be portable!)" ON)
if(GTSAM_BUILD_WITH_MARCH_NATIVE)
# Check if Apple OS and compiler is [Apple]Clang
if(APPLE AND (${CMAKE_CXX_COMPILER_ID} MATCHES "^(Apple)?Clang$"))
Expand Down
13 changes: 10 additions & 3 deletions cmake/GtsamTesting.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ macro(gtsamAddTestsGlob_impl groupName globPatterns excludedFiles linkLibraries)
set_property(SOURCE ${script_src} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${GTSAM_SOURCE_DIR}\"")

# Exclude from 'make all' and 'make install'
set_target_properties(${script_name} PROPERTIES EXCLUDE_FROM_ALL ON)
if(NOT QNX)
set_target_properties(${script_name} PROPERTIES EXCLUDE_FROM_ALL ON)
endif()

# Configure target folder (for MSVC and Xcode)
set_property(TARGET ${script_name} PROPERTY FOLDER "Unit tests/${groupName}")
Expand Down Expand Up @@ -240,8 +242,13 @@ macro(gtsamAddTestsGlob_impl groupName globPatterns excludedFiles linkLibraries)
set_property(SOURCE ${script_srcs} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${GTSAM_SOURCE_DIR}\"")

# Exclude from 'make all' and 'make install'
set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL ON)

# QNX is cross-compiled for, and does not support make, cmake, or ctest natively.
# Therefore, running tests must be done by manually copying test executables and required data files over.
# for more info, check PR#1968 https://github.com/borglab/gtsam/pull/1968
if(NOT QNX)
set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL ON)
endif()

# Configure target folder (for MSVC and Xcode)
set_property(TARGET ${script_name} PROPERTY FOLDER "Unit tests")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/HandlePrintConfiguration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(GTSAM_UNSTABLE_AVAILABLE)
print_enabled_config(${GTSAM_UNSTABLE_INSTALL_MATLAB_TOOLBOX} "Build MATLAB Toolbox for unstable")
endif()

if(NOT MSVC AND NOT XCODE_VERSION)
if(NOT MSVC AND NOT XCODE_VERSION AND NOT QNX)
print_enabled_config(${GTSAM_BUILD_WITH_MARCH_NATIVE} "Build for native architecture ")
print_config("Build type" "${CMAKE_BUILD_TYPE}")
print_config("C compilation flags" "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install the header files including the generated Config.h (which is in
# the build tree).
file (GLOB HEADERS [A-Za-z]*.hpp)
install (FILES ${HEADERS} DESTINATION include/GeographicLib)
install (FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GeographicLib)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/Config.h
DESTINATION include/GeographicLib)
2 changes: 1 addition & 1 deletion gtsam/3rdparty/cephes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(CEPHES_HEADER_FILES
dllexport.h)

# Add header files
install(FILES ${CEPHES_HEADER_FILES} DESTINATION include/gtsam/3rdparty/cephes)
install(FILES ${CEPHES_HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/3rdparty/cephes)

set(CEPHES_SOURCES
cephes/airy.c
Expand Down
2 changes: 1 addition & 1 deletion gtsam/3rdparty/ceres/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
file(GLOB ceres_headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
install(FILES ${ceres_headers} DESTINATION include/gtsam/3rdparty/ceres)
install(FILES ${ceres_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/3rdparty/ceres)
2 changes: 1 addition & 1 deletion gtsam/3rdparty/metis/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
install(FILES metis.h DESTINATION include/gtsam/3rdparty/metis)
install(FILES metis.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/3rdparty/metis)
9 changes: 9 additions & 0 deletions gtsam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ IF(MSVC)
ENDIF(MSVC)

# Generate and install config and dllexport files
#For config.in searches
if(QNX)
# QNX is cross-compiled for, and does not support make, cmake, or ctest natively. Additionally, space is limited in our embedded usecase.
# Therefore, running tests must be done by manually copying test executables and required data files over, preferably avoiding
# copying the whole source tree. Thus, we set the default file lookup to the recommended test folder, with the option
# to manually change it.
# for more info, check PR#1968 https://github.com/borglab/gtsam/pull/1968
set(QNX_TARGET_DATASET_DIR "/data/home/root/qnxuser/test" CACHE STRING "Path to your on-target testing folder.")
endif()
configure_file(config.h.in config.h)
set(library_name GTSAM) # For substitution in dllexport.h.in
configure_file("${GTSAM_SOURCE_DIR}/cmake/dllexport.h.in" "dllexport.h")
Expand Down
4 changes: 2 additions & 2 deletions gtsam/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Install headers
file(GLOB base_headers "*.h")
install(FILES ${base_headers} DESTINATION include/gtsam/base)
install(FILES ${base_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/base)

file(GLOB base_headers_tree "treeTraversal/*.h")
install(FILES ${base_headers_tree} DESTINATION include/gtsam/base/treeTraversal)
install(FILES ${base_headers_tree} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/base/treeTraversal)

# Build tests
add_subdirectory(tests)
4 changes: 4 additions & 0 deletions gtsam/base/std_optional_serialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ namespace boost { namespace serialization { struct U{}; } }
namespace std { template<> struct is_trivially_default_constructible<boost::serialization::U> : std::false_type {}; }
namespace std { template<> struct is_trivially_copy_constructible<boost::serialization::U> : std::false_type {}; }
namespace std { template<> struct is_trivially_move_constructible<boost::serialization::U> : std::false_type {}; }
// QCC (The QNX GCC-based Compiler) also has this issue, but it also extends to trivial destructor.
#if defined(__QNX__)
namespace std { template<> struct is_trivially_destructible<boost::serialization::U> : std::false_type {}; }
#endif
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion gtsam/basis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB basis_headers "*.h")
install(FILES ${basis_headers} DESTINATION include/gtsam/basis)
install(FILES ${basis_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/basis)

# Build tests
add_subdirectory(tests)
5 changes: 5 additions & 0 deletions gtsam/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

// Paths to example datasets distributed with GTSAM
#define GTSAM_SOURCE_TREE_DATASET_DIR "@GTSAM_SOURCE_DIR@/examples/Data"
#if !defined(__QNX__)
#define GTSAM_INSTALLED_DATASET_DIR "@GTSAM_TOOLBOX_INSTALL_PATH@/gtsam_examples/Data"
#else
//Set toolbox path to the path on the target.
#define GTSAM_INSTALLED_DATASET_DIR "@QNX_TARGET_DATASET_DIR@/gtsam_examples/Data"
#endif

// Whether GTSAM is compiled to use quaternions for Rot3 (otherwise uses rotation matrices)
#cmakedefine GTSAM_USE_QUATERNIONS
Expand Down
3 changes: 2 additions & 1 deletion gtsam/discrete/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Install headers
set(subdir discrete)
file(GLOB discrete_headers "*.h")
install(FILES ${discrete_headers} DESTINATION include/gtsam/discrete)
# FIXME: exclude headers
install(FILES ${discrete_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/discrete)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB geometry_headers "*.h")
install(FILES ${geometry_headers} DESTINATION include/gtsam/geometry)
install(FILES ${geometry_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/geometry)

# Build tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/hybrid/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Install headers
set(subdir hybrid)
file(GLOB hybrid_headers "*.h")
install(FILES ${hybrid_headers} DESTINATION include/gtsam/hybrid)
install(FILES ${hybrid_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/hybrid)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/inference/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB inference_headers "*.h")
install(FILES ${inference_headers} DESTINATION include/gtsam/inference)
install(FILES ${inference_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/inference)

# Build tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/inference/tests/testOrdering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ TEST(Ordering, MetisLoop) {
symbolicGraph.push_factor(0, 5);

// METIS
#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__QNX__)
{
Ordering actual = Ordering::Create(Ordering::METIS, symbolicGraph);
// - P( 1 0 3)
Expand Down
2 changes: 1 addition & 1 deletion gtsam/linear/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB linear_headers "*.h")
install(FILES ${linear_headers} DESTINATION include/gtsam/linear)
install(FILES ${linear_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/linear)

# Build tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/navigation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB navigation_headers "*.h")
install(FILES ${navigation_headers} DESTINATION include/gtsam/navigation)
install(FILES ${navigation_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/navigation)

# Add all tests
add_subdirectory(tests)
4 changes: 2 additions & 2 deletions gtsam/nonlinear/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Install headers
file(GLOB nonlinear_headers "*.h")
install(FILES ${nonlinear_headers} DESTINATION "include/gtsam/nonlinear")
install(FILES ${nonlinear_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/nonlinear)

file(GLOB nonlinear_headers_internal "internal/*.h")
install(FILES ${nonlinear_headers_internal} DESTINATION "include/gtsam/nonlinear/internal")
install(FILES ${nonlinear_headers_internal} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/nonlinear/internal)

# Build tests
add_subdirectory(tests)
12 changes: 11 additions & 1 deletion gtsam/nonlinear/tests/testSerializationNonlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ using namespace std;
using namespace gtsam;
using namespace gtsam::serializationTestHelpers;


/* ************************************************************************* */
// Create GUIDs for Noisemodels
BOOST_CLASS_EXPORT_GUID(gtsam::noiseModel::Diagonal, "gtsam_noiseModel_Diagonal")
Expand Down Expand Up @@ -153,9 +152,20 @@ TEST(Serialization, NoiseModelFactor1_backwards_compatibility) {

// Deserialize XML
PriorFactor<Pose3> factor_deserialized_xml = PriorFactor<Pose3>();
#if !defined(__QNX__)
deserializeFromXMLFile(GTSAM_SOURCE_TREE_DATASET_DIR
"/../../gtsam/nonlinear/tests/priorFactor.xml",
factor_deserialized_xml);
#else
/*QNX is cross-compiled for, and does not support make, cmake, or ctest natively. Additionally, space is a large constraint on embedded systems.
* Therefore, running tests must be done by manually copying test executables and required data files over, preferably avoiding
* copying the whole source tree. Thus, we set the default file lookup to the same folder. Please copy data files to the same folder as this test.
* for more info, check PR#1968 https://github.com/borglab/gtsam/pull/1968
*/
bool c = deserializeFromXMLFile(
"priorFactor.xml",
factor_deserialized_xml);
#endif
EXPECT(assert_equal(factor, factor_deserialized_xml));
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion gtsam/sam/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB sam_headers "*.h")
install(FILES ${sam_headers} DESTINATION include/gtsam/sam)
install(FILES ${sam_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/sam)

# Build tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/sfm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB sfm_headers "*.h")
install(FILES ${sfm_headers} DESTINATION include/gtsam/sfm)
install(FILES ${sfm_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/sfm)

# Build tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/slam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set (slam_excluded_headers #"")
)

file(GLOB slam_headers "*.h")
install(FILES ${slam_headers} DESTINATION include/gtsam/slam)
install(FILES ${slam_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/slam)

# Build tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam/symbolic/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB symbolic_headers "*.h")
install(FILES ${symbolic_headers} DESTINATION include/gtsam/symbolic)
install(FILES ${symbolic_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam/symbolic)

# Build tests
add_subdirectory(tests)
4 changes: 2 additions & 2 deletions gtsam/symbolic/tests/testSymbolicBayesTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ TEST(SymbolicBayesTree, COLAMDvsMETIS) {
{
Ordering ordering = Ordering::Create(Ordering::METIS, sfg);
// Linux and Mac split differently when using Metis
#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__QNX__)
EXPECT(assert_equal(Ordering{5, 4, 2, 1, 0, 3}, ordering));
#elif defined(_WIN32)
EXPECT(assert_equal(Ordering{4, 3, 1, 0, 5, 2}, ordering));
Expand All @@ -700,7 +700,7 @@ TEST(SymbolicBayesTree, COLAMDvsMETIS) {
// | | - P( 5 | 0 4)
// | - P( 2 | 1 3)
SymbolicBayesTree expected;
#if defined(__APPLE__)
#if defined(__APPLE__) || defined(__QNX__)
expected.insertRoot(
NodeClique(Keys(1)(0)(3), 3,
Children( //
Expand Down
2 changes: 1 addition & 1 deletion gtsam_unstable/base/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB base_headers "*.h")
install(FILES ${base_headers} DESTINATION include/gtsam_unstable/base)
install(FILES ${base_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/base)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam_unstable/discrete/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB discrete_headers "*.h")
install(FILES ${discrete_headers} DESTINATION include/gtsam_unstable/discrete)
install(FILES ${discrete_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/discrete)

# Add all tests
add_subdirectory(tests)
Expand Down
4 changes: 4 additions & 0 deletions gtsam_unstable/discrete/tests/testScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ TEST(schedulingExample, test) {

/* ************************************************************************* */
TEST(schedulingExample, smallFromFile) {
#if !defined(__QNX__)
string path(TOPSRCDIR "/gtsam_unstable/discrete/examples/");
#else
string path(""); //Same Directory
#endif
Scheduler s(2, path + "small.csv");

// add areas
Expand Down
2 changes: 1 addition & 1 deletion gtsam_unstable/dynamics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB dynamics_headers "*.h")
install(FILES ${dynamics_headers} DESTINATION include/gtsam_unstable/dynamics)
install(FILES ${dynamics_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/dynamics)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam_unstable/geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB geometry_headers "*.h")
install(FILES ${geometry_headers} DESTINATION include/gtsam_unstable/geometry)
install(FILES ${geometry_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/geometry)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam_unstable/linear/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB linear_headers "*.h")
install(FILES ${linear_headers} DESTINATION include/gtsam_unstable/linear)
install(FILES ${linear_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/linear)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam_unstable/nonlinear/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Install headers
file(GLOB nonlinear_headers "*.h")
install(FILES ${nonlinear_headers} DESTINATION include/gtsam_unstable/nonlinear)
install(FILES ${nonlinear_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/nonlinear)

# Add all tests
add_subdirectory(tests)
2 changes: 1 addition & 1 deletion gtsam_unstable/partition/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Install headers
file(GLOB partition_headers "*.h")
install(FILES ${partition_headers} DESTINATION include/gtsam_unstable/partition)
install(FILES ${partition_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/partition)

add_subdirectory(tests)
6 changes: 6 additions & 0 deletions gtsam_unstable/partition/tests/testFindSeparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ TEST ( Partition, edgePartitionByMetis2 )
graph.push_back(std::make_shared<GenericFactor3D>(1, 2, 1, NODE_POSE_3D, NODE_POSE_3D, 1));
graph.push_back(std::make_shared<GenericFactor3D>(2, 3, 2, NODE_POSE_3D, NODE_POSE_3D, 20));
graph.push_back(std::make_shared<GenericFactor3D>(3, 4, 3, NODE_POSE_3D, NODE_POSE_3D, 1));
//QNX Testing: fix tiebreaker to match
#if !defined(__QNX__)
std::vector<size_t> keys{0, 1, 2, 3, 4};
#else
//Anything where 2 is before 0 will work.
std::vector<size_t> keys{2, 0, 3, 1, 4};
#endif

WorkSpace workspace(6);
std::optional<MetisResult> actual = edgePartitionByMetis<GenericGraph3D>(graph, keys,
Expand Down
2 changes: 1 addition & 1 deletion gtsam_unstable/slam/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set (slam_excluded_headers #"")

file(GLOB slam_headers "*.h")
list(REMOVE_ITEM slam_headers ${slam_excluded_headers})
install(FILES ${slam_headers} DESTINATION include/gtsam_unstable/slam)
install(FILES ${slam_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gtsam_unstable/slam)

# Add all tests
add_subdirectory(tests)

0 comments on commit b762707

Please sign in to comment.