Skip to content

Commit 10b97d3

Browse files
Add C++ compiler to assert printed info.
The C++ linker is also printed if the CMake version is 3.29+.
1 parent 60683d4 commit 10b97d3

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed

include/mmSolver/buildConstant.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ const char* const project_git_branch();
4747
const char* const project_git_commit_hash_long();
4848
const char* const project_git_commit_hash_short();
4949

50-
// TODO: Add compiler details.
50+
const char* const cxx_compiler();
51+
const char* const cxx_linker();
5152

5253
const char* const maya_version();
5354
const char* const module_os_name();

lib/mmsolverlibs/include/mmsolverlibs/assert.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@
8282
::mmsolverlibs::build_info::project_git_commit_hash_short()
8383
#endif
8484

85+
// Project's C++ compiler details string.
86+
#ifndef MMASSERT_CXX_COMPILER
87+
#define MMASSERT_CXX_COMPILER ::mmsolverlibs::build_info::cxx_compiler()
88+
#endif
89+
90+
// Project's C++ compiler linker details string.
91+
#ifndef MMASSERT_CXX_LINKER
92+
#define MMASSERT_CXX_LINKER ::mmsolverlibs::build_info::cxx_linker()
93+
#endif
94+
8595
namespace mmsolverlibs {
8696
namespace assert {
8797

@@ -116,12 +126,17 @@ inline void ostream_add_build_info_end(std::ostream& ostream) {
116126
const auto project_git_branch = MMASSERT_PROJECT_GIT_BRANCH;
117127
const auto project_git_commit_hash_long =
118128
MMASSERT_PROJECT_GIT_COMMIT_HASH_LONG;
129+
const auto cxx_compiler = MMASSERT_CXX_COMPILER;
130+
const auto cxx_linker = MMASSERT_CXX_LINKER;
119131

120132
ostream << "- Project: " << project_name << "\n"
121133
<< "- Project Version: " << project_version << "\n"
122134
<< "- Build Date-Time: " << project_build_date_time << "\n"
123135
<< "- Git Branch: " << project_git_branch << "\n"
124-
<< "- Git Commit: " << project_git_commit_hash_long << std::endl;
136+
<< "- Git Commit: " << project_git_commit_hash_long << "\n"
137+
<< "- C++ Compiler: " << cxx_compiler << "\n"
138+
<< "- C++ Linker: " << cxx_linker
139+
<< std::endl;
125140
}
126141

127142
} // namespace
@@ -242,4 +257,15 @@ inline void print_todo(std::ostream& ostream, const char* file, const int line,
242257
std::abort(); \
243258
} while (0)
244259

260+
// Clean up the defines made in this file.
261+
#undef MMASSERT_PROJECT_NAME
262+
#undef MMASSERT_PROJECT_VERSION
263+
#undef MMASSERT_PROJECT_SOURCE_DIR
264+
#undef MMASSERT_PROJECT_BUILD_DATE_TIME
265+
#undef MMASSERT_PROJECT_GIT_BRANCH
266+
#undef MMASSERT_PROJECT_GIT_COMMIT_HASH_LONG
267+
#undef MMASSERT_PROJECT_GIT_COMMIT_HASH_SHORT
268+
#undef MMASSERT_CXX_COMPILER
269+
#undef MMASSERT_CXX_LINKER
270+
245271
#endif // MM_SOLVER_LIBS_ASSERT_H

lib/mmsolverlibs/include/mmsolverlibs/buildConstant.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ const char* const project_git_branch();
4646
const char* const project_git_commit_hash_long();
4747
const char* const project_git_commit_hash_short();
4848

49-
// TODO: Add compiler details.
49+
const char* const cxx_compiler();
50+
const char* const cxx_linker();
5051

5152
} // namespace build_info
5253
} // namespace mmsolverlibs

lib/mmsolverlibs/src/buildConstant.cpp.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,17 @@ const char* const project_git_commit_hash_short() {
5252
return "@PROJECT_GIT_COMMIT_HASH_SHORT@";
5353
};
5454

55+
const char* const cxx_compiler() {
56+
return "id=@CMAKE_CXX_COMPILER_ID@ "
57+
"version=@CMAKE_CXX_COMPILER_VERSION@ "
58+
"standard=@CMAKE_CXX_STANDARD@ "
59+
"executable='@CMAKE_CXX_COMPILER@'";
60+
};
61+
const char* const cxx_linker() {
62+
return "id=@CMAKE_CXX_COMPILER_LINKER_ID@ "
63+
"version=@CMAKE_CXX_COMPILER_LINKER_VERSION@ "
64+
"executable='@CMAKE_CXX_COMPILER_LINKER@'";
65+
};
66+
5567
} // namespace build_info
5668
} // namespace mmsolverlibs

src/mmSolver/buildConstant.cpp.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ const char* const project_git_commit_hash_short() {
5252
return "@PROJECT_GIT_COMMIT_HASH_SHORT@";
5353
};
5454

55+
const char* const cxx_compiler() {
56+
return "id=@CMAKE_CXX_COMPILER_ID@ "
57+
"version=@CMAKE_CXX_COMPILER_VERSION@ "
58+
"standard=@CMAKE_CXX_STANDARD@ "
59+
"executable='@CMAKE_CXX_COMPILER@'";
60+
};
61+
const char* const cxx_linker() {
62+
return "id=@CMAKE_CXX_COMPILER_LINKER_ID@ "
63+
"version=@CMAKE_CXX_COMPILER_LINKER_VERSION@ "
64+
"executable='@CMAKE_CXX_COMPILER_LINKER@'";
65+
};
66+
5567
const char* const maya_version() { return "@MAYA_VERSION@"; };
5668
const char* const module_os_name() { return "@MODULE_OS_NAME@"; };
5769
const char* const module_full_name() { return "@MODULE_FULL_NAME@"; };

src/mmSolver/utilities/assert_utils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#undef MMASSERT_PROJECT_GIT_BRANCH
3939
#undef MMASSERT_PROJECT_GIT_COMMIT_HASH_LONG
4040
#undef MMASSERT_PROJECT_GIT_COMMIT_HASH_SHORT
41+
#undef MMASSERT_CXX_COMPILER
42+
#undef MMASSERT_CXX_LINKER
4143
#define MMASSERT_PROJECT_NAME ::mmsolver::build_info::project_name()
4244
#define MMASSERT_PROJECT_VERSION ::mmsolver::build_info::project_version()
4345
#define MMASSERT_PROJECT_SOURCE_DIR ::mmsolver::build_info::project_source_dir()
@@ -48,6 +50,10 @@
4850
::mmsolver::build_info::project_git_commit_hash_long()
4951
#define MMASSERT_PROJECT_GIT_COMMIT_HASH_SHORT \
5052
::mmsolver::build_info::project_git_commit_hash_short()
53+
#define MMASSERT_CXX_COMPILER \
54+
::mmsolver::build_info::cxx_compiler()
55+
#define MMASSERT_CXX_LINKER \
56+
::mmsolver::build_info::cxx_linker()
5157

5258
// MM Solver Libs
5359
#include <mmsolverlibs/assert.h>
@@ -84,5 +90,7 @@
8490
#undef MMASSERT_PROJECT_GIT_BRANCH
8591
#undef MMASSERT_PROJECT_GIT_COMMIT_HASH_LONG
8692
#undef MMASSERT_PROJECT_GIT_COMMIT_HASH_SHORT
93+
#undef MMASSERT_CXX_COMPILER
94+
#undef MMASSERT_CXX_LINKER
8795

8896
#endif // MM_SOLVER_ASSERT_UTILS_H

0 commit comments

Comments
 (0)