Skip to content

Commit

Permalink
Merge pull request #75 from 2xB/2xB/fixkconst
Browse files Browse the repository at this point in the history
Kommon: Bake KConst epoch into header file
  • Loading branch information
richeldichel authored Oct 16, 2023
2 parents e01d5ec + 8caf20a commit 4f467b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions Kommon/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ set(KOMMON_BASE_HEADER_FILES
Utility/KAlgorithm.h
Utility/KException.h
Utility/KCast.h
Utility/KConst.h
Utility/KConst_2006.h
Utility/KConst_2021.h
Utility/KConsoleMuter.h
Utility/KHash.h
Utility/OstreamJoiner.h
Expand Down Expand Up @@ -193,8 +193,10 @@ elseif(KConst_REFERENCE_EPOCH LESS 2021)
"of some calculations. To restore *default* behavior, set KConst_REFERENCE_EPOCH=2021.")
endif()

# Needed for physical constants defined in Utility/KConst.h
target_compile_definitions(KommonBase PUBLIC KConst_REFERENCE_EPOCH=${KConst_REFERENCE_EPOCH})
# Bake KConst_REFERENCE_EPOCH into KConst.h
configure_file( Utility/KConst.h.in ${CMAKE_CURRENT_BINARY_DIR}/Utility/KConst.h @ONLY )
list( APPEND KOMMON_BASE_HEADER_FILES ${CMAKE_CURRENT_BINARY_DIR}/Utility/KConst.h )
target_include_directories( KommonBase PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/Utility> )

kasper_install_libraries( KommonBase )
kasper_install_headers( ${KOMMON_BASE_HEADER_FILES} )
Expand Down
10 changes: 10 additions & 0 deletions Kommon/Base/Utility/KConst.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#if @KConst_REFERENCE_EPOCH@ == 2006
#include "KConst_2006.h"

#elif @KConst_REFERENCE_EPOCH@ == 2021
#include "KConst_2021.h"

#else
#error "Unsupported value for KConst_REFERENCE_EPOCH: '@KConst_REFERENCE_EPOCH@'"

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
* @author S. Hickford <[email protected]>
*/

#if KConst_REFERENCE_EPOCH == 2006
#include "KConst_2006.h"

#elif KConst_REFERENCE_EPOCH == 2021

#ifndef KCONST_H_
#define KCONST_H_

Expand Down Expand Up @@ -457,7 +452,3 @@ constexpr double Ue3sq()
} /* namespace katrin */

#endif //KCONST_H

#else
#error "Unsupported value for KConst_REFERENCE_EPOCH."
#endif

0 comments on commit 4f467b0

Please sign in to comment.