clad icon indicating copy to clipboard operation
clad copied to clipboard

Create a directory for internal headers

Open parth-07 opened this issue 4 years ago • 1 comments

Currently, users of clad do not need to have access to all the header files defined in include/clad/Differentiator. We should create a separate directory for internal headers, this directory should contain all the headers that are not required by the users.

parth-07 avatar Oct 17 '21 20:10 parth-07

Hello @parth-07 @vgvassilev

To solve this issue, we can create a new directory named "internal" under "include/clad/Differentiator" and move all the internal headers to this new directory. This will make it clear which headers are intended for internal use only and which headers are part of the public interface.

Here are the steps to implement this solution:

  1. Create a new directory named internal under include/clad/Differentiator :
mkdir include/clad/Differentiator/internal
  1. Move all the internal headers to this new directory:
mv include/clad/Differentiator/*_impl.h include/clad/Differentiator/internal/
  1. Update the CMakeLists.txt file to exclude the internal headers from the installation targets:
file(GLOB_RECURSE public_headers "${PROJECT_SOURCE_DIR}/include/*.h")
file(GLOB_RECURSE internal_headers "${PROJECT_SOURCE_DIR}/include/clad/Differentiator/internal/*.h")

# Install public headers
install(FILES ${public_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Do not install internal headers
set(CMAKE_INSTALL_INCLUDEDIR_INTERNAL "${CMAKE_INSTALL_INCLUDEDIR}/clad/Differentiator/internal")
install(FILES ${internal_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR_INTERNAL} OPTIONAL)
  1. Update the include statements in the public headers to reflect the new directory structure:
#include "clad/Differentiator/internal/SomeInternalHeader.h"

May be with these changes, the internal headers will be separated from the public headers, and users of clad will not need to have access to all the header files defined in include/clad/Differentiator.

ro4i7 avatar Mar 11 '23 15:03 ro4i7