Skip to content

Commit

Permalink
cmake: enable CMP0051
Browse files Browse the repository at this point in the history
the new behavior of get_target_property(<var> <target> SOURCES) will be
enforced in future versions of cmake, so let ready for this change now
by removing the generator expressions from the returned source file
list.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Apr 26, 2018
1 parent 4aea3be commit 791af54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 1 addition & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
if(POLICY CMP0051)
# cmake 3.1 and higher include generator expressions in SOURCES property.
# in BuildBoost.cmake, get_target_property(<var> <target> SOURCES) is used
# to retrieve the source files of a target. in that case, we are only
# interested in the *source* files. and i don't want to bother stripping off
# the TARGET_OBJECTS elements from the returned SOURCES. so let's stick with
# the old behavior now.
cmake_policy(SET CMP0051 OLD)
cmake_policy(SET CMP0051 NEW)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")

Expand Down
3 changes: 3 additions & 0 deletions cmake/modules/BuildBoost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ function(maybe_add_boost_dep target)
return()
endif()
get_target_property(sources ${target} SOURCES)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
string(GENEX_STRIP "${sources}" sources)
endif()
foreach(src ${sources})
get_filename_component(ext ${src} EXT)
# assuming all cxx source files include boost header(s)
Expand Down

0 comments on commit 791af54

Please sign in to comment.