aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/ECMSetupVersion.cmake124
-rw-r--r--modules/ECMVersionHeader.h.in14
-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
46 files changed, 1196 insertions, 33 deletions
diff --git a/modules/ECMSetupVersion.cmake b/modules/ECMSetupVersion.cmake
index 3ae6fa8f..aff17de6 100644
--- a/modules/ECMSetupVersion.cmake
+++ b/modules/ECMSetupVersion.cmake
@@ -23,12 +23,18 @@
# <prefix>_VERSION_MAJOR - <major>
# <prefix>_VERSION_MINOR - <minor>
# <prefix>_VERSION_PATCH - <patch>
-# <prefix>_VERSION_STRING - <version>
+# <prefix>_VERSION - <version>
+# <prefix>_VERSION_STRING - <version> (for compatibility: use <prefix>_VERSION instead)
# <prefix>_SOVERSION - <soversion>, or <major> if SOVERSION was not given
+#
+# If CMake policy CMP0048 is not NEW, the following CMake variables will also
+# be set:
+#
# PROJECT_VERSION_MAJOR - <major>
# PROJECT_VERSION_MINOR - <minor>
# PROJECT_VERSION_PATCH - <patch>
-# PROJECT_VERSION_STRING - <version>
+# PROJECT_VERSION - <version>
+# PROJECT_VERSION_STRING - <version> (for compatibility: use PROJECT_VERSION instead)
#
# If the VERSION_HEADER option is used, a simple C header is generated with the
# given filename. If filename is a relative path, it is interpreted as relative
@@ -50,8 +56,24 @@
# CMake. It should be installed in the same location as the Config.cmake file of
# the library so that it can be found by find_package(). If the filename is a
# relative path, it is interpreted as relative to CMAKE_CURRENT_BINARY_DIR.
+#
+# If CMake policy CMP0048 is NEW, an alternative form of the command is
+# available::
+#
+# ecm_setup_version(PROJECT
+# [VARIABLE_PREFIX <prefix>]
+# [SOVERSION <soversion>]
+# [VERSION_HEADER <filename>]
+# [PACKAGE_VERSION_FILE <filename>] )
+#
+# This will use the version information set by the project() command.
+# VARIABLE_PREFIX defaults to the project name. Note that PROJECT must be the
+# first argument. In all other respects, it behaves like the other form of the
+# command.
+#
#=============================================================================
+# Copyright 2014 Alex Merry <alex.merry@kde.org>
# Copyright 2012 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
@@ -64,10 +86,12 @@
# (To distribute this file outside of extra-cmake-modules, substitute the full
# License text for the above reference.)
-# FIXME: Figure out how this should interact with CMP0048 in CMake 3.0.0
-
include(CMakePackageConfigHelpers)
+# save the location of the header template while CMAKE_CURRENT_LIST_DIR
+# has the value we want
+set(_ECM_SETUP_VERSION_HEADER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/ECMVersionHeader.h.in")
+
function(ECM_SETUP_VERSION _version)
set(options )
set(oneValueArgs VARIABLE_PREFIX SOVERSION VERSION_HEADER PACKAGE_VERSION_FILE)
@@ -79,47 +103,95 @@ function(ECM_SETUP_VERSION _version)
message(FATAL_ERROR "Unknown keywords given to ECM_SETUP_VERSION(): \"${ESV_UNPARSED_ARGUMENTS}\"")
endif()
+ set(project_manages_version FALSE)
+ set(use_project_version FALSE)
+ cmake_policy(GET CMP0048 project_version_policy)
+ if(project_version_policy STREQUAL "NEW")
+ set(project_manages_version TRUE)
+ if(_version STREQUAL "PROJECT")
+ set(use_project_version TRUE)
+ endif()
+ elseif(_version STREQUAL "PROJECT")
+ message(FATAL_ERROR "ecm_setup_version given PROJECT argument, but CMP0048 is not NEW")
+ endif()
+
+ set(should_set_prefixed_vars TRUE)
if(NOT ESV_VARIABLE_PREFIX)
- message(FATAL_ERROR "Required argument PREFIX missing in ECM_SETUP_VERSION() call")
+ if(use_project_version)
+ set(ESV_VARIABLE_PREFIX "${PROJECT_NAME}")
+ set(should_set_prefixed_vars FALSE)
+ else()
+ message(FATAL_ERROR "Required argument PREFIX missing in ECM_SETUP_VERSION() call")
+ endif()
endif()
- string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major "${_version}")
- string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor "${_version}")
- string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch "${_version}")
+ if(use_project_version)
+ set(_version "${PROJECT_VERSION}")
+ set(_major "${PROJECT_VERSION_MAJOR}")
+ set(_minor "${PROJECT_VERSION_MINOR}")
+ set(_patch "${PROJECT_VERSION_PATCH}")
+ else()
+ string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major "${_version}")
+ string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor "${_version}")
+ string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch "${_version}")
+ endif()
if(NOT ESV_SOVERSION)
set(ESV_SOVERSION ${_major})
endif()
- set(${ESV_VARIABLE_PREFIX}_VERSION_MAJOR ${_major})
- set(${ESV_VARIABLE_PREFIX}_VERSION_MINOR ${_minor})
- set(${ESV_VARIABLE_PREFIX}_VERSION_PATCH ${_patch})
+ if(should_set_prefixed_vars)
+ set(${ESV_VARIABLE_PREFIX}_VERSION "${_version}")
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MAJOR ${_major})
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MINOR ${_minor})
+ set(${ESV_VARIABLE_PREFIX}_VERSION_PATCH ${_patch})
+ endif()
+
set(${ESV_VARIABLE_PREFIX}_SOVERSION ${ESV_SOVERSION})
- set(${ESV_VARIABLE_PREFIX}_VERSION_STRING "${_version}")
- set(PROJECT_VERSION_STRING "${${ESV_VARIABLE_PREFIX}_VERSION_STRING}")
- set(PROJECT_VERSION_MAJOR "${${ESV_VARIABLE_PREFIX}_VERSION_MAJOR}")
- set(PROJECT_VERSION_MINOR "${${ESV_VARIABLE_PREFIX}_VERSION_MINOR}")
- set(PROJECT_VERSION_PATCH "${${ESV_VARIABLE_PREFIX}_VERSION_PATCH}")
+ if(NOT project_manages_version)
+ set(PROJECT_VERSION "${_version}")
+ set(PROJECT_VERSION_MAJOR "${_major}")
+ set(PROJECT_VERSION_MINOR "${_minor}")
+ set(PROJECT_VERSION_PATCH "${_patch}")
+ endif()
+
+ # compat
+ set(PROJECT_VERSION_STRING "${PROJECT_VERSION}")
+ set(${ESV_VARIABLE_PREFIX}_VERSION_STRING "${${ESV_VARIABLE_PREFIX}_VERSION}")
if(ESV_VERSION_HEADER)
- set(PROJECT_NAME_UPPER "${ESV_VARIABLE_PREFIX}")
- configure_file("${ECM_MODULE_DIR}/ECMVersionHeader.h.in" "${ESV_VERSION_HEADER}")
+ set(HEADER_PREFIX "${ESV_VARIABLE_PREFIX}")
+ set(HEADER_VERSION "${_version}")
+ set(HEADER_VERSION_MAJOR "${_major}")
+ set(HEADER_VERSION_MINOR "${_minor}")
+ set(HEADER_VERSION_PATCH "${_patch}")
+ configure_file("${_ECM_SETUP_VERSION_HEADER_TEMPLATE}" "${ESV_VERSION_HEADER}")
endif()
if(ESV_PACKAGE_VERSION_FILE)
write_basic_package_version_file("${ESV_PACKAGE_VERSION_FILE}" VERSION ${_version} COMPATIBILITY AnyNewerVersion)
endif()
- set(${ESV_VARIABLE_PREFIX}_VERSION_MAJOR "${${ESV_VARIABLE_PREFIX}_VERSION_MAJOR}" PARENT_SCOPE)
- set(${ESV_VARIABLE_PREFIX}_VERSION_MINOR "${${ESV_VARIABLE_PREFIX}_VERSION_MINOR}" PARENT_SCOPE)
- set(${ESV_VARIABLE_PREFIX}_VERSION_PATCH "${${ESV_VARIABLE_PREFIX}_VERSION_PATCH}" PARENT_SCOPE)
- set(${ESV_VARIABLE_PREFIX}_SOVERSION "${${ESV_VARIABLE_PREFIX}_SOVERSION}" PARENT_SCOPE)
- set(${ESV_VARIABLE_PREFIX}_VERSION_STRING "${${ESV_VARIABLE_PREFIX}_VERSION_STRING}" PARENT_SCOPE)
+ if(should_set_prefixed_vars)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MAJOR "${${ESV_VARIABLE_PREFIX}_VERSION_MAJOR}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_MINOR "${${ESV_VARIABLE_PREFIX}_VERSION_MINOR}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_PATCH "${${ESV_VARIABLE_PREFIX}_VERSION_PATCH}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION "${${ESV_VARIABLE_PREFIX}_VERSION}" PARENT_SCOPE)
+ endif()
+
+ # always set the soversion
+ set(${ESV_VARIABLE_PREFIX}_SOVERSION "${${ESV_VARIABLE_PREFIX}_SOVERSION}" PARENT_SCOPE)
+
+ if(NOT project_manages_version)
+ set(PROJECT_VERSION "${PROJECT_VERSION}" PARENT_SCOPE)
+ set(PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}" PARENT_SCOPE)
+ set(PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}" PARENT_SCOPE)
+ set(PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}" PARENT_SCOPE)
+ endif()
+ # always set the compatibility variables
set(PROJECT_VERSION_STRING "${PROJECT_VERSION_STRING}" PARENT_SCOPE)
- set(PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}" PARENT_SCOPE)
- set(PROJECT_VERSION_MINOR "${PROJECT_VERSION_MINOR}" PARENT_SCOPE)
- set(PROJECT_VERSION_PATCH "${PROJECT_VERSION_PATCH}" PARENT_SCOPE)
+ set(${ESV_VARIABLE_PREFIX}_VERSION_STRING "${${ESV_VARIABLE_PREFIX}_VERSION}" PARENT_SCOPE)
endfunction()
diff --git a/modules/ECMVersionHeader.h.in b/modules/ECMVersionHeader.h.in
index 19eb96c5..ee033cd2 100644
--- a/modules/ECMVersionHeader.h.in
+++ b/modules/ECMVersionHeader.h.in
@@ -1,11 +1,11 @@
-#ifndef @PROJECT_NAME_UPPER@_VERSION_H
-#define @PROJECT_NAME_UPPER@_VERSION_H
+#ifndef @HEADER_PREFIX@_VERSION_H
+#define @HEADER_PREFIX@_VERSION_H
-#define @PROJECT_NAME_UPPER@_VERSION_STRING "@PROJECT_VERSION_STRING@"
-#define @PROJECT_NAME_UPPER@_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
-#define @PROJECT_NAME_UPPER@_VERSION_MINOR @PROJECT_VERSION_MINOR@
-#define @PROJECT_NAME_UPPER@_VERSION_PATCH @PROJECT_VERSION_PATCH@
-#define @PROJECT_NAME_UPPER@_VERSION ((@PROJECT_VERSION_MAJOR@<<16)|(@PROJECT_VERSION_MINOR@<<8)|(@PROJECT_VERSION_PATCH@))
+#define @HEADER_PREFIX@_VERSION_STRING "@HEADER_VERSION@"
+#define @HEADER_PREFIX@_VERSION_MAJOR @HEADER_VERSION_MAJOR@
+#define @HEADER_PREFIX@_VERSION_MINOR @HEADER_VERSION_MINOR@
+#define @HEADER_PREFIX@_VERSION_PATCH @HEADER_VERSION_PATCH@
+#define @HEADER_PREFIX@_VERSION ((@HEADER_VERSION_MAJOR@<<16)|(@HEADER_VERSION_MINOR@<<8)|(@HEADER_VERSION_PATCH@))
#endif
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;
+}