aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@kde.org>2014-04-17 15:46:08 +0100
committerAlex Merry <alex.merry@kde.org>2014-04-25 10:39:56 +0100
commit035c6fa9390ecb66422ee684be71eea692989009 (patch)
treef95921a78c1e59b2ee890feb703f7a55341a2961 /tests
parent50b164a7ce83cdaec18209c7c2226d2fdb9cf29e (diff)
downloadextra-cmake-modules-035c6fa9390ecb66422ee684be71eea692989009.tar.gz
extra-cmake-modules-035c6fa9390ecb66422ee684be71eea692989009.tar.bz2
Make ecm_setup_version interact well with CMP0048
When CMake policy CMP0048 (CMake 3.0) is set to NEW, the project() command is meant to manage the project's version variables. We therefore do not set the PROJECT_VERSION variables in this case. To make sure projects do not have to specify their version in multiple places, this also allows the keyword "PROJECT" to be passed to ecm_setup_version instead of an actual version number. In this case, the version passed to project() will be used. REVIEW: 117619
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt1
-rw-r--r--tests/ECMSetupVersionTest/CMakeLists.txt39
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_header/CMakeLists.txt38
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_header/main.c24
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_header_abspath/CMakeLists.txt38
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_header_abspath/main.c24
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_simple/CMakeLists.txt34
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_simple/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_soversion/CMakeLists.txt37
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_soversion/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_version_file/CMakeLists.txt47
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_version_file/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_version_file_abspath/CMakeLists.txt47
-rw-r--r--tests/ECMSetupVersionTest/new_explicit_version_file_abspath/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_project_header/CMakeLists.txt37
-rw-r--r--tests/ECMSetupVersionTest/new_project_header/main.c24
-rw-r--r--tests/ECMSetupVersionTest/new_project_header_abspath/CMakeLists.txt37
-rw-r--r--tests/ECMSetupVersionTest/new_project_header_abspath/main.c24
-rw-r--r--tests/ECMSetupVersionTest/new_project_header_prefix/CMakeLists.txt38
-rw-r--r--tests/ECMSetupVersionTest/new_project_header_prefix/main.c24
-rw-r--r--tests/ECMSetupVersionTest/new_project_simple/CMakeLists.txt34
-rw-r--r--tests/ECMSetupVersionTest/new_project_simple/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_project_simple_prefix/CMakeLists.txt34
-rw-r--r--tests/ECMSetupVersionTest/new_project_simple_prefix/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_project_soversion/CMakeLists.txt36
-rw-r--r--tests/ECMSetupVersionTest/new_project_soversion/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_project_soversion_prefix/CMakeLists.txt37
-rw-r--r--tests/ECMSetupVersionTest/new_project_soversion_prefix/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_project_version_file/CMakeLists.txt46
-rw-r--r--tests/ECMSetupVersionTest/new_project_version_file/main.c4
-rw-r--r--tests/ECMSetupVersionTest/new_project_version_file_abspath/CMakeLists.txt46
-rw-r--r--tests/ECMSetupVersionTest/new_project_version_file_abspath/main.c4
-rw-r--r--tests/ECMSetupVersionTest/old_header/CMakeLists.txt38
-rw-r--r--tests/ECMSetupVersionTest/old_header/main.c24
-rw-r--r--tests/ECMSetupVersionTest/old_header_abspath/CMakeLists.txt38
-rw-r--r--tests/ECMSetupVersionTest/old_header_abspath/main.c24
-rw-r--r--tests/ECMSetupVersionTest/old_simple/CMakeLists.txt34
-rw-r--r--tests/ECMSetupVersionTest/old_simple/main.c4
-rw-r--r--tests/ECMSetupVersionTest/old_soversion/CMakeLists.txt37
-rw-r--r--tests/ECMSetupVersionTest/old_soversion/main.c4
-rw-r--r--tests/ECMSetupVersionTest/old_version_file/CMakeLists.txt47
-rw-r--r--tests/ECMSetupVersionTest/old_version_file/main.c4
-rw-r--r--tests/ECMSetupVersionTest/old_version_file_abspath/CMakeLists.txt47
-rw-r--r--tests/ECMSetupVersionTest/old_version_file_abspath/main.c4
44 files changed, 1091 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index a3e619a7..b0d7aec9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -2,6 +2,7 @@
# directory and project
add_subdirectory(ECMGenerateHeadersTest)
+add_subdirectory(ECMSetupVersionTest)
macro(ADD_TEST_MACRO NAME COMMAND)
string(REPLACE "." "/" dir "${NAME}")
diff --git a/tests/ECMSetupVersionTest/CMakeLists.txt b/tests/ECMSetupVersionTest/CMakeLists.txt
new file mode 100644
index 00000000..2e7decfb
--- /dev/null
+++ b/tests/ECMSetupVersionTest/CMakeLists.txt
@@ -0,0 +1,39 @@
+macro(add_version_test NAME COMMAND)
+ string(REPLACE "." "/" dir "${NAME}")
+ string(REGEX REPLACE "[^.]*\\." "" proj "${NAME}")
+ add_test(ecm_setup_version-${NAME} ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/${dir}"
+ "${CMAKE_CURRENT_BINARY_DIR}/${dir}"
+ --build-two-config
+ --build-generator ${CMAKE_GENERATOR}
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-project ${proj}
+ ${${NAME}_EXTRA_OPTIONS}
+ --test-command ${COMMAND} ${ARGN})
+endmacro()
+
+add_version_test(old_simple dummy)
+add_version_test(old_soversion dummy)
+add_version_test(old_version_file dummy)
+add_version_test(old_version_file_abspath dummy)
+add_version_test(old_header check_header)
+add_version_test(old_header_abspath check_header)
+
+if(CMAKE_MAJOR_VERSION GREATER 2)
+ add_version_test(new_explicit_header check_header)
+ add_version_test(new_explicit_header_abspath check_header)
+ add_version_test(new_explicit_simple dummy)
+ add_version_test(new_explicit_soversion dummy)
+ add_version_test(new_explicit_version_file dummy)
+ add_version_test(new_explicit_version_file_abspath dummy)
+ add_version_test(new_project_header check_header)
+ add_version_test(new_project_header_abspath check_header)
+ add_version_test(new_project_header_prefix check_header)
+ add_version_test(new_project_simple dummy)
+ add_version_test(new_project_simple_prefix dummy)
+ add_version_test(new_project_soversion dummy)
+ add_version_test(new_project_soversion_prefix dummy)
+ add_version_test(new_project_version_file dummy)
+ add_version_test(new_project_version_file_abspath dummy)
+endif()
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;
+}
diff --git a/tests/ECMSetupVersionTest/new_explicit_header_abspath/CMakeLists.txt b/tests/ECMSetupVersionTest/new_explicit_header_abspath/CMakeLists.txt
new file mode 100644
index 00000000..772c28d3
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_header_abspath/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_explicit_header_abspath 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 "${CMAKE_CURRENT_BINARY_DIR}/../ecm_new_explicit_header_abspath_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_abspath/main.c b/tests/ECMSetupVersionTest/new_explicit_header_abspath/main.c
new file mode 100644
index 00000000..d7168a79
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_header_abspath/main.c
@@ -0,0 +1,24 @@
+#include <ecm_old_header_abspath_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;
+}
diff --git a/tests/ECMSetupVersionTest/new_explicit_simple/CMakeLists.txt b/tests/ECMSetupVersionTest/new_explicit_simple/CMakeLists.txt
new file mode 100644
index 00000000..fa989d61
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_simple/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_explicit_simple 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)
+
+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(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_explicit_simple/main.c b/tests/ECMSetupVersionTest/new_explicit_simple/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_simple/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_explicit_soversion/CMakeLists.txt b/tests/ECMSetupVersionTest/new_explicit_soversion/CMakeLists.txt
new file mode 100644
index 00000000..1c50dcdb
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_soversion/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_explicit_soversion 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
+ SOVERSION 1
+)
+
+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 1)
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_explicit_soversion/main.c b/tests/ECMSetupVersionTest/new_explicit_soversion/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_soversion/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_explicit_version_file/CMakeLists.txt b/tests/ECMSetupVersionTest/new_explicit_version_file/CMakeLists.txt
new file mode 100644
index 00000000..f97c834e
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_version_file/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_explicit_version_file 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
+ PACKAGE_VERSION_FILE FooVersion.cmake
+)
+
+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)
+
+set(PACKAGE_FIND_VERSION "2.3.4")
+include("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake")
+strcheck(PACKAGE_VERSION "2.3.4")
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(FATAL_ERROR "PACKAGE_VERSION_COMPATIBLE not TRUE")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(FATAL_ERROR "PACKAGE_VERSION_EXACT not TRUE")
+endif()
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_explicit_version_file/main.c b/tests/ECMSetupVersionTest/new_explicit_version_file/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_version_file/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_explicit_version_file_abspath/CMakeLists.txt b/tests/ECMSetupVersionTest/new_explicit_version_file_abspath/CMakeLists.txt
new file mode 100644
index 00000000..cfe374cc
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_version_file_abspath/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_explicit_version_abspath 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
+ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/../NewExplicitVersionAbsPath.cmake"
+)
+
+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)
+
+set(PACKAGE_FIND_VERSION "2.3.4")
+include("${CMAKE_CURRENT_BINARY_DIR}/../NewExplicitVersionAbsPath.cmake")
+strcheck(PACKAGE_VERSION "2.3.4")
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(FATAL_ERROR "PACKAGE_VERSION_COMPATIBLE not TRUE")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(FATAL_ERROR "PACKAGE_VERSION_EXACT not TRUE")
+endif()
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_explicit_version_file_abspath/main.c b/tests/ECMSetupVersionTest/new_explicit_version_file_abspath/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_explicit_version_file_abspath/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_header/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_header/CMakeLists.txt
new file mode 100644
index 00000000..00e12177
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_header/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_header VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ VERSION_HEADER "ecm_new_project_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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+strcheck(new_project_header_VERSION "2.3.4")
+strcheck(new_project_header_VERSION_STRING "2.3.4")
+numcheck(new_project_header_VERSION_MAJOR 2)
+numcheck(new_project_header_VERSION_MINOR 3)
+numcheck(new_project_header_VERSION_PATCH 4)
+numcheck(new_project_header_SOVERSION 2)
+
+add_executable(check_header main.c)
+target_include_directories(check_header PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
diff --git a/tests/ECMSetupVersionTest/new_project_header/main.c b/tests/ECMSetupVersionTest/new_project_header/main.c
new file mode 100644
index 00000000..42236875
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_header/main.c
@@ -0,0 +1,24 @@
+#include <ecm_new_project_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(new_project_header_VERSION_MAJOR,2)
+ intcheck(new_project_header_VERSION_MINOR,3)
+ intcheck(new_project_header_VERSION_PATCH,4)
+ intcheck(new_project_header_VERSION,((2 << 16) + (3 << 8) + 4))
+ strcheck(new_project_header_VERSION_STRING,"2.3.4")
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_header_abspath/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_header_abspath/CMakeLists.txt
new file mode 100644
index 00000000..6a354042
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_header_abspath/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_header_abspath VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/../ecm_new_project_header_abspath_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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+strcheck(new_project_header_abspath_VERSION "2.3.4")
+strcheck(new_project_header_abspath_VERSION_STRING "2.3.4")
+numcheck(new_project_header_abspath_VERSION_MAJOR 2)
+numcheck(new_project_header_abspath_VERSION_MINOR 3)
+numcheck(new_project_header_abspath_VERSION_PATCH 4)
+numcheck(new_project_header_abspath_SOVERSION 2)
+
+add_executable(check_header main.c)
+target_include_directories(check_header PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/..")
diff --git a/tests/ECMSetupVersionTest/new_project_header_abspath/main.c b/tests/ECMSetupVersionTest/new_project_header_abspath/main.c
new file mode 100644
index 00000000..339da920
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_header_abspath/main.c
@@ -0,0 +1,24 @@
+#include <ecm_new_project_header_abspath_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(new_project_header_abspath_VERSION_MAJOR,2)
+ intcheck(new_project_header_abspath_VERSION_MINOR,3)
+ intcheck(new_project_header_abspath_VERSION_PATCH,4)
+ intcheck(new_project_header_abspath_VERSION,((2 << 16) + (3 << 8) + 4))
+ strcheck(new_project_header_abspath_VERSION_STRING,"2.3.4")
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_header_prefix/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_header_prefix/CMakeLists.txt
new file mode 100644
index 00000000..d560f223
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_header_prefix/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_header_prefix VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ VARIABLE_PREFIX Foo
+ VERSION_HEADER "ecm_new_project_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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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_project_header_prefix/main.c b/tests/ECMSetupVersionTest/new_project_header_prefix/main.c
new file mode 100644
index 00000000..d6885666
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_header_prefix/main.c
@@ -0,0 +1,24 @@
+#include <ecm_new_project_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;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_simple/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_simple/CMakeLists.txt
new file mode 100644
index 00000000..6ed27546
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_simple/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_simple VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+strcheck(new_project_simple_VERSION "2.3.4")
+strcheck(new_project_simple_VERSION_STRING "2.3.4")
+numcheck(new_project_simple_VERSION_MAJOR 2)
+numcheck(new_project_simple_VERSION_MINOR 3)
+numcheck(new_project_simple_VERSION_PATCH 4)
+numcheck(new_project_simple_SOVERSION 2)
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_project_simple/main.c b/tests/ECMSetupVersionTest/new_project_simple/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_simple/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_simple_prefix/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_simple_prefix/CMakeLists.txt
new file mode 100644
index 00000000..854d411f
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_simple_prefix/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_simple_prefix VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT VARIABLE_PREFIX Foo)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_project_simple_prefix/main.c b/tests/ECMSetupVersionTest/new_project_simple_prefix/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_simple_prefix/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_soversion/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_soversion/CMakeLists.txt
new file mode 100644
index 00000000..b2cedd66
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_soversion/CMakeLists.txt
@@ -0,0 +1,36 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_soversion VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ SOVERSION 1
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+strcheck(new_project_soversion_VERSION "2.3.4")
+strcheck(new_project_soversion_VERSION_STRING "2.3.4")
+numcheck(new_project_soversion_VERSION_MAJOR 2)
+numcheck(new_project_soversion_VERSION_MINOR 3)
+numcheck(new_project_soversion_VERSION_PATCH 4)
+numcheck(new_project_soversion_SOVERSION 1)
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_project_soversion/main.c b/tests/ECMSetupVersionTest/new_project_soversion/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_soversion/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_soversion_prefix/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_soversion_prefix/CMakeLists.txt
new file mode 100644
index 00000000..f8182b60
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_soversion_prefix/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_soversion_prefix VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ VARIABLE_PREFIX Foo
+ SOVERSION 1
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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 1)
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_project_soversion_prefix/main.c b/tests/ECMSetupVersionTest/new_project_soversion_prefix/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_soversion_prefix/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_version_file/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_version_file/CMakeLists.txt
new file mode 100644
index 00000000..32cc4d8c
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_version_file/CMakeLists.txt
@@ -0,0 +1,46 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_version_file VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ PACKAGE_VERSION_FILE FooVersion.cmake
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+strcheck(new_project_version_file_VERSION "2.3.4")
+strcheck(new_project_version_file_VERSION_STRING "2.3.4")
+numcheck(new_project_version_file_VERSION_MAJOR 2)
+numcheck(new_project_version_file_VERSION_MINOR 3)
+numcheck(new_project_version_file_VERSION_PATCH 4)
+numcheck(new_project_version_file_SOVERSION 2)
+
+set(PACKAGE_FIND_VERSION "2.3.4")
+include("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake")
+strcheck(PACKAGE_VERSION "2.3.4")
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(FATAL_ERROR "PACKAGE_VERSION_COMPATIBLE not TRUE")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(FATAL_ERROR "PACKAGE_VERSION_EXACT not TRUE")
+endif()
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_project_version_file/main.c b/tests/ECMSetupVersionTest/new_project_version_file/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_version_file/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/new_project_version_file_abspath/CMakeLists.txt b/tests/ECMSetupVersionTest/new_project_version_file_abspath/CMakeLists.txt
new file mode 100644
index 00000000..bcf22626
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_version_file_abspath/CMakeLists.txt
@@ -0,0 +1,46 @@
+cmake_minimum_required(VERSION 3.0.0)
+
+project(new_project_version_file_abspath VERSION 2.3.4)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(PROJECT
+ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/../NewProjectVersionAbsPath.cmake"
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+strcheck(new_project_version_file_abspath_VERSION "2.3.4")
+strcheck(new_project_version_file_abspath_VERSION_STRING "2.3.4")
+numcheck(new_project_version_file_abspath_VERSION_MAJOR 2)
+numcheck(new_project_version_file_abspath_VERSION_MINOR 3)
+numcheck(new_project_version_file_abspath_VERSION_PATCH 4)
+numcheck(new_project_version_file_abspath_SOVERSION 2)
+
+set(PACKAGE_FIND_VERSION "2.3.4")
+include("${CMAKE_CURRENT_BINARY_DIR}/../NewProjectVersionAbsPath.cmake")
+strcheck(PACKAGE_VERSION "2.3.4")
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(FATAL_ERROR "PACKAGE_VERSION_COMPATIBLE not TRUE")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(FATAL_ERROR "PACKAGE_VERSION_EXACT not TRUE")
+endif()
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/new_project_version_file_abspath/main.c b/tests/ECMSetupVersionTest/new_project_version_file_abspath/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/new_project_version_file_abspath/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/old_header/CMakeLists.txt b/tests/ECMSetupVersionTest/old_header/CMakeLists.txt
new file mode 100644
index 00000000..53f90820
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_header/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(old_header)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4
+ VARIABLE_PREFIX Foo
+ VERSION_HEADER "ecm_old_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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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/old_header/main.c b/tests/ECMSetupVersionTest/old_header/main.c
new file mode 100644
index 00000000..1ae1679b
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_header/main.c
@@ -0,0 +1,24 @@
+#include <ecm_old_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;
+}
diff --git a/tests/ECMSetupVersionTest/old_header_abspath/CMakeLists.txt b/tests/ECMSetupVersionTest/old_header_abspath/CMakeLists.txt
new file mode 100644
index 00000000..81428955
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_header_abspath/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(old_header_abspath)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4
+ VARIABLE_PREFIX Foo
+ VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/../ecm_old_header_abspath_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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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/old_header_abspath/main.c b/tests/ECMSetupVersionTest/old_header_abspath/main.c
new file mode 100644
index 00000000..d7168a79
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_header_abspath/main.c
@@ -0,0 +1,24 @@
+#include <ecm_old_header_abspath_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;
+}
diff --git a/tests/ECMSetupVersionTest/old_simple/CMakeLists.txt b/tests/ECMSetupVersionTest/old_simple/CMakeLists.txt
new file mode 100644
index 00000000..81adf151
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_simple/CMakeLists.txt
@@ -0,0 +1,34 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(old_simple)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4 VARIABLE_PREFIX Foo)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/old_simple/main.c b/tests/ECMSetupVersionTest/old_simple/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_simple/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/old_soversion/CMakeLists.txt b/tests/ECMSetupVersionTest/old_soversion/CMakeLists.txt
new file mode 100644
index 00000000..72b274bd
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_soversion/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(old_soversion)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4
+ VARIABLE_PREFIX Foo
+ SOVERSION 1
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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 1)
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/old_soversion/main.c b/tests/ECMSetupVersionTest/old_soversion/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_soversion/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/old_version_file/CMakeLists.txt b/tests/ECMSetupVersionTest/old_version_file/CMakeLists.txt
new file mode 100644
index 00000000..d47a23db
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_version_file/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(old_version_file)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4
+ VARIABLE_PREFIX Foo
+ PACKAGE_VERSION_FILE FooVersion.cmake
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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)
+
+set(PACKAGE_FIND_VERSION "2.3.4")
+include("${CMAKE_CURRENT_BINARY_DIR}/FooVersion.cmake")
+strcheck(PACKAGE_VERSION "2.3.4")
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(FATAL_ERROR "PACKAGE_VERSION_COMPATIBLE not TRUE")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(FATAL_ERROR "PACKAGE_VERSION_EXACT not TRUE")
+endif()
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/old_version_file/main.c b/tests/ECMSetupVersionTest/old_version_file/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_version_file/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/tests/ECMSetupVersionTest/old_version_file_abspath/CMakeLists.txt b/tests/ECMSetupVersionTest/old_version_file_abspath/CMakeLists.txt
new file mode 100644
index 00000000..1698f369
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_version_file_abspath/CMakeLists.txt
@@ -0,0 +1,47 @@
+cmake_minimum_required(VERSION 2.8.12)
+
+project(old_version_file_abspath)
+
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../modules)
+include(ECMSetupVersion)
+
+ecm_setup_version(2.3.4
+ VARIABLE_PREFIX Foo
+ PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/../OldVersionAbsPath.cmake"
+)
+
+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 "2.3.4")
+strcheck(PROJECT_VERSION_STRING "2.3.4")
+numcheck(PROJECT_VERSION_MAJOR 2)
+numcheck(PROJECT_VERSION_MINOR 3)
+numcheck(PROJECT_VERSION_PATCH 4)
+
+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)
+
+set(PACKAGE_FIND_VERSION "2.3.4")
+include("${CMAKE_CURRENT_BINARY_DIR}/../OldVersionAbsPath.cmake")
+strcheck(PACKAGE_VERSION "2.3.4")
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(FATAL_ERROR "PACKAGE_VERSION_COMPATIBLE not TRUE")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(FATAL_ERROR "PACKAGE_VERSION_EXACT not TRUE")
+endif()
+
+add_executable(dummy main.c)
diff --git a/tests/ECMSetupVersionTest/old_version_file_abspath/main.c b/tests/ECMSetupVersionTest/old_version_file_abspath/main.c
new file mode 100644
index 00000000..c13815ce
--- /dev/null
+++ b/tests/ECMSetupVersionTest/old_version_file_abspath/main.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}