aboutsummaryrefslogtreecommitdiff
path: root/tests/ECMSetupVersionTest/new_explicit_header
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ECMSetupVersionTest/new_explicit_header')
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_header/CMakeLists.txt38
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_header/main.c24
2 files changed, 62 insertions, 0 deletions
diff --git a/tests/ECMSetupVersionTest/new_explicit_header/CMakeLists.txt b/tests/ECMSetupVersionTest/new_explicit_header/CMakeLists.txt
new file mode 100644
index 00000000..4c2383a3
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_header/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_explicit_header VERSION 1.5.6.7)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4
+ VARIABLE_PREFIX Foo
+ VERSION_HEADER "ecm_new_explicit_header_version.h"
+)
+
+macro(strcheck var val)
+ if(NOT ${var} STREQUAL "${val}")
+ message(FATAL_ERROR "${var} was ${${var}} instead of ${val}")
+ endif()
+endmacro()
+macro(numcheck var val)
+ if(NOT ${var} EQUAL "${val}")
+ message(FATAL_ERROR "${var} was ${${var}} instead of ${val}")
+ endif()
+endmacro()
+
+strcheck(PROJECT_VERSION "1.5.6.7")
+strcheck(PROJECT_VERSION_STRING "1.5.6.7")
+numcheck(PROJECT_VERSION_MAJOR 1)
+numcheck(PROJECT_VERSION_MINOR 5)
+numcheck(PROJECT_VERSION_PATCH 6)
+
+strcheck(Foo_VERSION "2.3.4")
+strcheck(Foo_VERSION_STRING "2.3.4")
+numcheck(Foo_VERSION_MAJOR 2)
+numcheck(Foo_VERSION_MINOR 3)
+numcheck(Foo_VERSION_PATCH 4)
+numcheck(Foo_SOVERSION 2)
+
+add_executable(check_header main.c)
+target_include_directories(check_header PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
diff --git a/tests/ECMSetupVersionTest/new_explicit_header/main.c b/tests/ECMSetupVersionTest/new_explicit_header/main.c
new file mode 100644
index 00000000..98cdf415
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_header/main.c
@@ -0,0 +1,24 @@
+#include <ecm_new_explicit_header_version.h>
+#include <string.h>
+#include <stdio.h>
+
+#define intcheck(macro,val) \
+ if (macro != val) { \
+ printf(#macro " was %d instead of %d", macro, val); \
+ return 1; \
+ }
+#define strcheck(macro,val) \
+ if (strcmp(macro,val) != 0) { \
+ printf(#macro " was %s instead of %s", macro, val); \
+ return 1; \
+ }
+
+int main()
+{
+ intcheck(Foo_VERSION_MAJOR,2)
+ intcheck(Foo_VERSION_MINOR,3)
+ intcheck(Foo_VERSION_PATCH,4)
+ intcheck(Foo_VERSION,((2 << 16) + (3 << 8) + 4))
+ strcheck(Foo_VERSION_STRING,"2.3.4")
+ return 0;
+}