Skip to content

Commit

Permalink
Default to shared libraries also on Windows, fix installation of shar…
Browse files Browse the repository at this point in the history
…ed libraries on Windows and bump minimum required version of CMake to 3.16 (#418)

* Default to shared libraries also on Windows

* Update CMakeLists.txt

* Add test of standalone build of bindings

* Also default bindings standalone built to shared libraries

* Fix missing ARCHIVE DESTINATION by also removing RUNTIME and LIBRARY

* Bump minimum required version of CMake to 3.16

* Bump version to 4.0.3
  • Loading branch information
traversaro authored Sep 30, 2024
1 parent 82b84f4 commit 4901096
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,25 @@ jobs:
# Test python packages
python -c "import wearables"
python -c "import hde"
- name: Test standalone build of bindings
shell: bash -l {0}
run: |
cd bindings
mkdir -p build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DBUILD_TESTING:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON \
-DHDE_DETECT_ACTIVE_PYTHON_SITEPACKAGES:BOOL=ON ..
cmake --build . --config ${{ matrix.build_type }}
ctest --output-on-failure -C ${{ matrix.build_type }} .
cmake --install . --config ${{ matrix.build_type }}
- name: Check install of standalone build of bindings
shell: bash -l {0}
run: |
# Test python packages
python -c "import wearables"
python -c "import hde"
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SPDX-FileCopyrightText: Fondazione Istituto Italiano di Tecnologia (IIT)
# SPDX-License-Identifier: BSD-3-Clause

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.16)
project(HumanDynamicsEstimation
LANGUAGES CXX
VERSION 4.0.2)
VERSION 4.0.3)

# =====================
# PROJECT CONFIGURATION
Expand Down Expand Up @@ -43,11 +43,7 @@ include(AddWarningsConfigurationToTarget)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# Shared/Dynamic or Static library?
if(MSVC)
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" OFF)
else()
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
endif()
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down
4 changes: 3 additions & 1 deletion bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ if(HDE_BINDINGS_BUILD_STANDALONE)
find_package(WearableData REQUIRED)
find_package(HumanDynamicsEstimation REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
option(BUILD_SHARED_LIBS "Build libraries as shared as opposed to static" ON)
endif()

if(HDE_COMPILE_PYTHON_BINDINGS)
Expand Down Expand Up @@ -53,7 +55,7 @@ if(HDE_COMPILE_PYTHON_BINDINGS)
file(APPEND ${GENERATION_LOCATION_OF_INIT_PY_FILE}/__init__.py "# for example if the library to find are already found in the proper location in a conda\n")
file(APPEND ${GENERATION_LOCATION_OF_INIT_PY_FILE}/__init__.py "if(library_dll_path != os.path.join(os.environ.get('CONDA_PREFIX', ''),'Library','bin') and library_dll_path != os.path.join(os.environ.get('CONDA_PREFIX', ''),'bin')):\n")
file(APPEND ${GENERATION_LOCATION_OF_INIT_PY_FILE}/__init__.py " if(os.path.exists(library_dll_path)):\n")
file(APPEND ${GENERATION_LOCATION_OF_INIT_PY_FILE}/__init__.py " os.add_dll_directory(library_dll_path)$\n")
file(APPEND ${GENERATION_LOCATION_OF_INIT_PY_FILE}/__init__.py " os.add_dll_directory(library_dll_path)\n")
file(APPEND ${GENERATION_LOCATION_OF_INIT_PY_FILE}/__init__.py "\n")
endif()

Expand Down
2 changes: 1 addition & 1 deletion devices/Paexo/test-application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause


cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.16)
project(PaexoTestApplication)

find_package(IWear REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion interfaces/IWear/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-3-Clause


cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.16)
project(IWear LANGUAGES CXX VERSION ${PROJECT_VERSION})

include(GNUInstallDirs)
Expand Down
8 changes: 0 additions & 8 deletions msgs/yarp/thrift/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ add_library(${PROJECT_NAME}::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME}

install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hde/msgs")


Expand Down Expand Up @@ -63,8 +61,6 @@ add_library(${PROJECT_NAME}::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME}

install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hde/msgs")


Expand Down Expand Up @@ -97,8 +93,6 @@ add_library(${PROJECT_NAME}::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME}

install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hde/msgs")

set(LIBRARY_TARGET_NAME HumanWrenchMsg)
Expand Down Expand Up @@ -129,6 +123,4 @@ add_library(${PROJECT_NAME}::${LIBRARY_TARGET_NAME} ALIAS ${LIBRARY_TARGET_NAME}

install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hde/msgs")

0 comments on commit 4901096

Please sign in to comment.