Skip to content

Commit

Permalink
I don't think exporting worked right on windows for a bit (or the DLL…
Browse files Browse the repository at this point in the history
… naming got weird with my latest changes)
  • Loading branch information
Cliff Foster committed Mar 1, 2024
1 parent 9ab7ee0 commit ffa85e1
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 58 deletions.
17 changes: 9 additions & 8 deletions cmake/idi/functions/framework/idi_src.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ macro(idi_src)
# backwards compat, since CORE is always the main target
set(IDICMAKE_MAIN_TARGET ${IDICMAKE_CORE})

if(IDICMAKE_IS_LIBRARY AND IDICMAKE_IS_SHARED)
set(IDICMAKE_SHARED_NAME ${IDICMAKE_CORE})
add_library("${IDICMAKE_CORE}" SHARED "")
message(STATUS "------ Added SHARED Library ${IDICMAKE_CORE}")
else()
add_library("${IDICMAKE_CORE}" STATIC "")
message(STATUS "------ Added STATIC Library ${IDICMAKE_CORE}")
endif()

add_library("${IDICMAKE_CORE}" STATIC "")
message(STATUS "------ Added STATIC Library ${IDICMAKE_CORE}")


set(IDICMAKE_CORE ${IDICMAKE_CORE} PARENT_SCOPE)
idi_target_compile_settings("${IDICMAKE_CORE}")
Expand Down Expand Up @@ -62,11 +58,16 @@ macro(idi_src)
else()
if(IDICMAKE_IS_SHARED)
add_library("${IDICMAKE_PROJECT_NAME}" SHARED "")
target_link_libraries("${IDICMAKE_PROJECT_NAME}" PUBLIC "${IDICMAKE_CORE}")
set(IDICMAKE_SHARED_NAME ${IDICMAKE_PROJECT_NAME})

set_target_properties("${IDICMAKE_SHARED_NAME}" PROPERTIES CXX_VISIBILITY_PRESET hidden)
set_target_properties("${IDICMAKE_SHARED_NAME}" PROPERTIES C_VISIBILITY_PRESET hidden)

if (MSVC)
set_target_properties(${IDICMAKE_PROJECT_NAME} PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${IDICMAKE_CORE}")
endif()

target_sources(
"${IDICMAKE_SHARED_NAME}"
PRIVATE
Expand Down
4 changes: 2 additions & 2 deletions platform-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ set(IDICMAKE_VENDOR_NAMESPACE "idi")
set(IDICMAKE_APP_NAMESPACE "app")

# If IDICMAKE_IS_LIBRARY is set to true the project will be built as a library.
set(IDICMAKE_IS_LIBRARY false)
set(IDICMAKE_IS_LIBRARY true)

# If IDICMAKE_IS_SHARED is set to true then the project will build as a shared library.
# If it is set to false it will build as a static library. This requires
# IDICMAKE_IS_LIBRARY being set to true
set(IDICMAKE_IS_SHARED false)
set(IDICMAKE_IS_SHARED true)
32 changes: 8 additions & 24 deletions src/base/include/template_project/__version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,50 @@ namespace @__idi_namespace@::base {
*
* @return int32_t
*/
inline consteval uint32_t get_version_major() {
return @__idi_c_caps_namespace@_VERSION_MAJOR;
}
uint32_t get_version_major();

/**
* Get the minor version number of the current version of the project.
*
* @return int32_t
*/
inline consteval uint32_t get_version_minor() {
return @__idi_c_caps_namespace@_VERSION_MINOR;
}
uint32_t get_version_minor();

/**
* Get the patch version number of the current version of the project.
*
* @return int32_t
*/
inline consteval uint32_t get_version_patch() {
return @__idi_c_caps_namespace@_VERSION_PATCH;
}
uint32_t get_version_patch();

/**
* Get the short version of the git hash
*
* @return std::string_view
*/
inline std::string_view get_git_hash_short() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_SHORT;
}
std::string_view get_git_hash_short();

/**
* Get the long version of the git hash
*
* @return std::string_view
*/
inline std::string_view get_git_hash_long() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_FULL;
}
std::string_view get_git_hash_long();

/**
* Get the git branch at build time
*
* @return std::string_view
*/
inline std::string_view get_git_branch() {
return @__idi_c_caps_namespace@_VERSION_GIT_BRANCH;
}
std::string_view get_git_branch();

/**
* Get if the git repo is dirty at build time.
*
* @return true If the git repo is dirty
* @return false If the git repo is not dirty
*/
inline consteval bool get_git_is_dirty() {
return (@__idi_c_caps_namespace@_VERSION_GIT_DIRTY == 1);
}
bool get_git_is_dirty();

/**
* Gets the build timestamp in UTC time
Expand All @@ -87,7 +73,5 @@ namespace @__idi_namespace@::base {
*
* @return std::string_view reference to timestamp.
*/
inline std::string_view get_build_timestamp() {
return @__idi_c_caps_namespace@_BUILD_TIMESTAMP;
}
std::string_view get_build_timestamp();
}
32 changes: 8 additions & 24 deletions src/base/include/template_project/public/__version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,63 +23,49 @@ extern "C"
* Get the major version number of the current version of the project.
* @return int32_t
*/
inline @__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_major() {
return @__idi_c_caps_namespace@_VERSION_MAJOR;
}
@__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_major();

/**
* Get the minor version number of the current version of the project.
* @return int32_t
*/
inline @__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_minor() {
return @__idi_c_caps_namespace@_VERSION_MINOR;
}
@__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_minor();

/**
* Get the patch version number of the current version of the project.
* @return int32_t
*/
inline @__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_patch() {
return @__idi_c_caps_namespace@_VERSION_PATCH;
}
@__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_patch();

/**
* Get the short version of the git hash
*
* @return const char *
*/
inline @__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_hash_short() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_SHORT;
}
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_hash_short();

/**
* Get the long version of the git hash
*
* @return const char *
*/
inline @__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_hash_long() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_FULL;
}
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_hash_long();


/**
* Get the git branch at build time
*
* @return const char *
*/
inline @__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_branch() {
return @__idi_c_caps_namespace@_VERSION_GIT_BRANCH;
}
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_branch();

/**
* Get if the git repo is dirty at build time.
*
* @return true If the git repo is dirty
* @return false If the git repo is not dirty
*/
inline @__idi_c_caps_namespace@_EXPORT bool @__idi_c_namespace@_get_git_is_dirty() {
return (@__idi_c_caps_namespace@_VERSION_GIT_DIRTY == 1);
}
@__idi_c_caps_namespace@_EXPORT bool @__idi_c_namespace@_get_git_is_dirty();

/**
* Gets the build timestamp in UTC time
Expand All @@ -88,9 +74,7 @@ inline @__idi_c_caps_namespace@_EXPORT bool @__idi_c_namespace@_get_git_is_dirty
*
* @return std::string reference to timestamp.
*/
inline @__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_build_timestamp() {
return @__idi_c_caps_namespace@_BUILD_TIMESTAMP;
}
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_build_timestamp();

#ifdef __cplusplus
}
Expand Down
152 changes: 152 additions & 0 deletions src/base/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,155 @@
#include "@PROJECT_NAME@/version.hpp"
#include "@PROJECT_NAME@/public/__build_info.out.h"
#include "@PROJECT_NAME@/public/idi_version.h"



namespace @__idi_namespace@::base {
/**
* Get the major version number of the current version of the project.
*
* @return int32_t
*/
uint32_t get_version_major() {
return @__idi_c_caps_namespace@_VERSION_MAJOR;
}

/**
* Get the minor version number of the current version of the project.
*
* @return int32_t
*/
uint32_t get_version_minor() {
return @__idi_c_caps_namespace@_VERSION_MINOR;
}

/**
* Get the patch version number of the current version of the project.
*
* @return int32_t
*/
uint32_t get_version_patch() {
return @__idi_c_caps_namespace@_VERSION_PATCH;
}

/**
* Get the short version of the git hash
*
* @return std::string_view
*/
std::string_view get_git_hash_short() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_SHORT;
}

/**
* Get the long version of the git hash
*
* @return std::string_view
*/
std::string_view get_git_hash_long() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_FULL;
}

/**
* Get the git branch at build time
*
* @return std::string_view
*/
std::string_view get_git_branch() {
return @__idi_c_caps_namespace@_VERSION_GIT_BRANCH;
}

/**
* Get if the git repo is dirty at build time.
*
* @return true If the git repo is dirty
* @return false If the git repo is not dirty
*/
bool get_git_is_dirty() {
return (@__idi_c_caps_namespace@_VERSION_GIT_DIRTY == 1);
}

/**
* Gets the build timestamp in UTC time
*
* Ex: 2022-02-04T02:04:14Z
*
* @return std::string_view reference to timestamp.
*/
std::string_view get_build_timestamp() {
return @__idi_c_caps_namespace@_BUILD_TIMESTAMP;
}
}

/**
* Get the major version number of the current version of the project.
* @return int32_t
*/
@__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_major() {
return @__idi_c_caps_namespace@_VERSION_MAJOR;
}

/**
* Get the minor version number of the current version of the project.
* @return int32_t
*/
@__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_minor() {
return @__idi_c_caps_namespace@_VERSION_MINOR;
}

/**
* Get the patch version number of the current version of the project.
* @return int32_t
*/
@__idi_c_caps_namespace@_EXPORT uint32_t @__idi_c_namespace@_get_version_patch() {
return @__idi_c_caps_namespace@_VERSION_PATCH;
}

/**
* Get the short version of the git hash
*
* @return const char *
*/
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_hash_short() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_SHORT;
}

/**
* Get the long version of the git hash
*
* @return const char *
*/
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_hash_long() {
return @__idi_c_caps_namespace@_VERSION_GIT_HASH_FULL;
}


/**
* Get the git branch at build time
*
* @return const char *
*/
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_git_branch() {
return @__idi_c_caps_namespace@_VERSION_GIT_BRANCH;
}

/**
* Get if the git repo is dirty at build time.
*
* @return true If the git repo is dirty
* @return false If the git repo is not dirty
*/
@__idi_c_caps_namespace@_EXPORT bool @__idi_c_namespace@_get_git_is_dirty() {
return (@__idi_c_caps_namespace@_VERSION_GIT_DIRTY == 1);
}

/**
* Gets the build timestamp in UTC time
*
* Ex: 2022-02-04T02:04:14Z
*
* @return std::string reference to timestamp.
*/
@__idi_c_caps_namespace@_EXPORT const char * @__idi_c_namespace@_get_build_timestamp() {
return @__idi_c_caps_namespace@_BUILD_TIMESTAMP;
}

0 comments on commit ffa85e1

Please sign in to comment.