Skip to content

Commit 0d0888a

Browse files
[build] Fixed CMake CMP0048 policy restriction (#1765)
1 parent 954968a commit 0d0888a

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

CMakeLists.txt

+14-13
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88
#
99

1010
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
11-
# XXX This can be potentially done in future, but there still exist
12-
# some dependent project using cmake 2.8 - this can't be done this way.
13-
#cmake_minimum_required (VERSION 3.0.2 FATAL_ERROR)
14-
#project(SRT VERSION "1.4.2")
15-
project(SRT C CXX)
11+
set (SRT_VERSION 1.4.2)
1612

1713
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
18-
include(haiUtil)
14+
include(haiUtil) # needed for set_version_variables
15+
# CMake version 3.0 introduced the VERSION option of the project() command
16+
# to specify a project version as well as the name.
17+
if(${CMAKE_VERSION} VERSION_LESS "3.0.0")
18+
project(SRT C CXX)
19+
# Sets SRT_VERSION_MAJOR, SRT_VERSION_MINOR, SRT_VERSION_PATCH
20+
set_version_variables(SRT_VERSION ${SRT_VERSION})
21+
else()
22+
cmake_policy(SET CMP0048 NEW)
23+
# Also sets SRT_VERSION_MAJOR, SRT_VERSION_MINOR, SRT_VERSION_PATCH
24+
project(SRT VERSION ${SRT_VERSION} LANGUAGES C CXX)
25+
endif()
26+
1927
include(FindPkgConfig)
2028
# XXX See 'if (MINGW)' condition below, may need fixing.
2129
include(FindThreads)
@@ -43,9 +51,6 @@ if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
4351
include(GNUInstallDirs)
4452
endif()
4553

46-
set (SRT_VERSION 1.4.2)
47-
set_version_variables(SRT_VERSION ${SRT_VERSION})
48-
4954
# The CMAKE_BUILD_TYPE seems not to be always set, weird.
5055
if (NOT DEFINED ENABLE_DEBUG)
5156

@@ -775,8 +780,6 @@ MafReadDir(srtcore filelist.maf
775780
PRIVATE_HEADERS HEADERS_srt_private
776781
)
777782

778-
message(STATUS "SRT Sources: ${SOURCES_srt}")
779-
780783
# Auto generated version file and add it to the HEADERS_srt list.
781784
if(DEFINED ENV{APPVEYOR_BUILD_NUMBER})
782785
set(SRT_VERSION_BUILD ON)
@@ -1199,8 +1202,6 @@ if (ENABLE_UNITTESTS AND ENABLE_CXX11)
11991202
MafReadDir(test filelist.maf
12001203
SOURCES SOURCES_unittests
12011204
)
1202-
1203-
message(STATUS "Unit test sources: ${SOURCES_unittests}")
12041205

12051206
srt_add_program(test-srt ${SOURCES_unittests})
12061207
srt_make_application(test-srt)

0 commit comments

Comments
 (0)