Skip to content

Commit 4f08296

Browse files
Merge pull request #149 from matthew-hennefarth/fix-build-pedantic
Fix -DBUILD_WITH_PEDANTIC_WARNINGS=ON
2 parents 2d870d2 + 04b5966 commit 4f08296

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ else()
3333
set(NOT_DEBUG_MODE ON)
3434
endif()
3535

36+
# Function to link external libraries as system libraries
37+
include (cmake/LinkExternalLibraries.cmake)
38+
3639
#######################################################
3740
### Options ###
3841
#######################################################

cmake/LinkExternalLibraries.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function(target_link_libraries_system target)
2+
set(options PRIVATE PUBLIC INTERFACE)
3+
cmake_parse_arguments(TLLS "${options}" "" "" ${ARGN})
4+
foreach(op ${options})
5+
if(TLLS_${op})
6+
set(scope ${op})
7+
endif()
8+
endforeach(op)
9+
set(libs ${TLLS_UNPARSED_ARGUMENTS})
10+
11+
foreach(lib ${libs})
12+
get_target_property(lib_include_dirs ${lib} INTERFACE_INCLUDE_DIRECTORIES)
13+
if(lib_include_dirs)
14+
if(scope)
15+
target_include_directories(${target} SYSTEM ${scope} ${lib_include_dirs})
16+
else()
17+
target_include_directories(${target} SYSTEM PRIVATE ${lib_include_dirs})
18+
endif()
19+
else()
20+
message("Warning: ${lib} doesn't set INTERFACE_INCLUDE_DIRECTORIES. No include_directories set.")
21+
endif()
22+
if(scope)
23+
target_link_libraries(${target} ${scope} ${lib})
24+
else()
25+
target_link_libraries(${target} ${lib})
26+
endif()
27+
endforeach()
28+
endfunction(target_link_libraries_system)

source/matplot/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ target_include_directories(matplot
9090
PUBLIC $<BUILD_INTERFACE:${MATPLOT_ROOT_DIR}/source>
9191
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
9292

93-
target_link_libraries(matplot
94-
PRIVATE cimg nodesoup std::filesystem)
93+
target_link_libraries_system(matplot
94+
PRIVATE cimg nodesoup std::filesystem)
9595

9696
# https://cmake.org/cmake/help/v3.14/manual/cmake-compile-features.7.html#requiring-language-standards
9797
target_compile_features(matplot PUBLIC cxx_std_17)
@@ -242,4 +242,4 @@ if (BUILD_INSTALLER)
242242
NAMESPACE Matplot++::
243243
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++
244244
)
245-
endif()
245+
endif()

0 commit comments

Comments
 (0)