Skip to content

Commit d3ff5e8

Browse files
authored
Print Chimera version instead of LLVM version (#234)
This is to resolve #157. This PR prints Chimera version instead of LLVM version that is used for building Chimera. Now `chimera --version` prints `Chimera 0.1.0` where the version numbers are defined in `CMakeLists.txt`. Depends on #233
1 parent 091f373 commit d3ff5e8

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ set(SHARE_INSTALL_DIR "share/${PROJECT_NAME}")
99
## SETUP ##
1010
###########
1111

12+
# Chimera version
13+
set(CHIMERA_MAJOR_VERSION "0")
14+
set(CHIMERA_MINOR_VERSION "1")
15+
set(CHIMERA_PATCH_VERSION "0")
16+
set(CHIMERA_VERSION
17+
${CHIMERA_MAJOR_VERSION}.${CHIMERA_MINOR_VERSION}.${CHIMERA_PATCH_VERSION}
18+
)
19+
1220
# Preset for code formatting
1321
include(ClangFormat)
1422
clang_format_setup()
@@ -118,6 +126,13 @@ target_link_libraries(libchimera
118126
)
119127
target_link_libraries(libchimera PRIVATE mstch cling_utils)
120128
target_link_libraries(libchimera PRIVATE chimera_bindings)
129+
target_compile_definitions(libchimera
130+
PUBLIC
131+
CHIMERA_MAJOR_VERSION=${CHIMERA_MAJOR_VERSION}
132+
CHIMERA_MINOR_VERSION=${CHIMERA_MINOR_VERSION}
133+
CHIMERA_PATCH_VERSION=${CHIMERA_PATCH_VERSION}
134+
CHIMERA_VERSION=${CHIMERA_VERSION}
135+
)
121136
clang_format_add_sources(${${PROJECT_NAME}_HEADERS} ${${PROJECT_NAME}_SOURCES})
122137

123138
# Build the main chimera executable.

src/chimera.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "chimera/configuration.h"
66
#include "chimera/frontend_action.h"
77

8+
#include <iostream>
89
#include <memory>
910
#include <string>
1011
#include <clang/Tooling/ArgumentsAdjusters.h>
@@ -78,6 +79,18 @@ static cl::extrahelp MoreHelp(
7879

7980
int run(int argc, const char **argv)
8081
{
82+
// Print custom output for `--version` option
83+
for (int i = 1; i < argc; ++i)
84+
{
85+
if (std::strcmp(argv[i], "--version") == 0)
86+
{
87+
std::cout << "Chimera " << CHIMERA_MAJOR_VERSION << "."
88+
<< CHIMERA_MINOR_VERSION << "." << CHIMERA_PATCH_VERSION
89+
<< "\n\n";
90+
exit(0);
91+
}
92+
}
93+
8194
// Create parser that handles clang options.
8295
CommonOptionsParser OptionsParser(argc, argv, ChimeraCategory);
8396

0 commit comments

Comments
 (0)