Skip to content

Commit

Permalink
Provide library version in API (#586)
Browse files Browse the repository at this point in the history
This fixes #582.
  • Loading branch information
kyllingstad authored May 27, 2020
1 parent 470f0d5 commit 9542942
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
13 changes: 13 additions & 0 deletions include/cosim/lib_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,18 @@ namespace cosim
constexpr const char* library_short_name = "libcosim";


/// Software version
struct version
{
int major = 0;
int minor = 0;
int patch = 0;
};


/// Returns the version of the libcosim library.
version library_version();


} // namespace cosim
#endif // header guard
17 changes: 16 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ set(sources
"cosim/utility/uuid.cpp"
"cosim/utility/zip.cpp"
)
set(generatedSources
"cosim/lib_info.cpp"
)

if(LIBCOSIM_WITH_FMUPROXY)
list(APPEND publicHeaders
Expand Down Expand Up @@ -126,7 +129,19 @@ set(publicHeadersFull)
foreach(h IN LISTS publicHeaders)
list(APPEND publicHeadersFull "${publicHeaderDir}/${h}")
endforeach()
set(allSources ${publicHeadersFull} ${privateHeaders} ${generatedHeaders} ${sources})

set(generatedSourcesFull)
foreach(src IN LISTS generatedSources)
set(tgt "${CMAKE_CURRENT_BINARY_DIR}/${src}")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/${src}.in"
"${tgt}"
@ONLY
)
list(APPEND generatedSourcesFull "${tgt}")
endforeach()

set(allSources ${publicHeadersFull} ${privateHeaders} ${generatedHeaders} ${sources} ${generatedSourcesFull})

add_custom_command(
OUTPUT osp_system_structure_schema.hpp
Expand Down
16 changes: 16 additions & 0 deletions src/cosim/lib_info.cpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include "cosim/lib_info.hpp"


namespace cosim
{


version library_version()
{
// clang-format off
return { @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@ };
// clang-format on
}


} // namespace cosim

0 comments on commit 9542942

Please sign in to comment.