From e0ce34833a5d27b142e0b3aad70bf7a99648d966 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 18:48:44 -0400 Subject: [PATCH 1/4] remove postfix for python when compiling with Timing and Profiling --- python/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5012189249..d11f414a73 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -118,6 +118,8 @@ set_target_properties(${GTSAM_PYTHON_TARGET} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam" DEBUG_POSTFIX "" # Otherwise you will have a wrong name RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name + TIMING_POSTFIX "" # Otherwise you will have a wrong name + PROFILING_POSTFIX "" # Otherwise you will have a wrong name ) if(WIN32) @@ -218,6 +220,8 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) LIBRARY_OUTPUT_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable" DEBUG_POSTFIX "" # Otherwise you will have a wrong name RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name + TIMING_POSTFIX "" # Otherwise you will have a wrong name + PROFILING_POSTFIX "" # Otherwise you will have a wrong name ) set(GTSAM_UNSTABLE_MODULE_PATH ${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable) From 5c75a52fa6378f9371e83d2996c7beb4a6fcf862 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 18:50:50 -0400 Subject: [PATCH 2/4] remove extra whitespaces --- python/CMakeLists.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d11f414a73..41dd4b1416 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -8,7 +8,7 @@ endif() # Generate setup.py. file(READ "${PROJECT_SOURCE_DIR}/README.md" README_CONTENTS) configure_file(${PROJECT_PYTHON_SOURCE_DIR}/setup.py.in - ${GTSAM_PYTHON_BUILD_DIRECTORY}/setup.py) + ${GTSAM_PYTHON_BUILD_DIRECTORY}/setup.py) # Supply MANIFEST.in for older versions of Python file(COPY ${PROJECT_PYTHON_SOURCE_DIR}/MANIFEST.in @@ -23,10 +23,9 @@ include(PybindWrap) # Load the pybind11 code - # This is required to avoid an error in modern pybind11 cmake scripts: if(POLICY CMP0057) - cmake_policy(SET CMP0057 NEW) + cmake_policy(SET CMP0057 NEW) endif() # Use bundled pybind11 version @@ -129,14 +128,14 @@ if(WIN32) ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/${GTSAM_OUTPUT_NAME}.pyd" - "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/gtsam.pyd" + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/gtsam.pyd" ) ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$;$" - "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/" + "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam/" COMMAND_EXPAND_LISTS - VERBATIM + VERBATIM ) endif() @@ -200,7 +199,6 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) gtsam::gtsfm::KeypointsVector gtsam::gtsfm::SfmTrack2dVector) - pybind_wrap(${GTSAM_PYTHON_UNSTABLE_TARGET} # target ${PROJECT_SOURCE_DIR}/gtsam_unstable/gtsam_unstable.i # interface_header "gtsam_unstable.cpp" # generated_cpp @@ -228,7 +226,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) # Copy all python files to build folder. copy_directory("${CMAKE_CURRENT_SOURCE_DIR}/gtsam_unstable" - "${GTSAM_UNSTABLE_MODULE_PATH}") + "${GTSAM_UNSTABLE_MODULE_PATH}") # Hack to get python test files copied every time they are modified file(GLOB GTSAM_UNSTABLE_PYTHON_TEST_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/gtsam_unstable/" "${CMAKE_CURRENT_SOURCE_DIR}/gtsam_unstable/tests/*.py") @@ -241,7 +239,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) if(WIN32) set_target_properties(${GTSAM_PYTHON_UNSTABLE_TARGET} PROPERTIES SUFFIX ".pyd" - ) + ) ADD_CUSTOM_COMMAND(TARGET ${GTSAM_PYTHON_UNSTABLE_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable/${GTSAM_UNSTABLE_OUTPUT_NAME}.pyd" @@ -252,7 +250,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) "$;$" "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable/" COMMAND_EXPAND_LISTS - VERBATIM + VERBATIM ) endif() From 234dd0930cf60b33c21b56afe844bae0fda97c08 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 18:51:18 -0400 Subject: [PATCH 3/4] common macro for setting python library properties --- python/CMakeLists.txt | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 41dd4b1416..9070d191b9 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -18,6 +18,19 @@ set(WRAP_BUILD_TYPE_POSTFIXES ${GTSAM_BUILD_TYPE_POSTFIXES}) include(PybindWrap) +macro(SET_PYTHON_TARGET_PROPERTIES PYTHON_TARGET OUTPUT_NAME OUTPUT_DIRECTORY) + set_target_properties(${PYTHON_TARGET} PROPERTIES + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" + INSTALL_RPATH_USE_LINK_PATH TRUE + OUTPUT_NAME "${OUTPUT_NAME}" + LIBRARY_OUTPUT_DIRECTORY "${OUTPUT_DIRECTORY}" + DEBUG_POSTFIX "" # Otherwise you will have a wrong name + RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name + TIMING_POSTFIX "" # Otherwise you will have a wrong name + PROFILING_POSTFIX "" # Otherwise you will have a wrong name + ) +endmacro() + ############################################################ ## Load the necessary files to compile the wrapper @@ -110,16 +123,7 @@ pybind_wrap(${GTSAM_PYTHON_TARGET} # target ${GTSAM_ENABLE_BOOST_SERIALIZATION} # use_boost_serialization ) -set_target_properties(${GTSAM_PYTHON_TARGET} PROPERTIES - INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" - INSTALL_RPATH_USE_LINK_PATH TRUE - OUTPUT_NAME "${GTSAM_OUTPUT_NAME}" - LIBRARY_OUTPUT_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam" - DEBUG_POSTFIX "" # Otherwise you will have a wrong name - RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name - TIMING_POSTFIX "" # Otherwise you will have a wrong name - PROFILING_POSTFIX "" # Otherwise you will have a wrong name - ) +SET_PYTHON_TARGET_PROPERTIES(${GTSAM_PYTHON_TARGET} ${GTSAM_OUTPUT_NAME} "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam") if(WIN32) set_target_properties(${GTSAM_PYTHON_TARGET} PROPERTIES @@ -211,16 +215,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) ${GTSAM_ENABLE_BOOST_SERIALIZATION} # use_boost_serialization ) - set_target_properties(${GTSAM_PYTHON_UNSTABLE_TARGET} PROPERTIES - INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" - INSTALL_RPATH_USE_LINK_PATH TRUE - OUTPUT_NAME "${GTSAM_UNSTABLE_OUTPUT_NAME}" - LIBRARY_OUTPUT_DIRECTORY "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable" - DEBUG_POSTFIX "" # Otherwise you will have a wrong name - RELWITHDEBINFO_POSTFIX "" # Otherwise you will have a wrong name - TIMING_POSTFIX "" # Otherwise you will have a wrong name - PROFILING_POSTFIX "" # Otherwise you will have a wrong name - ) + SET_PYTHON_TARGET_PROPERTIES(${GTSAM_PYTHON_UNSTABLE_TARGET} ${GTSAM_UNSTABLE_OUTPUT_NAME} "${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable") set(GTSAM_UNSTABLE_MODULE_PATH ${GTSAM_PYTHON_BUILD_DIRECTORY}/gtsam_unstable) From 95098e0cade22f672f3b426099feb91c2a1863d7 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 26 Sep 2024 18:51:30 -0400 Subject: [PATCH 4/4] add missing preprocessor guard --- gtsam/sfm/TranslationFactor.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gtsam/sfm/TranslationFactor.h b/gtsam/sfm/TranslationFactor.h index 9af3b184e8..33bc82f5a9 100644 --- a/gtsam/sfm/TranslationFactor.h +++ b/gtsam/sfm/TranslationFactor.h @@ -149,11 +149,13 @@ class BilinearAngleTranslationFactor } private: +#ifdef GTSAM_ENABLE_BOOST_SERIALIZATION friend class boost::serialization::access; template void serialize(ARCHIVE& ar, const unsigned int /*version*/) { ar& boost::serialization::make_nvp( "Base", boost::serialization::base_object(*this)); } +#endif }; // \ BilinearAngleTranslationFactor } // namespace gtsam