From 23857dc1e8a0aee2a1ce3b53d06bb724e47b90a7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 9 Feb 2019 21:23:16 +0100 Subject: cmake: wrap around for function var scope --- cmake/opentrack-boilerplate.cmake | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'cmake') diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 0e9516a8..10ef96a3 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -28,14 +28,18 @@ set(new-hier-path "#pragma once include_directories("${CMAKE_BINARY_DIR}") -set(hier-path-filename "${CMAKE_BINARY_DIR}/opentrack-library-path.hxx") -set(orig-hier-path "") -if(EXISTS "${hier-path-filename}") - file(READ ${hier-path-filename} orig-hier-path) -endif() -if(NOT (orig-hier-path STREQUAL new-hier-path)) - file(WRITE "${hier-path-filename}" "${new-hier-path}") -endif() +function(otr_write_library_paths) + set(hier-path-filename "${CMAKE_BINARY_DIR}/opentrack-library-path.hxx") + set(orig-hier-path "") + if(EXISTS "${hier-path-filename}") + file(READ ${hier-path-filename} orig-hier-path) + endif() + if(NOT (orig-hier-path STREQUAL new-hier-path)) + file(WRITE "${hier-path-filename}" "${new-hier-path}") + endif() +endfunction() + +otr_write_library_paths() function(otr_glob_sources var) set(basedir "${CMAKE_CURRENT_SOURCE_DIR}") -- cgit v1.2.3