Skip to content

Commit f339ef8

Browse files
committed
use return propagate
1 parent e81a086 commit f339ef8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

CMake/ystdlib-cpp-helpers.cmake

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
# check_if_header_only_library()
22
#
3-
# @param SOURCE_LIST The list of source files that a target library uses
4-
# @param IS_HEADER_ONLY Returns whether the target library only contains header files
3+
# @param SOURCE_LIST The list of source files that a target library uses.
4+
# @param IS_HEADER_ONLY Returns whether the target library only contains header files.
55
function(check_if_header_only_library SOURCE_LIST IS_HEADER_ONLY)
66
set(_LOCAL_SOURCE_LIST "${${SOURCE_LIST}}")
7+
set(${IS_HEADER_ONLY} FALSE)
78
foreach(src_file IN LISTS _LOCAL_SOURCE_LIST)
8-
if(${src_file} MATCHES ".*\\.(h|hpp|inc)")
9-
list(REMOVE_ITEM _LOCAL_SOURCE_LIST "${src_file}")
9+
if(NOT ${src_file} MATCHES ".*\\.(h|hpp)")
10+
return(PROPAGATE ${IS_HEADER_ONLY})
1011
endif()
1112
endforeach()
12-
13-
if(_LOCAL_SOURCE_LIST STREQUAL "")
14-
set(${IS_HEADER_ONLY} TRUE PARENT_SCOPE)
15-
else()
16-
set(${IS_HEADER_ONLY} FALSE PARENT_SCOPE)
17-
endif()
13+
set(${IS_HEADER_ONLY} TRUE PARENT_SCOPE)
1814
endfunction()
1915

2016
# Adds a c++20 interface library in the subdirectory NAME with the target NAME and alias

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
cmake_minimum_required(VERSION 3.22.1)
22

3+
# Enables return() arguments e.g. return([PROPAGATE <var-name>...])
4+
cmake_policy(SET CMP0140 NEW)
5+
36
project(YSTDLIB_CPP LANGUAGES CXX)
47

58
set(YSTDLIB_CPP_VERSION "0.0.1" CACHE STRING "Project version.")

0 commit comments

Comments
 (0)