Skip to content

Conversation

@ahoarau
Copy link

@ahoarau ahoarau commented Dec 10, 2025

In this PR we introduce the JRL CMake Modules v2, extracted from the repo: https://github.com/ahoarau/jrl-cmakemodules-v2

The integration on the user-side can be done as follows:

set(JRL_CMAKEMODULES_USE_V2 ON CACHE BOOL "Use jrl-cmakemodules v2")
if(JRL_CMAKEMODULES_SOURCE_DIR)
  message(STATUS "Using jrl-cmakemodules from source directory: ${JRL_CMAKEMODULES_SOURCE_DIR}")
  add_subdirectory(${JRL_CMAKEMODULES_SOURCE_DIR} jrl-cmakemodules)
else()
  find_package(jrl-cmakemodules 0.2.0 CONFIG REQUIRED)
endif()

We can still use the repo jrl-cmakemodules as usual, i.e. with pixi or manually installing it.
Either set an env variable JRL_CMAKEMODULES_SOURCE_DIR pointing to the jrl repo source location or use the installed version (find_package(...)).
Then define JRL_CMAKEMODULES_USE_V2 ON to bypass the v1 and use exclusively the v2.
We do not intend to use both v1 and v2 in projects.

TODO:

  • Port the main modules
  • Test the integration in client repo (proxsuite, eigenpy, nanoeigenpy, coal)
  • Figure out why gersemi still needs to re-format the new modules
  • Add COMPATIBLITY_OPTION for jrl_cmake_dependent_option()
  • Port tests from original repo
  • Port CI from original repo
  • Rewrite release.cmake in python (help wanted)

endif()
endfunction()

function(jrl_python_generate_init_py name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some documentation

Comment on lines +1700 to +1739
if(NOT Python_EXECUTABLE)
message(
FATAL_ERROR
"Python_EXECUTABLE not defined.
Please use jrl_find_package(Python REQUIRED COMPONENT Interpreter)"
)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use jrl_check_var_defined ?

Also, in BoostPython.cmake you use $<TARGET_FILE:Python::Interpreter>. Which one is the best ?

Comment on lines 1738 to 1777
if(NOT Python_EXECUTABLE)
message(
FATAL_ERROR
"Python_EXECUTABLE not defined.
Please use jrl_find_package(Python REQUIRED COMPONENT Interpreter)"
)
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use jrl_check_var_defined ?

Also, in BoostPython.cmake you use $<TARGET_FILE:Python::Interpreter>. Which one is the best ?

@nim65s nim65s self-requested a review December 15, 2025 10:24
Comment on lines +248 to +250
function(jrl_configure_default_install_dirs)
include(GNUInstallDirs)
endfunction()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function(jrl_configure_default_install_dirs)
include(GNUInstallDirs)
endfunction()
macro(jrl_configure_default_install_dirs)
include(GNUInstallDirs)
endmacro()

Some variables like ${CMAKE_INSTALL_FULL_BINDIR} are not defined if the include is inside a function.

configure_file(
"${templates_dir}/cmake-uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake-uninstall.cmake"
IMMEDIATE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find the documentation for this keyword.

endfunction()

# Helper function: pad or truncate a string to a fixed width
function(_pad_string input width output_var)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename it into _jrl_pad_string

add_custom_command(
OUTPUT ${arg_OUTPUT}
COMMAND
${CMAKE_COMMAND} -E env ${pythonpath} $<TARGET_FILE:Python::Interpreter> ${stubgen_py}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check like this one :  jrl_check_target_exists(Python::Interpreter "Python::Interpreter target not found. Please call jrl_find_python() first.")

Comment on lines +1880 to +1881
# * Otherwise, if running inside a Conda environment on Windows, an
# absolute path to `sysconfig.get_path('purelib')` is returned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we already talked, I'm not a huge fan of handling this special case. The ${PROJECT_NAME}_PYTHON_INSTALL_DIR variable is made for this purpose.

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