Skip to content

Conversation

@BlockoS
Copy link

@BlockoS BlockoS commented Sep 28, 2025

Hello,

This PR updates the CMake scripts with the following:

  • Add a new configuration option (BUILD_EXAMPLES) to enable or disable the build of examples (enabled by default).
  • Add install target that will install the library, header files and CMake configuration scripts.
  • Update the Fusion target in order to propagate the library include directories when used both with add_subdirectory and as an external package.

For example, the following commands will build the library without the examples and install it.

cmake -Bbuild -S. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${HOME}/packages -DBUILD_EXAMPLES=OFF
cmake --build ./build --target install 

After this ${HOME}/packages will contain:

${HOME}/packages
├── include
│   └── Fusion
│       ├── Fusion.h
│       ├── FusionAhrs.h
│       ├── FusionAxes.h
│       ├── FusionCalibration.h
│       ├── FusionCompass.h
│       ├── FusionConvention.h
│       ├── FusionMath.h
│       └── FusionOffset.h
└── lib
    ├── cmake
    │   └── Fusion
    │       ├── FusionConfig.cmake
    │       ├── FusionConfigVersion.cmake
    │       ├── FusionTargets-release.cmake
    │       └── FusionTargets.cmake
    └── libFusion.a

This way projects can use the Fusion library by passing -DFusion_DIR=${HOME}/packages/lib/cmake/Fusion during project configuration, using find_package(Fusion) in the CMake script and link with Fusion::lib.

find_package(Fusion 1.2.8 REQUIRED)

add_executable(foo foo.c)
target_link_libraries(foo Fusion::lib) 

@xioTechnologies
Copy link
Owner

Thank you for PR. It appears that you are suggesting the same change as this which has already been replied to.

@BlockoS
Copy link
Author

BlockoS commented Sep 29, 2025

Ok. The thing is that we are using the repository as a git submodule and our build system is already using CMake.
We are already doing what in this PR outside of the Fusion project scope but it felt more appropriate to do it in a less "hackish" way.

@xioTechnologies
Copy link
Owner

If your goal is to tie your local submodule to this remote then you can do so and just not reference this repo's CMake. Your parent CMake would reference the C files as required. For example, the x-IMU3-Device repo uses the JSON repo as a submodule without any reference to the submodule CMake.

Personally, it doesn't feel right to include this particular repo as a submodule because the repo is not just the C library. It is also the Python package wrapper/distribution and examples. The submodule would be bringing allot of baggage when only a flat directory of 11 files is required.

Even so, I agree that the current arrangement is not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants