diff --git a/dlib/test/CMakeLists.txt b/dlib/test/CMakeLists.txt index 950b077a2..b1bd01f1d 100644 --- a/dlib/test/CMakeLists.txt +++ b/dlib/test/CMakeLists.txt @@ -142,26 +142,19 @@ PROJECT(${target_name}) # cmake that they are part of our target (which is the executable named test) ADD_EXECUTABLE(${target_name} main.cpp tester.cpp ${tests}) -# add the folder containing the dlib folder to the include path -INCLUDE_DIRECTORIES(../..) - # Turn on all warnings when using gcc. if (CMAKE_COMPILER_IS_GNUCXX) add_definitions("-W -Wall") endif() -# There is a CMakeLists.txt file in the dlib source folder that tells cmake -# how to build the dlib library. Tell cmake about that file. -add_subdirectory(.. dlib_build) + +# Tell cmake to link our target executable to dlib. +include(../cmake) +TARGET_LINK_LIBRARIES(${target_name} dlib ) + if (NOT DLIB_NO_GUI_SUPPORT) add_subdirectory(gui) endif() -# Tell cmake to link our target executable to the non-gui version of the dlib -# library. -TARGET_LINK_LIBRARIES(${target_name} dlib ) - -# make the default build be in "Release" mode -include(../release_build_by_default) diff --git a/dlib/test/gui/CMakeLists.txt b/dlib/test/gui/CMakeLists.txt index d8b43ff74..b673dc452 100644 --- a/dlib/test/gui/CMakeLists.txt +++ b/dlib/test/gui/CMakeLists.txt @@ -12,14 +12,9 @@ PROJECT(${target_name}) # cmake that they are part of our target (which is the executable named test) ADD_EXECUTABLE(${target_name} main.cpp ) -# add the folder containing the dlib folder to the include path +# Add the folder containing the dlib folder to the include path INCLUDE_DIRECTORIES(../../..) -# There is a CMakeLists.txt file in the dlib source folder that tells cmake -# how to build the dlib library. Tell cmake about that file. - - -# Tell cmake to link our target executable to the non-gui version of the dlib -# library. +# Tell cmake to link our target executable to dlib. TARGET_LINK_LIBRARIES(${target_name} dlib ) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index db4f0dc77..31bf26c23 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -4,30 +4,16 @@ # -# setting this makes CMake allow normal looking IF ELSE statements -SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) -cmake_minimum_required(VERSION 2.4) -if(COMMAND cmake_policy) - cmake_policy(SET CMP0003 NEW) -endif() - - -#set default build type to Release -include(../dlib/release_build_by_default) - - +cmake_minimum_required(VERSION 2.6) PROJECT(examples) -# add the folder containing the dlib folder to the include path -INCLUDE_DIRECTORIES(..) - - -# There is a CMakeLists.txt file in the dlib source folder that tells cmake -# how to build the dlib library. Tell cmake about that file. -add_subdirectory(../dlib dlib_build) - +include(../dlib/cmake) +# We are going to use a macro to add all the example programs. However, +# usually you will only create one executable in your cmake projects. +# Therefore, you would just need to invoke ADD_EXECUTABLE() and +# TARGET_LINK_LIBRARIES() as shown below. MACRO(add_example name) ADD_EXECUTABLE(${name} ${name}.cpp) TARGET_LINK_LIBRARIES(${name} dlib )