Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[drake_cmake_external] Add test case to disable solver #370

Merged
merged 9 commits into from
Feb 25, 2025
25 changes: 15 additions & 10 deletions drake_cmake_external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ include(ExternalProject)

# This shows how to fetch Eigen from source as part of Drake's CMake build.
# If you'd rather just use your operating system's Eigen, then this stanza could
# be removed (as well as removing -DWITH_USER_EIGEN:BOOLEAN=ON, below).
# be removed (as well as removing -DWITH_USER_EIGEN:BOOL=ON, below).
ExternalProject_Add(eigen
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
URL_HASH SHA256=8586084f71f9bde545ee7fa6d00288b264a2b7ac3607b974e54d13e7162c1c72
Expand All @@ -45,7 +45,7 @@ ExternalProject_Add(eigen

# This shows how to rebuild fmt from source as part of Drake's CMake build.
# If you'd rather just use your operating system's fmt, then this stanza could
# be removed (as well as removing -DWITH_USER_FMT:BOOLEAN=ON, below).
# be removed (as well as removing -DWITH_USER_FMT:BOOL=ON, below).
# If you rebuild fmt from source, then you must also rebuild spdlog from source.
ExternalProject_Add(fmt
URL https://github.com/fmtlib/fmt/archive/refs/tags/6.1.2.tar.gz
Expand All @@ -67,7 +67,7 @@ ExternalProject_Add(fmt

# This shows how to rebuild spdlog from source as part of Drake's CMake build.
# If you'd rather just use your operating system's fmt, then this stanza could
# be removed (as well as removing -DWITH_USER_SPDLOG:BOOLEAN=ON, below).
# be removed (as well as removing -DWITH_USER_SPDLOG:BOOL=ON, below).
# If you rebuild spdlog from source, then you must also rebuild fmt from source.
ExternalProject_Add(spdlog
DEPENDS fmt
Expand All @@ -83,7 +83,7 @@ ExternalProject_Add(spdlog
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}
-DSPDLOG_BUILD_SHARED=ON
-DCMAKE_CXX_FLAGS:STRING=-fPIC
-DSPDLOG_FMT_EXTERNAL:BOOLEAN=ON
-DSPDLOG_FMT_EXTERNAL:BOOL=ON
-Dfmt_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/fmt
)

Expand All @@ -95,11 +95,11 @@ set(DRAKE_PREFIX "${PROJECT_BINARY_DIR}/drake-prefix")

ExternalProject_Add(drake
DEPENDS eigen fmt spdlog
URL https://github.com/RobotLocomotion/drake/archive/master.tar.gz
# URL https://github.com/RobotLocomotion/drake/archive/master.tar.gz
# Or from a commit (download and use "shasum -a 256 'xxx.tar.gz'" on it to
# get the URL_HASH.
# URL https://github.com/RobotLocomotion/drake/archive/65c4366ea2b63278a286b1e22b8d464d50fbe365.tar.gz
# URL_HASH SHA256=899d98485522a7cd5251e50a7a6b8a64e40aff2a3af4951a3f0857fd938cafca
URL https://github.com/RobotLocomotion/drake/archive/565130305be05a4d2071761442ae93ce5aadbcb7.tar.gz
URL_HASH SHA256=787c57af97eb267d8a980595a612964cc598f7350b3bbfacaf5743ea60c360ab
TLS_VERIFY ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
Expand All @@ -109,9 +109,14 @@ ExternalProject_Add(drake
-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}
-DPYTHON_EXECUTABLE:FILEPATH=${Python3_EXECUTABLE}
-DWITH_USER_EIGEN:BOOLEAN=ON
-DWITH_USER_FMT:BOOLEAN=ON
-DWITH_USER_SPDLOG:BOOLEAN=ON
-DWITH_USER_EIGEN:BOOL=ON
-DWITH_USER_FMT:BOOL=ON
-DWITH_USER_SPDLOG:BOOL=ON
# The Drake build has options to turn features on/off.
# See https://drake.mit.edu/from_source.html for the full list.
# Here, we demonstrate how to set an arbitrary option
# for one of the open-source dependencies.
-DWITH_CSDP:BOOL=OFF
PREFIX "${DRAKE_PREFIX}"
BINARY_DIR "${PROJECT_BINARY_DIR}/drake"
BUILD_ALWAYS ON
Expand Down
10 changes: 10 additions & 0 deletions drake_cmake_external/drake_external_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,13 @@ set_tests_properties(import_all_test PROPERTIES
ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}"
)

add_test(NAME solver_disabled_test
COMMAND Python3::Interpreter -B -m unittest solver_disabled_test
)
set_tests_properties(solver_disabled_test PROPERTIES
ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}"
LABELS small
REQUIRED_FILES "${CMAKE_CURRENT_SOURCE_DIR}/solver_disabled_test.py"
TIMEOUT 60
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: MIT-0

"""
Our CMakeLists.txt file disabled the CSDP solver as part of the Drake build.
Here, we'll check that the opt-out succeeded.
"""

import unittest

from pydrake.solvers import CsdpSolver

class TestCsdpSolver(unittest.TestCase):
def test_unavailable(self):
solver = CsdpSolver()
self.assertFalse(solver.available())

if __name__ == '__main__':
unittest.main()
Loading