From ab71b2d5c18db3bad593d35dcfed3aa71aa35852 Mon Sep 17 00:00:00 2001 From: Vicente Eduardo Ferrer Garcia Date: Thu, 9 Dec 2021 16:16:51 +0200 Subject: [PATCH] Make version library a interface. --- source/version/CMakeLists.txt | 8 +++++-- source/version/source/version.c | 38 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 source/version/source/version.c diff --git a/source/version/CMakeLists.txt b/source/version/CMakeLists.txt index e15e80754..9486e5134 100644 --- a/source/version/CMakeLists.txt +++ b/source/version/CMakeLists.txt @@ -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) @@ -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") @@ -59,6 +62,7 @@ source_group_by_path(${include_path} "\\\\.h$|\\\\.hpp$" # Build library add_library(${target} ${headers} + ${sources} ) # Create namespaced alias diff --git a/source/version/source/version.c b/source/version/source/version.c new file mode 100644 index 000000000..49e7cb6d2 --- /dev/null +++ b/source/version/source/version.c @@ -0,0 +1,38 @@ +/* + * CMake Versioning Utility by Parra Studios + * A template for generating versioning utilities. + * + * Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia + * + * 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 + +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 \n" + +#ifdef ADT_STATIC_DEFINE + "Compiled as static library type" +#else + "Compiled as shared library type" +#endif + + "\n"; + + return version_info; +}