Make everything work in cmake 3.8

This commit is contained in:
Davis King 2023-03-23 20:07:48 -04:00
parent b7834324b4
commit 806b629035
2 changed files with 16 additions and 4 deletions

View File

@ -184,7 +184,11 @@ if (CMAKE_COMPILER_IS_GNUCXX)
# definitely heap allocated. # definitely heap allocated.
add_compile_options(-Wno-free-nonheap-object) add_compile_options(-Wno-free-nonheap-object)
endif() endif()
target_link_options(${target_name} PRIVATE $<$<CONFIG:RELEASE>:-s>)
if(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
# strip debug symbols to make the binary smaller
target_link_options(${target_name} PRIVATE $<$<CONFIG:RELEASE>:-s>)
endif()
elseif (MSVC) elseif (MSVC)
# Treat warnings as errors. # Treat warnings as errors.
@ -194,7 +198,11 @@ else() # basically Clang
add_compile_options(-W -Werror) add_compile_options(-W -Werror)
# This is for the comment in face_detection_ex.cpp that says "faces/*.jpg" # This is for the comment in face_detection_ex.cpp that says "faces/*.jpg"
add_compile_options(-Wno-comment) add_compile_options(-Wno-comment)
target_link_options(${target_name} PRIVATE $<$<CONFIG:RELEASE>:-s>)
if(${CMAKE_VERSION} VERSION_GREATER "3.8.0")
# strip debug symbols to make the binary smaller
target_link_options(${target_name} PRIVATE $<$<CONFIG:RELEASE>:-s>)
endif()
endif() endif()

View File

@ -106,8 +106,12 @@ target_link_libraries(assignment_learning_ex dlib::dlib)
macro(add_example name) macro(add_example name)
add_executable(${name} ${name}.cpp) add_executable(${name} ${name}.cpp)
target_link_libraries(${name} dlib::dlib ) 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 $<$<CONFIG:RELEASE>:-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 $<$<CONFIG:RELEASE>:-s>)
endif()
endmacro() endmacro()
# if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude # if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude