From 0e2456cb0b34b5dabe0f574a87efd88f94964bb4 Mon Sep 17 00:00:00 2001 From: Silvio Traversaro Date: Sun, 11 Apr 2021 11:36:35 +0200 Subject: [PATCH 1/8] Do not overwrite default linker flags so that LDFLAGS environment variable is considered --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea0cea97a..c58139ab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ if(UNIX AND NOT APPLE) if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") get_filename_component(LINKER_BIN ${CMAKE_LINKER} NAME) if("${LINKER_BIN}" STREQUAL "ld") - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--unresolved-symbols=report-all") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--unresolved-symbols=report-all") endif() endif() endif() From 9795af4c52113dca9f8ff5981f3b0eb71a505bc8 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 11 Apr 2021 19:04:40 +0200 Subject: [PATCH 2/8] Fail if Ignition is explicitly enabled but not found --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c58139ab2..b47d29141 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,7 @@ if(NOT IGNITION_DISTRIBUTION) endif() -if(NOT IGNITION_DISTRIBUTION) +if(NOT IGNITION_DISTRIBUTION OR "${IGNITION_DISTRIBUTION}" STREQUAL "") set(USE_IGNITION FALSE) else() set(USE_IGNITION TRUE) @@ -182,8 +182,13 @@ option(SCENARIO_USE_IGNITION "Build C++ code depending on Ignition" ${USE_IGNITION}) +# Fail if Ignition is enabled but no compatible distribution was found +if(SCENARIO_USE_IGNITION AND "${IGNITION_DISTRIBUTION}" STREQUAL "") + message(FATAL_ERROR "Failed to find a compatible Ignition Gazebo distribution") +endif() + # Alias the targets -if(${SCENARIO_USE_IGNITION}) +if(SCENARIO_USE_IGNITION) include(ImportTargets${IGNITION_DISTRIBUTION}) endif() From e238c54d0c809ff8742aca0ea21248265ec0d393 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 11 Apr 2021 19:05:08 +0200 Subject: [PATCH 3/8] Enable bindings only if SWIG is found --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b47d29141..6bf84a8ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,7 +210,8 @@ if(CMAKE_BUILD_TYPE STREQUAL "PyPI" AND NOT USE_IGNITION) message(FATAL_ERROR "Found no Ignition distribution for PyPI package") endif() -option(SCENARIO_ENABLE_BINDINGS "Enable SWIG bindings" ON) +find_package(SWIG 4.0 QUIET) +option(SCENARIO_ENABLE_BINDINGS "Enable SWIG bindings" ${SWIG_FOUND}) if(SCENARIO_ENABLE_BINDINGS) add_subdirectory(bindings) From cc8aa433bca449c26f87ad8318f828b874705fd0 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 11 Apr 2021 19:07:40 +0200 Subject: [PATCH 4/8] Compile ScenarIO Gazebo only if Ignition is found --- bindings/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index ab028b186..f4329deac 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -54,7 +54,9 @@ endif() # Add the SWIG folders add_subdirectory(core) -add_subdirectory(gazebo) +if(SCENARIO_USE_IGNITION) + add_subdirectory(gazebo) +endif() # Move main init.py file to package root of the build tree configure_file( From 3b48e84840911ea999a55a3b7c2b75f1982555c2 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 11 Apr 2021 22:32:07 +0200 Subject: [PATCH 5/8] Improve handling of bindings install prefix --- bindings/CMakeLists.txt | 29 ++++++++++++++++------------- bindings/core/CMakeLists.txt | 8 ++++---- bindings/gazebo/CMakeLists.txt | 8 ++++---- cpp/scenario/core/CMakeLists.txt | 2 ++ 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index f4329deac..74b524091 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -36,20 +36,23 @@ find_package(SWIG 4.0 REQUIRED) set(UseSWIG_MODULE_VERSION 2) include(${SWIG_USE_FILE}) -# Change the install prefix of the bindings targets depending on -# the installation mode (User or Developer) +# By default, install ScenarIO in the python site-package directory +if(NOT BINDINGS_INSTALL_PREFIX) + set(BINDINGS_INSTALL_PREFIX ${Python3_SITELIB}) +endif() + +# Expose the install prefix as CMake option +set(BINDINGS_INSTALL_PREFIX "${BINDINGS_INSTALL_PREFIX}" + CACHE STRING "Installation prefix of the bindings") + +# Final directory of the "scenario" package if(NOT CMAKE_BUILD_TYPE STREQUAL "PyPI") - if(NOT BINDINGS_INSTALL_PREFIX) - # Install in the python site-package directory - set(BINDINGS_INSTALL_PREFIX ${Python3_SITELIB}/scenario) - else() - set(BINDINGS_INSTALL_PREFIX "${BINDINGS_INSTALL_PREFIX}" - CACHE STRING "Custom location where to install the bindings") - endif() + set(SCENARIO_PACKAGE_INSTALL_DIR "${BINDINGS_INSTALL_PREFIX}/scenario") else() - # Install in the root of the PyPI package directory that - # will become the archive to install / publish. - set(BINDINGS_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) + # If packaging for PyPI, install ScenarIO in the temp site-package directory + # created by either setup.py or pip. + # The "scenario/" folder is added by cmake_build_extension + set(SCENARIO_PACKAGE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}") endif() # Add the SWIG folders @@ -70,4 +73,4 @@ file(TOUCH ${CMAKE_CURRENT_BINARY_DIR}/scenario/bindings/__init__.py) # Move main init.py file to package root of the install tree install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py - DESTINATION ${BINDINGS_INSTALL_PREFIX}) + DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}) diff --git a/bindings/core/CMakeLists.txt b/bindings/core/CMakeLists.txt index dd61aa177..c83132778 100644 --- a/bindings/core/CMakeLists.txt +++ b/bindings/core/CMakeLists.txt @@ -41,10 +41,10 @@ get_property(WRAPPER_PY_FILE TARGET ${scenario_swig_name} PROPERTY SWIG_SUPPORT_ install( TARGETS ${scenario_swig_name} - LIBRARY DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings - ARCHIVE DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings - RUNTIME DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings) + LIBRARY DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings + ARCHIVE DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings + RUNTIME DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings) install( FILES ${WRAPPER_PY_FILE} - DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings) + DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings) diff --git a/bindings/gazebo/CMakeLists.txt b/bindings/gazebo/CMakeLists.txt index 21c40f66b..c314b6851 100644 --- a/bindings/gazebo/CMakeLists.txt +++ b/bindings/gazebo/CMakeLists.txt @@ -42,10 +42,10 @@ get_property(WRAPPER_PY_FILE TARGET ${scenario_swig_name} PROPERTY SWIG_SUPPORT_ install( TARGETS ${scenario_swig_name} - LIBRARY DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings - ARCHIVE DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings - RUNTIME DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings) + LIBRARY DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings + ARCHIVE DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings + RUNTIME DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings) install( FILES ${WRAPPER_PY_FILE} - DESTINATION ${BINDINGS_INSTALL_PREFIX}/bindings) + DESTINATION ${SCENARIO_PACKAGE_INSTALL_DIR}/bindings) diff --git a/cpp/scenario/core/CMakeLists.txt b/cpp/scenario/core/CMakeLists.txt index bcc3fb5eb..21e79f081 100644 --- a/cpp/scenario/core/CMakeLists.txt +++ b/cpp/scenario/core/CMakeLists.txt @@ -50,6 +50,8 @@ target_include_directories(CoreUtils PUBLIC set_target_properties(CoreUtils PROPERTIES PUBLIC_HEADER "${CORE_UTILS_HEADERS}") +# This definition is used by the "scenario" Python package +# to detect User / Developer installation mode if(NOT CMAKE_BUILD_TYPE STREQUAL "PyPI") target_compile_options(CoreUtils PRIVATE -DSCENARIO_CMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}") From f32982dfb73e6c62614e3636c9aa8fff62be5ac6 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 11 Apr 2021 22:02:42 +0200 Subject: [PATCH 6/8] Inspect installed ScenarIO package --- .github/workflows/cicd.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 0e44ae267..738e7fa3b 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -183,6 +183,11 @@ jobs: cd dist pip3 install -v *.whl + - name: Inspect installed ScenarIO package + run: | + apt-get install -y --no-install-recommends tree + tree $(python3 -c "import scenario, pathlib; print(pathlib.Path(scenario.__file__).parent)") + - name: Ccache stats run: ccache --show-stats From 316f6cc247c416610d7f7a747b37a99df041a238 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Sun, 11 Apr 2021 22:02:26 +0200 Subject: [PATCH 7/8] Pass -v to pip when building wheel in CI --- .github/workflows/cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 738e7fa3b..38ead433a 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -165,7 +165,7 @@ jobs: - name: '[User] Create wheel' if: matrix.type == 'User' && matrix.ignition == 'dome' shell: bash -i -e {0} - run: pip3 wheel -w dist/ . + run: pip3 wheel -v -w dist/ . # Note: calling "pip wheel" with "--global-option" forces dependencies to be build from their sdist. # Since it's very slow, we create the wheel from setup.py without isolation. - name: '[User] Create wheel' From a2050093d41ac4911bfcb384614c4aba8bd57325 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Mon, 12 Apr 2021 12:27:19 +0200 Subject: [PATCH 8/8] Bump ScenarIO version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bf84a8ab..71e1b63b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # GNU Lesser General Public License v2.1 or any later version. cmake_minimum_required(VERSION 3.16) -project(Scenario VERSION 1.2.0) +project(Scenario VERSION 1.2.1) # Add custom functions / macros list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)