Skip to content

Commit

Permalink
Make version library a interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Dec 9, 2021
1 parent 8e293b8 commit ab71b2d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/version/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,9 @@ string(TOUPPER ${META_PROJECT_NAME} META_PROJECT_NAME_UPPER)
string(TOLOWER ${META_PROJECT_NAME} META_PROJECT_NAME_LOWER)

set(template_include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target}")
set(template_source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")

set(include_path "${CMAKE_BINARY_DIR}/source/include/${META_PROJECT_NAME_LOWER}")
set(source_path "${CMAKE_BINARY_DIR}/source/${META_PROJECT_NAME_LOWER}/source")
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")

# Generate version-header
configure_file(${template_include_path}/version.h.in ${include_path}/${META_PROJECT_NAME_LOWER}_version.h)
Expand All @@ -46,6 +45,10 @@ set(headers
${include_path}/${META_PROJECT_NAME_LOWER}_version.h
)

set(sources
${source_path}/version.c
)

# Group source files
set(header_group "Header Files (API)")
set(source_group "Source Files")
Expand All @@ -59,6 +62,7 @@ source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$"
# Build library
add_library(${target}
${headers}
${sources}
)

# Create namespaced alias
Expand Down
38 changes: 38 additions & 0 deletions source/version/source/version.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* CMake Versioning Utility by Parra Studios
* A template for generating versioning utilities.
*
* Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia <[email protected]>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <metacall/metacall_version.h>

const char *version_print_info()
{
static const char version_info[] =
"Abstract Data Type Library " METACALL_VERSION "\n"
"Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia <[email protected]>\n"

#ifdef ADT_STATIC_DEFINE
"Compiled as static library type"
#else
"Compiled as shared library type"
#endif

"\n";

return version_info;
}

0 comments on commit ab71b2d

Please sign in to comment.