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

Do not remove catkin file, breaks robostack environment #622

Merged
merged 3 commits into from
Dec 6, 2023
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: 1 addition & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: [ubuntu-22.04]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Run project tests
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
hpp/idl/*.pyc
.docs/build
_unittests/build/
_unittests/install/
25 changes: 25 additions & 0 deletions _unittests/catkin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.10)

set(PROJECT_NAME jrl-cmakemodules-catkin)
set(PROJECT_VERSION 0.0.0)
set(PROJECT_DESCRIPTION "JRL CMake module - catkin")
set(PROJECT_URL http://jrl-cmakemodules.readthedocs.io)

include(../../base.cmake)

project(${PROJECT_NAME} LANGUAGES CXX)

# This project test the correct behavior of #622
#
# * If .catkin is already here when the project is configured it is not removed
# * Otherwise it is assumed it is created by the project and removed with the
# uninstall target

option(FORCE_DOT_CATKIN_CREATION
"Force creation of .catkin file in install destination" OFF)

if(FORCE_DOT_CATKIN_CREATION)
install(
CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_INSTALL_PREFIX}/.catkin)"
)
endif()
2 changes: 1 addition & 1 deletion _unittests/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.10)

set(PROJECT_NAME jrl-cmakemodules-cpp)
set(PROJECT_VERSION 0.0.0)
Expand Down
2 changes: 1 addition & 1 deletion _unittests/dependency/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.10)

set(PROJECT_NAME jrl-cmakemodules-dependency)
set(PROJECT_VERSION 0.0.0)
Expand Down
2 changes: 1 addition & 1 deletion _unittests/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.10)

# These variables have to be defined before running SETUP_PROJECT
set(PROJECT_NAME jrl-cmakemodules-python)
Expand Down
32 changes: 31 additions & 1 deletion _unittests/run_unit_tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/bash

unittests="python cpp dependency"
set -e
set -x

unittests="python cpp dependency catkin"

# Code for running a specific unit test
# For unit test foo, function `run_foo` is executed if defined.
Expand All @@ -23,6 +26,33 @@ function run_cpp()
run_default $here/cpp
}

function run_catkin()
{
$CMAKE_BIN ${cmake_options} -DFORCE_DOT_CATKIN_CREATION=ON "${here}/catkin"
make install
if [[ ! -f ${here}/install/.catkin ]]; then
echo ".catkin file should have been created"
exit 1
fi
make uninstall
if [[ -f ${here}/install/.catkin ]]; then
echo ".catkin file should have been removed"
exit 1
fi
cd ${here}/build/
rm -rf ${here}/build/catkin/
mkdir -p ${here}/build/catkin/
cd catkin
touch ${here}/install/.catkin
$CMAKE_BIN ${cmake_options} -DFORCE_DOT_CATKIN_CREATION=OFF "${here}/catkin"
make install
make uninstall
if [[ ! -f ${here}/install/.catkin ]]; then
echo ".catkin file should NOT have been removed"
exit 1
fi
}

# The code below run all the unit tests
here="`pwd`"
rm -rf build install
Expand Down
4 changes: 2 additions & 2 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

MESSAGE(STATUS "catkin path: @CMAKE_INSTALL_PREFIX@/.catkin")
IF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin")
IF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin" AND PACKAGE_CREATES_DOT_CATKIN)
MESSAGE(STATUS "Try to remove @CMAKE_INSTALL_PREFIX@/.catkin")
EXECUTE_PROCESS(
COMMAND @CMAKE_COMMAND@ -E remove "@CMAKE_INSTALL_PREFIX@/.catkin"
RESULT_VARIABLE rm_resval
OUTPUT_VARIABLE rm_out
ERROR_VARIABLE rm_err
)
ENDIF(EXISTS "@CMAKE_INSTALL_PREFIX@/.catkin")
ENDIF()

IF(EXISTS "@CMAKE_CURRRENT_BINARY_DIR@/install_manifest.txt")
return()
Expand Down
23 changes: 21 additions & 2 deletions uninstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,34 @@
# Add custom rule to uninstall the package.
#
macro(_SETUP_PROJECT_UNINSTALL)
# Detect if the .catkin was created previously
if(NOT DEFINED PACKAGE_CREATES_DOT_CATKIN
OR NOT "${PACKAGE_PREVIOUS_INSTALL_PREFIX}" STREQUAL
"${CMAKE_INSTALL_PREFIX}")
set(PACKAGE_PREVIOUS_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}"
CACHE INTERNAL "Cache install prefix given to the package")
if(EXISTS "${CMAKE_INSTALL_PREFIX}/.catkin")
set(PACKAGE_CREATES_DOT_CATKIN
FALSE
CACHE INTERNAL "")
else()
set(PACKAGE_CREATES_DOT_CATKIN
TRUE
CACHE INTERNAL "")
endif()
endif()
# FIXME: it is utterly stupid to rely on the install manifest. Can't we just
# remember what we install ?!
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" IMMEDIATE @ONLY)

add_custom_target(
uninstall "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")
uninstall
"${CMAKE_COMMAND}"
-DPACKAGE_CREATES_DOT_CATKIN=${PACKAGE_CREATES_DOT_CATKIN} -P
"${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake")

configure_file("${CMAKE_CURRENT_LIST_DIR}/cmake_reinstall.cmake.in"
"${PROJECT_BINARY_DIR}/cmake/cmake_reinstall.cmake.configured")
Expand Down