From 806b62903500a1aa1d45edf074b54a41db5af538 Mon Sep 17 00:00:00 2001 From: Davis King Date: Thu, 23 Mar 2023 20:07:48 -0400 Subject: [PATCH] Make everything work in cmake 3.8 --- dlib/test/CMakeLists.txt | 12 ++++++++++-- examples/CMakeLists.txt | 8 ++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/dlib/test/CMakeLists.txt b/dlib/test/CMakeLists.txt index 249b38164..a20640a85 100644 --- a/dlib/test/CMakeLists.txt +++ b/dlib/test/CMakeLists.txt @@ -184,7 +184,11 @@ if (CMAKE_COMPILER_IS_GNUCXX) # definitely heap allocated. add_compile_options(-Wno-free-nonheap-object) endif() - target_link_options(${target_name} PRIVATE $<$:-s>) + + if(${CMAKE_VERSION} VERSION_GREATER "3.8.0") + # strip debug symbols to make the binary smaller + target_link_options(${target_name} PRIVATE $<$:-s>) + endif() elseif (MSVC) # Treat warnings as errors. @@ -194,7 +198,11 @@ else() # basically Clang add_compile_options(-W -Werror) # This is for the comment in face_detection_ex.cpp that says "faces/*.jpg" add_compile_options(-Wno-comment) - target_link_options(${target_name} PRIVATE $<$:-s>) + + if(${CMAKE_VERSION} VERSION_GREATER "3.8.0") + # strip debug symbols to make the binary smaller + target_link_options(${target_name} PRIVATE $<$:-s>) + endif() endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 579e87a74..e8f720656 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -106,8 +106,12 @@ target_link_libraries(assignment_learning_ex dlib::dlib) macro(add_example name) add_executable(${name} ${name}.cpp) target_link_libraries(${name} dlib::dlib ) - # And strip symbols to make your binary smaller if you like. Certainly not required though. - target_link_options(${name} PRIVATE $<$:-s>) + + if(${CMAKE_VERSION} VERSION_GREATER "3.8.0") + # And strip symbols to make your binary smaller if you like. Certainly not + # required though. + target_link_options(${name} PRIVATE $<$:-s>) + endif() endmacro() # if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude