Hi Some FFmpeg developers a while back suggested that codec2 should have a version.h so users can better detect and deal with API peculiarities. Nivex added version numbers in r3343, this patch exposes them in a generated version.h that gets installed with the rest of the headers. Proposed patch attached.
Thoughts? I think we might always define CODEC2_VERSION_PATCH. Not much sense in trying to distinguish PATCH=0 and PATCH=Undefined (CMake certainly can't) Once this issue is sorted I plan on taking another stab at getting codec2 stuff incorporated into FFmpeg. I got reasonable feedback on my patchset for that earlier this year /Tomas
Index: CMakeLists.txt =================================================================== --- CMakeLists.txt (revision 3379) +++ CMakeLists.txt (working copy) @@ -37,6 +37,7 @@ set(CODEC2_VERSION_MAJOR 0) set(CODEC2_VERSION_MINOR 8) # Set to patch level if needed, otherwise leave FALSE. +# Must be positive (non-zero) if set, since 0 == FALSE in CMake. set(CODEC2_VERSION_PATCH FALSE) set(CODEC2_VERSION "${CODEC2_VERSION_MAJOR}.${CODEC2_VERSION_MINOR}") # Patch level version bumps should not change API/ABI. @@ -53,7 +54,7 @@ # Set default C++ flags. include(CheckCCompilerFlag) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O3 -D CODEC2_VERSION_MAJOR=${CODEC2_VERSION_MAJOR} -D CODEC2_VERSION_MINOR=${CODEC2_VERSION_MINOR}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -g -O3") CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_GNU11) if(CMAKE_C_STANDARD_COMPUTED_DEFAULT EQUAL "90") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") @@ -140,6 +141,10 @@ configure_file ("${PROJECT_SOURCE_DIR}/cmake/config.h.in" "${PROJECT_BINARY_DIR}/config.h" ) +# Output path is such that #include <codec2/version.h> in codec2.h works +set(CODEC2_VERSION_PATH "${PROJECT_BINARY_DIR}/codec2/version.h") +configure_file ("${PROJECT_SOURCE_DIR}/cmake/version.h.in" + "${CODEC2_VERSION_PATH}" ) include_directories(${PROJECT_BINARY_DIR}) # CMake Package setup Index: cmake/version.h.in =================================================================== --- cmake/version.h.in (nonexistent) +++ cmake/version.h.in (working copy) @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: version.h + AUTHOR......: Tomas Härdin + DATE CREATED: 03 November 2017 + + Codec 2 VERSION #defines + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2017 Tomas Härdin + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. +*/ + +//this functions both as an include guard and your typical HAVE macro +#ifndef CODEC2_HAVE_VERSION +#define CODEC2_HAVE_VERSION + +#define CODEC2_VERSION_MAJOR @CODEC2_VERSION_MAJOR@ +#define CODEC2_VERSION_MINOR @CODEC2_VERSION_MINOR@ +#cmakedefine CODEC2_VERSION_PATCH @CODEC2_VERSION_PATCH@ +#define CODEC2_VERSION "@CODEC2_VERSION@" + +#endif //CODEC2_HAVE_VERSION \ No newline at end of file Index: src/CMakeLists.txt =================================================================== --- src/CMakeLists.txt (revision 3379) +++ src/CMakeLists.txt (working copy) @@ -249,6 +249,7 @@ freedv_api.h varicode.h freedv_api_internal.h + ${CODEC2_VERSION_PATH} ) # Index: src/codec2.h =================================================================== --- src/codec2.h (revision 3379) +++ src/codec2.h (working copy) @@ -33,6 +33,8 @@ #ifndef __CODEC2__ #define __CODEC2__ +#include <codec2/version.h> + #define CODEC2_MODE_3200 0 #define CODEC2_MODE_2400 1 #define CODEC2_MODE_1600 2
signature.asc
Description: This is a digitally signed message part
------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________ Freetel-codec2 mailing list Freetel-codec2@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freetel-codec2