Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2021-10-29 20:08:18 +0300
committerSimon Tatham <anakin@pobox.com>2021-10-29 20:08:18 +0300
commit5eee8ca648c8453ff5308f7a009277eccfa80d16 (patch)
tree2ad6c439f483d709085609811c5108a854cd305f /cmake
parente24444dba81ef960b02bd7aa666ca5c6d46f03eb (diff)
Compatibility with older versions of cmake.
After this change, the cmake setup now works even on Debian stretch (oldoldstable), which runs cmake 3.7. In order to support a version that early I had to: - write a fallback implementation of 'add_compile_definitions' for older cmakes, which is easy, because add_compile_definitions(FOO) is basically just add_compile_options(-DFOO) - stop using list(TRANSFORM) and string(JOIN), of which I had one case each, and they were easily replaced with simple foreach loops - stop putting OBJECT libraries in the target_link_libraries command for executable targets, in favour of adding $<TARGET_OBJECTS:foo> to the main sources list for the same target. That matches what I do with library targets, so it's probably more sensible anyway. I tried going back by another Debian release and getting this cmake setup to work on jessie, but that runs CMake 3.0.1, and in _that_ version of cmake the target_sources command is missing, and I didn't find any alternative way to add extra sources to a target after having first declared it. Reorganising to cope with _that_ omission would be too much upheaval without a very good reason.
Diffstat (limited to 'cmake')
-rw-r--r--cmake/setup.cmake14
1 files changed, 12 insertions, 2 deletions
diff --git a/cmake/setup.cmake b/cmake/setup.cmake
index c0965c49..6612de97 100644
--- a/cmake/setup.cmake
+++ b/cmake/setup.cmake
@@ -55,9 +55,19 @@ add_custom_target(cmake_commit_c
DEPENDS check_git_commit ${INTERMEDIATE_COMMIT_C}
COMMENT "Updating cmake_commit.c")
+if(CMAKE_VERSION VERSION_LESS 3.12)
+ function(add_compile_definitions)
+ foreach(i ${ARGN})
+ add_compile_options(-D${i})
+ endforeach()
+ endfunction()
+endif()
+
function(add_sources_from_current_dir target)
- set(sources ${ARGN})
- list(TRANSFORM sources PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
+ set(sources)
+ foreach(i ${ARGN})
+ set(sources ${sources} ${CMAKE_CURRENT_SOURCE_DIR}/${i})
+ endforeach()
target_sources(${target} PRIVATE ${sources})
endfunction()