diff options
author | Alex Merry <alex.merry@kde.org> | 2014-04-17 15:46:08 +0100 |
---|---|---|
committer | Alex Merry <alex.merry@kde.org> | 2014-04-25 10:39:56 +0100 |
commit | 035c6fa9390ecb66422ee684be71eea692989009 (patch) | |
tree | f95921a78c1e59b2ee890feb703f7a55341a2961 /tests/ECMSetupVersionTest/new_project_version_file_abspath | |
parent | 50b164a7ce83cdaec18209c7c2226d2fdb9cf29e (diff) | |
download | extra-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/ECMSetupVersionTest/new_project_version_file_abspath')
-rw-r--r-- | tests/ECMSetupVersionTest/new_project_version_file_abspath/CMakeLists.txt | 46 | ||||
-rw-r--r-- | tests/ECMSetupVersionTest/new_project_version_file_abspath/main.c | 4 |
2 files changed, 50 insertions, 0 deletions
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; +} |