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

Simplify the drake_cmake_external example #338

Merged
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
2 changes: 0 additions & 2 deletions drake_cmake_external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ endif()

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")

find_package(Python3 REQUIRED COMPONENTS Interpreter Development)

include(ExternalProject)

# This shows how to fetch Eigen from source as part of Drake's CMake build.
Expand Down
33 changes: 20 additions & 13 deletions drake_cmake_external/drake_external_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,29 @@
# SPDX-License-Identifier: MIT-0

cmake_minimum_required(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.16)
project(drake_external_examples)

include(CTest)

if(APPLE)
set(FIND_PYTHON_INTERP_VERSION 3.12)
else()
set(FIND_PYTHON_INTERP_VERSION 3.6)
endif()
find_package(PythonInterp ${FIND_PYTHON_INTERP_VERSION} MODULE REQUIRED)

find_package(drake CONFIG REQUIRED)

get_filename_component(PYTHONPATH
"${drake_DIR}/../../python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages"
find_package(Python3 ${drake_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development)

get_filename_component(DRAKE_PYTHONPATH
"${drake_DIR}/../../python${drake_PYTHON_VERSION}/site-packages"
REALPATH
)

add_subdirectory(apps)
add_executable(simple_continuous_time_system simple_continuous_time_system.cc)
target_link_libraries(simple_continuous_time_system drake::drake)

include(CTest)

add_test(NAME simple_continuous_time_system
COMMAND simple_continuous_time_system
)
add_test(NAME import_all_test COMMAND
"${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/import_all_test.py"
)
set_tests_properties(import_all_test PROPERTIES
ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}"
)

14 changes: 0 additions & 14 deletions drake_cmake_external/drake_external_examples/apps/CMakeLists.txt

This file was deleted.

16 changes: 3 additions & 13 deletions drake_cmake_installed_apt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: MIT-0

cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.16)
project(drake_cmake_installed_apt)

include(CTest)
Expand All @@ -21,23 +21,13 @@ target_include_directories(gtest PUBLIC
)
target_link_libraries(gtest Threads::Threads)

if(CMAKE_VERSION VERSION_LESS 3.12)
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/cmake/3.12/Modules"
)
endif()

find_package(Python 3.6 MODULE REQUIRED)
set(PYTHON_VERSION_MAJOR_MINOR
"${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}"
)

find_package(drake CONFIG REQUIRED PATHS /opt/drake)
find_package(Python3 ${drake_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development)

get_filename_component(DRAKE_PYTHONPATH "${drake_DIR}" DIRECTORY)
get_filename_component(DRAKE_PYTHONPATH "${DRAKE_PYTHONPATH}" DIRECTORY)
set(DRAKE_PYTHONPATH
"${DRAKE_PYTHONPATH}/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages"
"${DRAKE_PYTHONPATH}/python${drake_PYTHON_VERSION}/site-packages"
)

add_subdirectory(src)
Expand Down
2 changes: 1 addition & 1 deletion drake_cmake_installed_apt/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_test(NAME cc_particle_test COMMAND particle_test)
set_tests_properties(cc_particle_test PROPERTIES LABELS small TIMEOUT 60)

add_test(NAME python_particle_test
COMMAND Python::Interpreter -B -m unittest particle_test
COMMAND Python3::Interpreter -B -m unittest particle_test
)
set_tests_properties(python_particle_test PROPERTIES
ENVIRONMENT "PYTHONPATH=${DRAKE_PYTHONPATH}"
Expand Down