From 4f55291b8514103cbd63bc4cbafee0ba27468b9a Mon Sep 17 00:00:00 2001 From: Davis King Date: Tue, 21 May 2013 20:20:10 -0400 Subject: [PATCH] Made cmake file a little more convenient when used in large projects. --- dlib/cmake | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/dlib/cmake b/dlib/cmake index deda25105..f8466cc71 100644 --- a/dlib/cmake +++ b/dlib/cmake @@ -1,20 +1,24 @@ +# Don't add dlib if it's already been added to the cmake project +if (NOT TARGET dlib) -# Determine the path to dlib. -string(REPLACE "cmake" "" dlib_path ${CMAKE_CURRENT_LIST_FILE}) + # Determine the path to dlib. + string(REPLACE "cmake" "" dlib_path ${CMAKE_CURRENT_LIST_FILE}) -if (CMAKE_COMPILER_IS_GNUCXX) - # By default, g++ won't warn or error if you forget to return a value in a - # function which requires you to do so. This option makes it give a warning - # for doing this. - add_definitions("-Wreturn-type") + if (CMAKE_COMPILER_IS_GNUCXX) + # By default, g++ won't warn or error if you forget to return a value in a + # function which requires you to do so. This option makes it give a warning + # for doing this. + add_definitions("-Wreturn-type") + endif() + + # Add folder containing dlib to the include search path. + INCLUDE_DIRECTORIES(${dlib_path}/..) + + # This is really optional, but nice. It will make sure the build mode + # created by cmake is always release by default. + include(${dlib_path}/release_build_by_default) + + add_subdirectory(${dlib_path} dlib_build) endif() -# Add folder containing dlib to the include search path. -INCLUDE_DIRECTORIES(${dlib_path}/..) - -# This is really optional, but nice. It will make sure the build mode -# created by cmake is always release by default. -include(${dlib_path}/release_build_by_default) - -add_subdirectory(${dlib_path} dlib_build)