Closed
Description
Current idea:
- All non-templated function/method bodies move to new files, such as
option_fwd.inl
. inline
gets replaced byCLI11_INLINE_DEF
- If
CLI11_COMPILE
is not defined,CLI11_INLINE_DEF
isinline
and the.inl
files get included at the end ofoption.hpp
- If
CLI11_COMPILE
is defined,CLI11_INLINE_DEF
is nothing. 0 or 1 selects whether this is the compiled file or a user. - The generation scripts need to be adjusted to handle this correctly; the .icc part will be wrapped in
#if
s.
The CMake files will automatically compile each header with an icc file, and link to that. A user not using CMake can add a file like this:
#def CLI11_COMPILE 1
#include "CLI11.hpp"
Then use CLI11 like this:
#def CLI11_COMPILE 0
#include "CLI11.hpp"
And get the benefits of compilation. If nothing is done, nothing changes and everything is header only.
// option.hpp
#include "option_fwd.hpp"
#ifndef CLI11_COMPILE || CLI11_COMPILE==1
#include "option.inl"
#endif
// option_fwd.hpp
// Minimal required includes
// [cli11:preinc:includes]
#include <fwd>
// [cli11:preinc:end]
// All files need this (has inline, etc)
#include "macros.hpp"
// Includes for other files in CLI11 (fwd only)
#include "app_fwd.hpp"
namespace CLI {
// [cli11:app_fwd:code]
class Option {
// Definitions and templated functions only
};
CLI11_INLINE void f();
// [cli11:app_fwd:end]
} // namespace CLI
// option.inl
// Currently not planning to include fwd here, since it is an inline file (depending on IDEs, possibly)
// Compile only includes
// [cli11:inc:includes]
#include <algorithm>
// [cli11:inc:end]
namespace CLI {
// [cli11:option_inl:code]
Option::Option() {} // Definitions
CLI11_INLINE void f() {}
// [cli11:option_inl:end]
} // namespace CLI
// option.cpp
#define CLI11_COMPILE 1 // Might as well force it here)
#include <option.hpp>
Metadata
Metadata
Assignees
Labels
No labels