diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index df6e058..98e65c5 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,8 +10,8 @@ assignees: pzhu-flexiv ## Version info -- Sim Plugin: [e.g. v1.1] -- OS: [e.g. Ubuntu 20.04, x86_64] +- Sim Plugin: [e.g. v1.2] +- OS: [e.g. Ubuntu 22.04, x86_64] ## How urgent is this bug? Have you found any workarounds? diff --git a/CMakeLists.txt b/CMakeLists.txt index 2520a8a..2bb1520 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,20 +3,20 @@ cmake_minimum_required(VERSION 3.16.3) # =================================================================== # PROJECT SETUP # =================================================================== -project(flexiv_sim_plugin VERSION 1.1.0) +project(flexiv_sim_plugin VERSION 1.2.0) # Configure build type if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "CMake build type" FORCE) endif() -set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo") +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug" "RelWithDebInfo" "MinSizeRel") # Set static library according to platform message(STATUS "OS: ${CMAKE_SYSTEM_NAME}") message(STATUS "Processor: ${CMAKE_SYSTEM_PROCESSOR}") if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") - set(SIM_PLUGIN_STATIC_LIB "libflexiv_sim_plugin.x86_64-linux-gnu.a") + set(SIM_PLUGIN_LIB "libflexiv_sim_plugin.x86_64-linux-gnu.a") else() message(FATAL_ERROR "Linux with ${CMAKE_SYSTEM_PROCESSOR} processor is currently not supported.") endif() @@ -32,51 +32,50 @@ endif() # Threads set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) -if(Threads_FOUND) - message(STATUS "Found Threads: HAVE_PTHREAD = ${THREADS_HAVE_PTHREAD_ARG}") -endif() +message(STATUS "Found Threads") # spdlog find_package(spdlog REQUIRED) -if(spdlog_FOUND) - message(STATUS "Found spdlog: ${spdlog_DIR}") -endif() +message(STATUS "Found spdlog v${spdlog_VERSION}: ${spdlog_DIR}") # Fast-DDS (Fast-RTPS) -find_package(fastrtps 2.6.7 REQUIRED) -if(fastrtps_FOUND) - message(STATUS "Found fastrtps: ${fastrtps_DIR}") -endif() +find_package(fastrtps REQUIRED) +message(STATUS "Found fastrtps v${fastrtps_VERSION}: ${fastrtps_DIR}") + +# Fast-CDR +find_package(fastcdr REQUIRED) +message(STATUS "Found fastcdr v${fastcdr_VERSION}: ${fastcdr_DIR}") # =================================================================== # CREATE LIBRARY # =================================================================== -# Create an INTERFACE library with no source file to compile -add_library(${PROJECT_NAME} INTERFACE) +# Create static library target with dummy source +add_library(${PROJECT_NAME} STATIC ${CMAKE_CURRENT_SOURCE_DIR}/lib/dummy.cpp) -# Create an alias of the library using flexiv namespace, -# to imitate the install target which uses flexiv namespace. +# Create an alias of the target with flexiv namespace add_library(flexiv::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -target_include_directories(${PROJECT_NAME} INTERFACE +# Set include directories +target_include_directories(${PROJECT_NAME} PUBLIC $ $ ) -target_link_libraries(${PROJECT_NAME} INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/lib/${SIM_PLUGIN_STATIC_LIB} +# Link to dependencies +target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads spdlog::spdlog fastrtps + fastcdr ) # Use moderate compiler warning option if(CMAKE_HOST_UNIX) - target_compile_options(${PROJECT_NAME} INTERFACE -Wall -Wextra) + target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wextra) else() - target_compile_options(${PROJECT_NAME} INTERFACE /W1) + target_compile_options(${PROJECT_NAME} PUBLIC /W1) endif() -# Install the INTERFACE library +# Install the library include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/FlexivInstallLibrary.cmake) FlexivInstallLibrary() diff --git a/README.md b/README.md index 1f9d36e..7c480bc 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ An example program that mocks an external simulator is provided and can be used NOTE: the robot serial number provided to the program is the same one you noted down when creating the simulated robot in Flexiv Elements Studio. 2. Go back to Elements Studio, then restart the exited simulator by toggling ON the *Connect* button. -3. Wait for the connection to establish. If the connection is successful, you should see the visualized robot in Elements Studio moving every joint back and forth. A software error should occur in Elements Studio which is expected because the mock external simulator did not close the loop by applying the calculated joint torques command to the simulated robot in it. This won't happen to real external simulators. +3. Wait for the connection to establish. If the connection is successful, you should see the visualized robot in Elements Studio moving every joint back and forth. NOTE: a software error should occur in Elements Studio which is expected because the mock external simulator did not close the loop by applying the calculated joint torques command to the simulated robot in it. This won't happen to real external simulators. ## Quick Start - Python diff --git a/cmake/FlexivInstallLibrary.cmake b/cmake/FlexivInstallLibrary.cmake index 1d2d0d6..2d64d84 100644 --- a/cmake/FlexivInstallLibrary.cmake +++ b/cmake/FlexivInstallLibrary.cmake @@ -68,20 +68,28 @@ macro(FlexivInstallLibrary) COMPATIBILITY AnyNewerVersion ) - # copy the *-targets.cmake file to the CMAKE_INSTALL_PREFIX directory + # Copy the *-targets.cmake file to the CMAKE_INSTALL_PREFIX directory install(EXPORT "${PROJECT_NAME}-targets" FILE "${PROJECT_NAME}-targets.cmake" NAMESPACE "flexiv::" DESTINATION "lib/cmake/${PROJECT_NAME}" ) - # copy the *.-config file to the CMAKE_INSTALL_PREFIX directory. This will specify the dependencies. + # Copy the *.-config file to the CMAKE_INSTALL_PREFIX directory. This will specify the dependencies. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in" "${PROJECT_NAME}-config.cmake" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" DESTINATION "lib/cmake/${PROJECT_NAME}" ) + # Replace the dummy static lib with the actual static lib + install(CODE + "file(REMOVE ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})") + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/lib/${SIM_PLUGIN_LIB} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + RENAME ${CMAKE_STATIC_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + # Use the CPack Package Generator set(CPACK_PACKAGE_VENDOR "Flexiv") set(CPACK_PACKAGE_CONTACT "support@flexiv.com") diff --git a/cmake/flexiv_sim_plugin-config.cmake.in b/cmake/flexiv_sim_plugin-config.cmake.in index 2666693..4dad5dd 100644 --- a/cmake/flexiv_sim_plugin-config.cmake.in +++ b/cmake/flexiv_sim_plugin-config.cmake.in @@ -4,7 +4,8 @@ include(CMakeFindDependencyMacro) set(THREADS_PREFER_PTHREAD_FLAG ON) find_dependency(Threads REQUIRED) find_dependency(spdlog REQUIRED) -find_dependency(fastrtps 2.6.7 REQUIRED) +find_dependency(fastrtps REQUIRED) +find_dependency(fastcdr REQUIRED) # Add targets file include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake") diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index 64b5d9f..1c26f3c 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NAME = "Flexiv Sim Plugin APIs" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.1.0 +PROJECT_NUMBER = 1.2.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/example/mock_external_simulator.cpp b/example/mock_external_simulator.cpp index 943669c..4bfceed 100644 --- a/example/mock_external_simulator.cpp +++ b/example/mock_external_simulator.cpp @@ -27,8 +27,7 @@ constexpr double kSineAmp = 0.035; constexpr double kSineFreq = 0.3; // Initial joint positions when the robot is at home posture [rad] -constexpr std::array kInitQ - = {0.0, -0.698132, 0.0, 1.5708, 0.0, 0.698132, 0.0}; +const std::vector kInitQ = {0.0, -0.698132, 0.0, 1.5708, 0.0, 0.698132, 0.0}; // Servo cycle of the physics loop unsigned int g_servo_cycle = 0; @@ -60,13 +59,13 @@ void StepPhysics(sim_plugin::UserNode& user_node) robot_states.servo_cycle = g_servo_cycle++; // Set joint positions to sine waves - for (size_t i = 0; i < sim_plugin::kJointDoF; i++) { + for (size_t i = 0; i < kInitQ.size(); i++) { robot_states.q[i] = kInitQ[i] + kSineAmp * sin(2 * M_PI * kSineFreq * g_servo_cycle * kPhysicsPeriod); } // Set joint velocities to corresponding cosine waves - for (size_t i = 0; i < sim_plugin::kJointDoF; i++) { + for (size_t i = 0; i < kInitQ.size(); i++) { robot_states.dq[i] = kSineAmp * 2 * M_PI * kSineFreq * cos(2 * M_PI * kSineFreq * g_servo_cycle * kPhysicsPeriod); } @@ -87,7 +86,7 @@ void StepPhysics(sim_plugin::UserNode& user_node) // Step 4: apply joint torques command to the simulated robot in the external simulator // ============================================================================================= - auto target_joint_torques = user_node.robot_commands().tau_d; + auto target_joint_torques = user_node.robot_commands().target_drives; // Call the external simulator's API to apply the target joint torques // End the current physics step with kPhysicsPeriod as the total loop period diff --git a/example_py/mock_external_simulator.py b/example_py/mock_external_simulator.py index 09d1e86..29a60d3 100644 --- a/example_py/mock_external_simulator.py +++ b/example_py/mock_external_simulator.py @@ -85,7 +85,7 @@ def step_physics(user_node, logger): # Step 4: apply joint torques command to the simulated robot in the external simulator # ============================================================================================= - target_joint_torques = user_node.robot_commands().tau_d + target_joint_torques = user_node.robot_commands().target_drives # Call the external simulator's API to apply the target joint torques # End the current physics step with kPhysicsPeriod as roughly the total loop period diff --git a/include/flexiv/sim_plugin/data.hpp b/include/flexiv/sim_plugin/data.hpp index 67eaf47..2384de3 100644 --- a/include/flexiv/sim_plugin/data.hpp +++ b/include/flexiv/sim_plugin/data.hpp @@ -8,14 +8,12 @@ #define FLEXIV_SIM_PLUGIN_DATA_HPP_ #include +#include #include namespace flexiv { namespace sim_plugin { -/** Joint-space degrees of freedom of the simulated robot */ -constexpr size_t kJointDoF = 7; - /** Number of simulated digital IO ports */ constexpr size_t kIOPorts = 16; @@ -23,41 +21,48 @@ constexpr size_t kIOPorts = 16; struct SimRobotStates { /** @brief Customized constructor */ - SimRobotStates(uint64_t _servo_cycle, const std::array& _q, - const std::array& _dq) + SimRobotStates( + uint64_t _servo_cycle, const std::vector& _q, const std::vector& _dq) : servo_cycle(_servo_cycle) , q(_q) , dq(_dq) { } + /** @brief Default constructor */ SimRobotStates() = default; /** Servo cycle incremented once per physics step of the external simulator */ uint64_t servo_cycle = 0; - /** Current joint positions of the simulated robot [rad] */ - std::array q = {}; + /** Current joint positions of the simulated robot: \f$ q \in \mathbb{R}^{n \times 1} \f$. Unit: + * \f$ [rad] or [m] \f$. + * @note This contains values for both the external axes (if any) and the robot manipulator. */ + std::vector q = {}; - /** Current joint velocities of the simulated robot [rad/s] */ - std::array dq = {}; + /** Current joint velocities of the simulated robot: \f$ \dot{q} \in \mathbb{R}^{n \times 1} + * \f$. Unit: \f$ [rad/s] or [m/s] \f$. + * @note This contains values for both the external axes (if any) and the robot manipulator. */ + std::vector dq = {}; }; /** Commands data for a simulated robot in the external simulator */ struct SimRobotCommands { /** @brief Customized constructor */ - SimRobotCommands(const std::array& _tau_d, + SimRobotCommands(const std::vector& _target_drives, const std::array& _digital_outputs) - : tau_d(_tau_d) + : target_drives(_target_drives) , digital_outputs(_digital_outputs) { } /** @brief Default constructor */ SimRobotCommands() = default; - /** Target joint torques for the simulated robot [Nm]. */ - std::array tau_d = {}; + /** Target joint drives for the simulated robot, can be torques or velocities depending on the + * drive type of the joint. Unit: \f$ [Nm] or [rad/s] or [m/s] \f$. + * @note This contains values for both the external axes (if any) and the robot manipulator. */ + std::vector target_drives = {}; /** Desired digital outputs for the simulated robot. The index of this boolean array corresponds * to that of the digital output ports. True: port high, false: port low. */ diff --git a/lib/dummy.cpp b/lib/dummy.cpp new file mode 100644 index 0000000..6299cc5 --- /dev/null +++ b/lib/dummy.cpp @@ -0,0 +1,5 @@ +/** + * @file dummy.cpp + * @brief A dummy source file to add portability to the installed flexiv_rdk library + */ +void dummy() { } diff --git a/lib/libflexiv_sim_plugin.x86_64-linux-gnu.a b/lib/libflexiv_sim_plugin.x86_64-linux-gnu.a index 5200750..75a9215 100644 Binary files a/lib/libflexiv_sim_plugin.x86_64-linux-gnu.a and b/lib/libflexiv_sim_plugin.x86_64-linux-gnu.a differ diff --git a/thirdparty/build_and_install_dependencies.sh b/thirdparty/build_and_install_dependencies.sh index 4a43448..a0c4413 100644 --- a/thirdparty/build_and_install_dependencies.sh +++ b/thirdparty/build_and_install_dependencies.sh @@ -19,23 +19,31 @@ fi INSTALL_DIR=$1 echo "Dependencies will be installed to: $INSTALL_DIR" -# Use specified number for parallel build jobs, otherwise use number of cores +# Use specified number for parallel build jobs, otherwise use 4 if [ -n "$2" ] ;then - NUM_JOBS=$2 + export NUM_JOBS=$2 else - NUM_JOBS=4 + export NUM_JOBS=4 fi echo "Number of parallel build jobs: $NUM_JOBS" +# Set shared cmake arguments +SHARED_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=OFF \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ + -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ + -DBUILD_TESTING=OFF" # Clone all dependencies in a subfolder mkdir -p cloned && cd cloned +export SHARED_CMAKE_ARGS # Build and install all dependencies to INSTALL_DIR -bash $SCRIPTPATH/scripts/install_spdlog.sh $INSTALL_DIR $NUM_JOBS -bash $SCRIPTPATH/scripts/install_tinyxml2.sh $INSTALL_DIR $NUM_JOBS -bash $SCRIPTPATH/scripts/install_foonathan_memory.sh $INSTALL_DIR $NUM_JOBS -bash $SCRIPTPATH/scripts/install_Fast-CDR.sh $INSTALL_DIR $NUM_JOBS -bash $SCRIPTPATH/scripts/install_Fast-DDS.sh $INSTALL_DIR $NUM_JOBS +bash $SCRIPTPATH/scripts/install_spdlog.sh +bash $SCRIPTPATH/scripts/install_tinyxml2.sh +bash $SCRIPTPATH/scripts/install_foonathan_memory.sh +bash $SCRIPTPATH/scripts/install_Fast-CDR.sh +bash $SCRIPTPATH/scripts/install_Fast-DDS.sh echo ">>>>>>>>>> Finished <<<<<<<<<<" diff --git a/thirdparty/scripts/install_Fast-CDR.sh b/thirdparty/scripts/install_Fast-CDR.sh index f582c3a..0e93f81 100644 --- a/thirdparty/scripts/install_Fast-CDR.sh +++ b/thirdparty/scripts/install_Fast-CDR.sh @@ -2,31 +2,21 @@ set -e echo "Installing Fast-CDR" -# Get install directory and number of parallel build jobs as script arguments -INSTALL_DIR=$1 -NUM_JOBS=$2 +# Use a specific version +VER_TAG=v1.0.28 # Clone source code if [ ! -d Fast-CDR ] ; then - git clone https://github.com/eProsima/Fast-CDR.git + git clone https://github.com/eProsima/Fast-CDR.git --branch $VER_TAG cd Fast-CDR else cd Fast-CDR + git checkout $VER_TAG fi -# Use specific version -git fetch -p -git checkout v1.0.24 -git submodule update --init --recursive - # Configure CMake mkdir -p build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ - -DCOMPILE_EXAMPLES=OFF +cmake .. $SHARED_CMAKE_ARGS -DCOMPILE_EXAMPLES=OFF # Build and install cmake --build . --target install --config Release -j $NUM_JOBS diff --git a/thirdparty/scripts/install_Fast-DDS.sh b/thirdparty/scripts/install_Fast-DDS.sh index 443978e..c0204e1 100644 --- a/thirdparty/scripts/install_Fast-DDS.sh +++ b/thirdparty/scripts/install_Fast-DDS.sh @@ -3,34 +3,27 @@ set -e echo "Installing Fast-DDS" -# Get install directory and number of parallel build jobs as script arguments -INSTALL_DIR=$1 -NUM_JOBS=$2 +# Use a specific version +VER_TAG=v2.6.10 # Clone source code if [ ! -d Fast-DDS ] ; then - git clone https://github.com/eProsima/Fast-DDS.git + git clone https://github.com/eProsima/Fast-DDS.git --branch $VER_TAG cd Fast-DDS else cd Fast-DDS + git checkout $VER_TAG fi -# Use specific version -git fetch -p -git checkout v2.6.7 +# Initialize submodules git submodule update --init --recursive # Configure CMake mkdir -p build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCMAKE_PREFIX_PATH=$INSTALL_DIR \ +cmake .. $SHARED_CMAKE_ARGS \ -DTHIRDPARTY_Asio=ON \ -DCOMPILE_EXAMPLES=OFF \ - -DSQLITE3_SUPPORT=OFF \ - -DOPENSSL_USE_STATIC_LIBS=ON + -DSQLITE3_SUPPORT=OFF # Build and install cmake --build . --target install --config Release -j $NUM_JOBS diff --git a/thirdparty/scripts/install_foonathan_memory.sh b/thirdparty/scripts/install_foonathan_memory.sh index 5a6c3c5..d0d794e 100644 --- a/thirdparty/scripts/install_foonathan_memory.sh +++ b/thirdparty/scripts/install_foonathan_memory.sh @@ -2,30 +2,21 @@ set -e echo "Installing foonathan_memory" -# Get install directory and number of parallel build jobs as script arguments -INSTALL_DIR=$1 -NUM_JOBS=$2 +# Use a specific version +VER_TAG=v1.3.1 # Clone source code if [ ! -d foonathan_memory_vendor ] ; then - git clone https://github.com/eProsima/foonathan_memory_vendor.git + git clone https://github.com/eProsima/foonathan_memory_vendor.git --branch $VER_TAG cd foonathan_memory_vendor else cd foonathan_memory_vendor + git checkout $VER_TAG fi -# Use specific version -git fetch -p -git checkout v1.2.1 -git submodule update --init --recursive - # Configure CMake mkdir -p build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCMAKE_PREFIX_PATH=$INSTALL_DIR +cmake .. $SHARED_CMAKE_ARGS # Build and install cmake --build . --target install --config Release -j $NUM_JOBS diff --git a/thirdparty/scripts/install_spdlog.sh b/thirdparty/scripts/install_spdlog.sh index 3fc6b42..abd0f9e 100644 --- a/thirdparty/scripts/install_spdlog.sh +++ b/thirdparty/scripts/install_spdlog.sh @@ -1,31 +1,23 @@ #!/bin/bash set -e -echo "Installing spdlog" -# Get install directory and number of parallel build jobs as script arguments -INSTALL_DIR=$1 -NUM_JOBS=$2 +# Use a specific version +VER_TAG=v1.14.1 # Clone source code if [ ! -d spdlog ] ; then - git clone https://github.com/gabime/spdlog.git + git clone https://github.com/gabime/spdlog.git --branch $VER_TAG cd spdlog else cd spdlog + git checkout $VER_TAG fi -# Use specific version -git fetch -p -git checkout v1.14.1 -git submodule update --init --recursive - # Configure CMake mkdir -p build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCMAKE_PREFIX_PATH=$INSTALL_DIR +cmake .. $SHARED_CMAKE_ARGS \ + -DSPDLOG_BUILD_EXAMPLE=OFF \ + -DSPDLOG_BUILD_TESTS=OFF # Build and install cmake --build . --target install --config Release -j $NUM_JOBS diff --git a/thirdparty/scripts/install_tinyxml2.sh b/thirdparty/scripts/install_tinyxml2.sh index 7458139..e443ef8 100644 --- a/thirdparty/scripts/install_tinyxml2.sh +++ b/thirdparty/scripts/install_tinyxml2.sh @@ -2,30 +2,21 @@ set -e echo "Installing tinyxml2" -# Get install directory and number of parallel build jobs as script arguments -INSTALL_DIR=$1 -NUM_JOBS=$2 +# Use a specific version +VER_TAG=8.0.0 # Clone source code if [ ! -d tinyxml2 ] ; then - git clone https://github.com/leethomason/tinyxml2.git + git clone https://github.com/leethomason/tinyxml2.git --branch $VER_TAG cd tinyxml2 else cd tinyxml2 + git checkout $VER_TAG fi -# Use specific version -git fetch -p -git checkout 8.0.0 -git submodule update --init --recursive - # Configure CMake mkdir -p build && cd build -cmake .. -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \ - -DCMAKE_PREFIX_PATH=$INSTALL_DIR +cmake .. $SHARED_CMAKE_ARGS # Build and install cmake --build . --target install --config Release -j $NUM_JOBS